Just about everything about Red Pitaya
#95 by Wylde
Mon Jun 23, 2014 2:03 pm
Hello everybody,

I have no previous experience with FPGAs or hardware programming and I would therefore like to start getting familiar with my redpitaya by compiling the existing FPGA code (later on, I will then make small adjustments to the code and check if everything behaves as planned etc.). However, I have a number of problems and questions that came up in the context of this undertaking, which I'd like to list in the following.

1.) I have installed Vivado 2013.3 on an ubuntu-based virtual machine on my computer. According to the "FPGA develpment environment" section, I should be able to compile the FPGA code by first using the command "source /usr/local/xilinx/Vivado/2013.3/settings64.sh" (which I altered to match the corresponding directory on my computer) in the TCL window (?) and then just open the redpitaya project file to compile the code (with synthesis, implementation and bitstream generation being performed using the vivado GUI). However, I already get an error message when trying to set the working environment:

Code: Select allsource /opt/Xilinx/Vivado/2013.3/settings64.sh
can't read "_": no such variable
    while executing
    (file "/opt/Xilinx/Vivado/2013.3/settings64.sh" line 3)

Secondly, when I click "Run Synthesis" on the vivado GUI, the synthesis fails and I get a number of error messages (12 at first, later more). Does anybody have an idea why this is the case?

2.) Interestingly enough, I can on the other hand generate the red_pitaya_top.bit file by using the GNU make mechanism and the corresponding makefile in RedPitaya/FPGA/release1/fpga (note: this also produces a lot of warnings but no critical ones or errors). However, while the 'make [...] fpga' command works, I get another error message when trying to execute the 'make [...] sw_package' command, which looks something like this:

Code: Select allmake[1]: libgen: Command not found
make[1]: *** [ps7_cortexa9_0/lib/libxil.a] Error 127
make[1]: Target `all' not remade because of errors.
make[1]: Leaving directory `/home/labuser/VivadoCompilationTest/RedPitaya/FPGA/release1/fpga/vivado/red_pitaya.sdk/SDK/SDK_Export/fsbl_bsp'
make: *** [fsbl_bsp] Error 2

Again, I would be thankful if anybody had any advice on how to deal with this problem.

3.) This may be a stupid question but even if everything compiled nicely, I would still not be sure which files I would actually need to copy where onto the RedPitaya to implement the compiled code on the system. Also, I am rather unsure about the meaning of the 'fpga.bit' files in the individual application folders in the repository, which are said to have a size of 0 bytes by both github and my file system on the computer. So if anybody could shortly describe how to get compiled FPGA code onto the redpitaya such that it works, I would be very thankful.

Please accept my aplogies in case any of the above should be covered in some documentation but I couldn't find any help on the wiki pages so far. Thanks in advance for any help!

Last edited by Wylde on Tue Jun 24, 2014 1:50 pm, edited 1 time in total.
#98 by Nils Roos
Mon Jun 23, 2014 6:01 pm
Regarding point 3):
The output of the full RedPitaya build are several zip-files
1. RedPitaya/ecosystem-<version>-<release>.zip (eg. ecosystem-0.92-0-devbuild.zip)
2. RedPitaya/Applications/<appname>-<version>-<release>.zip

To install these, proceed as follows:
1. mount your SD-card as a writable drive
2. erase its contents
3. unpack the ecosystem-zip into the the SD's root directory
4. change to the /www/apps directory (which has been created during unpacking of ecosystem)
5. unpack application-zips here

You can do all of these steps on the RedPitaya via console, just put the zips into a temporary directory and remember that the RP-filesystem resides in RAM; also, be mindful that the SD-card is mounted as /opt and needs to be remounted writable by executing "rw".
#99 by Nils Roos
Mon Jun 23, 2014 6:36 pm
Regarding point 2):
Did you install SDK 2013.3 alongside your Vivado 2013.3 ? As far as I remember, the SDK needed to be separately selected during installation. The SDK should be in the directory /opt/Xilinx/SDK/2013.3 if you installed it alongside Vivado.
One other thing, since you seem to have used the Vivado default installation location, you need to change the path to the toolchain in the file RedPitaya/OS/buildroot/config (line 138)
Code: Select allBR2_TOOLCHAIN_EXTERNAL_PATH="/opt/Xilinx/SDK/2013.3/gnu/arm/lin"
#101 by Nils Roos
Mon Jun 23, 2014 8:57 pm
Regarding point 1):
The wikipage "FPGA development environment" says nothing about using the source command from within tcl console, you should use "source /opt/Xilinx/Vivado/2013.3/settings64.sh" in the shell before starting Vivado with "/opt/Xilinx/Vivado/2013.3/bin/vivado".

The errors during synthesis stem from wrong or missing LANG and LC_ALL environment variables. Make sure to have the locale en_US (or any other locale that uses a point as decimal separator, really) installed on your system and start Vivado with the following sequence of commands:

Code: Select allsource /opt/Xilinx/Vivado/2013.3/settings64.sh
export LANG=en_US
export LC_ALL=en_US

This should solve your synthesis issues - it did solve mine just now :mrgreen: .
#102 by Nils Roos
Mon Jun 23, 2014 9:20 pm
One last thing:

Thank you, thank you, thank you for asking this question.

This last bit with the environment variables also solves some very weird issues I have been having with migrating to Vivado 2014.2. Without your question as a starting point, I would have never thought of that.
#105 by Wylde
Tue Jun 24, 2014 1:42 pm
Hey Nils,

first of all, thank you very much for this elaborate answer, I really appreciate it. As I am quite new to the subject matter, I still have some follow-up questions:

Regarding point 1)

The command lines you posted did in fact solve the problem and I can now run the synthesis using the Vivado GUI. Thanks a lot!

Regarding point 2)

I already had SDK installed as you described it. Unfortunately, while I am sure the wrong path in the config file would have caused error messages at a later point, I still get the same error after changing it, i.e. I still get the following output when trying to run the "make FPGA_TOOL=vivado sw_package" command:

Code: Select allmake[1]:
make[1]: libgen: Command not found
make[1]: *** [ps7_cortexa9_0/lib/libxil.a] Error 127
make[1]: Target `all' not remade because of errors.
make[1]: Leaving directory `/home/labuser/VivadoCompilationTest/RedPitaya/FPGA/release1/fpga/vivado/red_pitaya.sdk/SDK/SDK_Export/fsbl_bsp'
make: *** [fsbl_bsp] Error 2

So it seems like there is some trouble with the libgen command (I suppose it is a command, although a quick google search almost made it seem like a library to me?). I manually checked and found the corresponding code in the Makefile under "RedPitaya/FPGA/release1/fpga/vivado/red_pitaya.sdk/SDK/SDK_Export/fsbl_bsp", which confuses me even more because it says the Makefile was generated with SDK and since I have that installed, I wouldn't know why there should be any unknown terms appearing.

So if you or anybody else had another idea how to solve the issue, I would highly appreciate it.

[EDIT] I have just found out what caused the error and also figured out a way how to deal with a subsequent one: In addition to having SDK installed, one should also execute a command like

Code: Select allsource /opt/Xilinx/SDK/2013.3/settings64.sh

in analogy to the corresponding command for the vivado settings that is documented on the redpitaya wiki. After doing so, I then received a lot of error messages stating that the gmake command could not be found, which I was able to overcome by linking the gmake command to the make command:

Code: Select allsudo ln -s /usr/bin/make /usr/bin/gmake

Now I still get some error messages but I will see how persistent they are before I post again.

Regarding point 3)

Again, thanks a lot, such an explanation is exactly what I've been looking for. However, could you maybe lose a few words on what you call "the full RedPitayaBuild"? Up to now I am only aware of the process up to the point of bitstream generation (or perhaps the device-tree and image file creation) as described in the wiki article. Would I then simply execute something like

Code: Select allmake BUILD_NUMBER=1 CROSS_COMPILE=arm-linux-gnueabi- zip

to create the .zip files in the corresponding directories (similar to what is done in the web application tutorial) or are there more steps in between that I am missing? Thanks again!

#108 by Wylde
Tue Jun 24, 2014 6:54 pm
Hey again,

having dealt with the original problems regarding the make [...] sw_package command as described in the edited post, I now ended up receiving the following error:

Code: Select allarm-xilinx-eabi-gcc: Command not found

After a bit of googling I found a lot of documentation on this error, especially in combination with the PlanAhead tool and the ISE design suite but I wasn't able to get anything useful out of it that would have solved the problem. I am using Vivado/SDK 2013.3 on a 64-bit Ubuntu system in a virtual machine. A simple search showed that there is in fact an executable named arm-xilinx-eabi-gcc (together with a large amount of associated files) stored under /opt/Xilinx/SDK/2013.3/gnu/arm/lin/bin on my computer.

Any help or advice how to deal with this would be highly appreciated.

[EDIT2] Fixed it as well. If any other newbie should have the same problem: the issue seems to be common when using a 64-bit system and can also occur in other contexts when some libraries are not installed (some more information here, here and here). For me, the simple command line

Code: Select allsudo apt-get install gcc-4.7-multilib

did the job. I now have another error message but I will wait if I can solve the problem myself. Sorry for all the editing but maybe my documented struggles can actually be helpful to other people who are new to all of this.

Last edited by Wylde on Wed Jun 25, 2014 9:31 am, edited 4 times in total.
#109 by Nils Roos
Tue Jun 24, 2014 10:19 pm
Hi Robert
By "full RedPitaya build" I refer to the process described in RedPitaya/INSTALL.
This generates the full ecosystem (fpga bitstream, u-boot bootloader, linux kernel, ramdisk image with buildroot environment, nginx webserver) and the RedPitaya applications (scope, etc).

Now that you mention it, I had pretty much the same issues (gmake, arm-xilinx-eabi-gcc, etc) while trying to build the "sw-package" target separately. Most of them simply disappeared when I tried the full build as a sanity check of my build environment.
I assume that this has something to do with environment propagation through the make hierarchy but since I had found a process that works I did not investigate further.

A quick checklist for the full build:
- install Vivado 2013.3 + SDK 2013.3
- get a bare clone of github.com/Xilinx/u-boot-xlnx and github.com/Xilinx/linux-xlnx
Code: Select allgit clone --bare https://github.com/Xilinx/u-boot-xlnx /var/git/u-boot-xlnx.git
git clone --bare https://github.com/Xilinx/linux-xlnx /var/git/linux-xlnx.git
- symbolic link gmake -> make
- edit the path to the SDK toolchain in RedPitaya/OS/buildroot/config:138
- append "RedPitaya/OS/u-boot/u-boot-xlnx/tools" to your PATH if you don't already have the mkimage utility somewhere on your system (fill in the bits before "RedPitaya" as needed, eg "/home/nils/RedPitaya/...")
- find something to do for the next ~30 minutes, depending on your system :lol:

It's probably a good idea to test if you can run the full build successfully. The mkimage utility is generated in the course of the u-boot build, and you will need that to create the u-boot-loadable kernel image (uImage) that is packaged with the bitstream. Possibly there are other ways to get the uImage, but being able to build the whole thing yourself has its own rewards, in my opinion.
#113 by Wylde
Wed Jun 25, 2014 7:05 pm
Hey Nils,

again, thanks a lot! I now think I have a certain understanding of what is going on and will for now focus on executing the full build process without trying to generate the individual components seperately. However, after following the instructions both from you and the INSTALL file in the RedPitaya repository, I still get some error messages when executing the make and make -C Applications commands. For the former, the system lists a number of undefined references similar to the following snippet:

Code: Select allfs/libfs.o:(.data+0x4): undefined reference to `fat_set_blk_dev'

and subsequently gives the error message

Code: Select allarm-xilinx-eabi-ld: error: required section '.rel.plt' not found in the linker script
arm-xilinx-eabi-ld: final link failed: Invalid operation

The make -C Applications command on the other hand gives the error

Code: Select allmake[2]: arm-xilinx-gnueabi-gcc: Command not found

Would you have any idea why that is (especially the errors after the make command)? I did not have much time to google-search the error messages yet and may find a solution tomorrow, but as you have been through the whole process, I thought I'd ask (sorry if the solution to this should be quite obvious or easy to find elsewhere).

Furthermore, as I continue to have struggles witht the full build, I was wondering if it would also be possible to slightly modify the verilog code for some application (e.g. the PID controller), generate the complete bitstream (which works nicely and should be less effort then running the full build) and implement the changes in a less invasive way, e.g. simply by replacing the fpga.bit file in the corresponding (PID) application directory on the RedPitaya. Asked in a different, more general way, this question translates to the following - what is the purpose of the individual fpga.bit files in the seperate application directories? Would the system just use them and work accordingly if they were to be replaced by a file that actually contains something (since right now, they all have size 0)?

My apologies for the large amount of questions but it is really helping a lot and your answers are certainly appreciated!

#115 by Nils Roos
Wed Jun 25, 2014 9:36 pm
Two things that you could try:
1. install kernel headers
Code: Select allsudo apt-get install linux-headers-$(uname -r)
you might need to also install the kernel headers of the 32bit variant (same reason you needed the gcc-multilib, but try without first)
2. make clean your RedPitaya directory, or better yet start with a fresh checkout

The INSTALL file uses the settings from ISE 14.6 - maybe this is the problem. I use the following script-snippet to do a full build:
Code: Select allcd RedPitaya/
source /opt/Xilinx/Vivado/2013.3/settings64.sh
export CROSS_COMPILE=arm-xilinx-eabi-
export PATH="$PATH:$PWD/OS/u-boot/u-boot-xlnx/tools"
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
make -C Applications
Perhaps this solves your make -C Applications issue.

Apparently, it is not yet possible to amend the PL configuration via the fpga.bit file (see this discussion), but this will probably be remedied in a future release.

Who is online

Users browsing this forum: No registered users and 3 guests