Building C project

Applications, development tools, FPGA, C, WEB
Gagagou
Posts: 2
Joined: Mon Jul 12, 2021 9:17 am

Building C project

Post by Gagagou » Mon Jul 12, 2021 9:22 am

Hi everyone,

I have an issue using redpitaya board and vivado/vitis.

I've created an Hello World project with vivado/vitis that's working with jtag and the board, but i want to build it so i can execute it from the board like in this exemple : https://redpitaya.readthedocs.io/en/lat ... /comC.html

But i can't make it works, i can't build it from the bord, even if i copy every library.

So i wanted to know if there is a way to compile the project from vitis/vivado and then simply export it with sftp ?

Gagagou
Posts: 2
Joined: Mon Jul 12, 2021 9:17 am

Re: Building C project

Post by Gagagou » Wed Jul 28, 2021 7:51 am

Hi guys,

Coming with more information and test.

To resmue, i'm trying to compile and running a C program created with Xilinx SDK on Redpitaya OS.
It's just the simple Helloworld created with SDK

Code: Select all

#include <stdio.h>
#include <platform.h>
#include <xil_printf.h>


int main()
{
    init_platform();

    print("Hello World\n\r");
    print("Successfully ran Hello World application");
    cleanup_platform();
    return 0;
}

pavel
Posts: 656
Joined: Sat May 23, 2015 5:22 pm

Re: Building C project

Post by pavel » Wed Jul 28, 2021 8:28 am

To resmue, i'm trying to compile and running a C program created with Xilinx SDK on Redpitaya OS.
If by Redpitaya OS you mean Ubuntu Linux installed on the SD card image provided by Red Pitaya developers and if you want to run this program on Linux, then I think the easiest would be to compile this program directly on the Red Pitaya board.

The command to compile the code is

Code: Select all

gcc test.c -o test
The Xilinx includes and functions should be removed from the code:

Code: Select all

#include <stdio.h>

int main()
{
    printf("Hello World\n");
    printf("Successfully ran Hello World application\n");
    return 0;
}
If the gcc compiler isn't installed, it can be installed with the following commands:

Code: Select all

apt-get update
apt-get install build-essential

gagagou_
Posts: 5
Joined: Wed Jul 28, 2021 8:42 am

Re: Building C project

Post by gagagou_ » Wed Jul 28, 2021 8:46 am

Hi Pavel, sorry my post wasn't finished and i wanted to edit it, but i forgot my password blablabla.. Anyway.

Yeah by Redpitaya OS i mean Ubuntu on SD card, and i'm actually trying to compile it from there
Why does the Xilinx Includes and fonction should be removed ?
Because i'm trying with Helloworld right now, but it will be used with a more complicated code using those xilinx fonction

Here the post with everything that i wanted to post


Hi guys,

Coming with more information and test.

To resmue, i'm trying to compile and running a C program created with Xilinx SDK on Redpitaya OS.
It's just the simple Helloworld created with SDK

Code: Select all

#include <stdio.h>
#include <platform.h>
#include <xil_printf.h>


int main()
{
    init_platform();

    print("Hello World\n\r");
    print("Successfully ran Hello World application");
    cleanup_platform();
    return 0;
}
but when i'm trying to compile it on my laptop with ubuntu 20.04.2 LTS or Redpitaya OS i'm running into some issues.

First i'm having this one

Code: Select all

Grekt:~/xilinx_sdk_workspace/workspace/HelloWorld/src$ gcc helloworld.c -o helloworld
helloworld.c:49:10: fatal error: platform.h: No such file or directory
   49 | #include <platform.h>
      |          ^~~~~~~~~~~~
compilation terminated.
I've resolved it by copying every header from xilinx vivado/SDK installation to the working directory where i'm compiling, or into /usr/include
But it's not really convenient

Then when i'd every headers needed, i had this issue :

Code: Select all

Grekt:~/xilinx_sdk_workspace/workspace/HelloWorld/src$ gcc helloworld.c -o helloworld
/usr/bin/ld: /tmp/ccBivcU1.o: in function `main':
helloworld.c:(.text+0xe): undefined reference to `init_platform'
/usr/bin/ld: helloworld.c:(.text+0x1a): undefined reference to `print'
/usr/bin/ld: helloworld.c:(.text+0x26): undefined reference to `print'
/usr/bin/ld: helloworld.c:(.text+0x30): undefined reference to `cleanup_platform'
collect2: error: ld returned 1 exit status
I asked on a discord server who's programming in C how can i solve this, and they said that i had to add another piece of program to get it right.
So i've searched into xilinx directory to get every program and added them to the working directory.
And the compilation worked !

but then, when i tried to run the program i had this error :

Code: Select all

Grekt:~/xilinx_sdk_workspace/workspace/HelloWorld/src$ gcc helloworld.c platform.c print.c outbyte.c xuartps_hw.c -o helloworld
Grekt:~/xilinx_sdk_workspace/workspace/HelloWorld/src$ ./helloworld
Segmentation fault (core dumped)

Code: Select all

Grekt:~/xilinx_sdk_workspace/workspace/HelloWorld/src$ ./helloworld
AddressSanitizer:DEADLYSIGNAL
=================================================================
==47264==ERROR: AddressSanitizer: SEGV on unknown address 0x00009bff8005 (pc 0x55fc4708f400 bp 0x7ffef322d330 sp 0x7ffef322d320 T0)
==47264==The signal is caused by a READ memory access.
    #0 0x55fc4708f3ff in Xil_In32 /usr/include/xil_io.h:153
    #1 0x55fc4708f4a8 in XUartPs_SendByte /home/gagagou/xilinx_sdk_workspace/workspace/HelloWorld/src/xuartps_hw.c:83
    #2 0x55fc4708f3c7 in outbyte /home/gagagou/xilinx_sdk_workspace/workspace/HelloWorld/src/outbyte.c:14
    #3 0x55fc4708f343 in print /home/gagagou/xilinx_sdk_workspace/workspace/HelloWorld/src/print.c:29
    #4 0x55fc4708f226 in main /home/gagagou/xilinx_sdk_workspace/workspace/HelloWorld/src/helloworld.c:57
    #5 0x7f6efac760b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #6 0x55fc4708f14d in _start (/home/gagagou/xilinx_sdk_workspace/workspace/HelloWorld/src/helloworld+0x114d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/include/xil_io.h:153 in Xil_In32
==47264==ABORTING
And i don't know what to do to make it working.

Does anyone already compile C program on Redpitaya OS and if yes, did they had to include xilinx header by hand, or there is something to do to get it right.

pavel
Posts: 656
Joined: Sat May 23, 2015 5:22 pm

Re: Building C project

Post by pavel » Wed Jul 28, 2021 11:02 am

Why does the Xilinx Includes and fonction should be removed ?
Why do you think your hello world code needs them?

As far as I know, Xilinx includes and functions are only used for bare metal applications. Programs running on Linux use Linux and libc headers.

For example, my applications for the Red Pitaya board can be found at this link. None of them use Xilinx includes and they work.

gagagou_
Posts: 5
Joined: Wed Jul 28, 2021 8:42 am

Re: Building C project

Post by gagagou_ » Wed Jul 28, 2021 11:14 am

I don't really know.
When i'm using this code with SDK and JTAG it supposed to send Helloworld to my com port MIO14-15 but when i'm compiling the with printf and removing all the include, it will only print it to my current shell, ssh, com whatever.
So i guess i need the Xilinx include and fonctions to make it working fine.

And people working with me and developing are using SDK to dev and it could be cool if the same code that's working with SDK and JTAG, could work directly on the board by just compiling it and not using SDK and JTAG.

I don't know if i'm clear enought ^^'

pavel
Posts: 656
Joined: Sat May 23, 2015 5:22 pm

Re: Building C project

Post by pavel » Wed Jul 28, 2021 11:20 am

gagagou_ wrote:
Wed Jul 28, 2021 11:14 am
And people working with me and developing are using SDK to dev and it could be cool if the same code that's working with SDK and JTAG, could work directly on the board by just compiling it and not using SDK and JTAG.
I think that in this case it would be more efficient to ask these people to give you an example of working program.

pavel
Posts: 656
Joined: Sat May 23, 2015 5:22 pm

Re: Building C project

Post by pavel » Wed Jul 28, 2021 11:29 am

gagagou_ wrote:
Wed Jul 28, 2021 11:14 am
When i'm using this code with SDK and JTAG it supposed to send Helloworld to my com port MIO14-15 but when i'm compiling the with printf and removing all the include, it will only print it to my current shell, ssh, com whatever.
So i guess i need the Xilinx include and fonctions to make it working fine.
The serial ports under Linux are accessed via /dev/tty device files. Here is a link to a tutorial:
https://blog.mbedded.ninja/programming/ ... ing-c-cpp/

gagagou_
Posts: 5
Joined: Wed Jul 28, 2021 8:42 am

Re: Building C project

Post by gagagou_ » Wed Jul 28, 2021 2:03 pm

Hum so there is no way to use a C program written with Xilinx SDK in the Redpitaya Ubuntu ?
I've to change everything to match linux headers and fonctions ?

gagagou_
Posts: 5
Joined: Wed Jul 28, 2021 8:42 am

Re: Building C project

Post by gagagou_ » Wed Jul 28, 2021 2:08 pm

pavel wrote:
Wed Jul 28, 2021 11:20 am
gagagou_ wrote:
Wed Jul 28, 2021 11:14 am
And people working with me and developing are using SDK to dev and it could be cool if the same code that's working with SDK and JTAG, could work directly on the board by just compiling it and not using SDK and JTAG.
I think that in this case it would be more efficient to ask these people to give you an example of working program.

Didn't see you answered twice,
Well the helloworld posted previously is a program that work within the SDK and the JTAG connection but not when i'm compiling it in linux

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 2 guests