Jump to content
  • 0

Help loading fpag bitstream from uboot


m3atwad

Question

Hello,

I have a basic zedboard design using the following steps.

1. Create vivado project for zedboard using the zedboard template (accessed by double clicking on zynq block in BD -> templates -> zed board.

2. I added a gpio for the LEDs

3. Validate design and build with no problems.

4. Export .bit and .xsa file to petalinux project.

5. Create petalinux project based on #4 vivado files.

6. Build petalinux project.

I am trying to use tftp boot.  I can verify the tftp server is working because I see uboot open image.ub, the kernel load and attempt to boot.  My boot process hangs as shown in attached screenshot 22.jpg.

I actually think my problem is that I'm not loading the FPGA bitstream and because there is an axi lite gpio block it is causing the boot process to hang.  I know when I build images for the sd card I manually run a command that packages the fpga.bit file into the BOOT.bin.  This is a very simple 'hello world' test project so I think I'm missing something obvious like this.  

I am using xsct command console to load the ps7_init.tcl, dow u-boot.elf and then I execute the 'run netboot' command.  This downloads image.ub and extracts it but I think the fpga bitstream is left out.  I can see the tftp / image.ub process working as shown in screenshot 23.jpg.

So I'm thinking after I get to the uboot prompt I need to load the fpga bitstream so my question is the following.

1. How do I load the fpga bitstream - what command is it?  I've found fpga loadb, but am confused as to how to use it.

2. How do I know where to put the fpga bitstream?

3. How do I read it from the tftp server I have?

 

 

 

22.jpg

23.jpg

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

fdn=z7020

serverip=0.1.2.3

bit_addr=0x10000000
img_addr=0x11400000

bit_name=system.bit
img_name=image.ub

tftp_fpga=tftpboot $bit_addr $bit_name && fpga loadb $fdn $bit_addr $filesize;
tftp_boot=tftpboot $img_addr $img_name && bootm $img_addr;
defaul_bootcmd=dhcp && env run tftp_fpga && env run tftp_boot;

A uEnv.txt example.

It looks that you already managed to run tftp_boot part

Link to comment
Share on other sites

Hi Lonel,

Thanks for the reply.  Where can I find the location of uEnv.txt?  Can I view and verify this from uboot?

 

The only commands I run from uboot are 'run netboot'.  Where is tftp_boot supposed to be run from?

Link to comment
Share on other sites

Hi lonel,

Thanks for the help!  I have found my uEnv.txt as shown in the screenshot in case anyone else is looking for the location in a petalinux project.  See attached screenshot.

lonel - I have environment variables defined in platform-top.h and in uEnv.txt and some are the same.  Should I get rid of uEnv.txt and just use platform-top.h (attached) or should I switch to just using uEnv.txt?  It seems like you could use either and I am getting confused with both of these two things being applied.

 

One last thing - How did you choose the fpga bitstream address of 0x10000000?  How does uboot know to get the image from that address and where does it send the bitstream data - what interface gets that bitstream into the PL section?

25.jpg

platform-top.zip

Link to comment
Share on other sites

@m3atwad I have gave you the content of the uEnv.txt file you should have created and placed on sd card(I am assuming you boot from the SD card).

12 hours ago, m3atwad said:

Should I get rid of uEnv.txt and just use platform-top.h (attached)

With uEnv.txt you can obtain a custom boot behavior without recompiling u-boot.

platform-top.h is compiled into u-boot itself while uEnv.txt is imported at runtime if found on sd card. The following extract from platform.h is responsible with importing the uEnv.txt from sd card:

        "bootenv=uEnv.txt\0" \
        "importbootenv=echo \"Importing environment from SD ...\"; " \
                "env import -t ${loadbootenv_addr} $filesize\0" \
        "loadbootenv=load mmc $sdbootdev:$partid ${loadbootenv_addr} ${bootenv}\0" \
        "sd_uEnvtxt_existence_test=test -e mmc $sdbootdev:$partid /uEnv.txt\0" \
        "uenvboot=" \
                "if run sd_uEnvtxt_existence_test; then " \
                        "run loadbootenv; " \
                        "echo Loaded environment from ${bootenv}; " \
                        "run importbootenv; " \
                        "fi; " \
                "if test -n $uenvcmd; then " \
                        "echo Running uenvcmd ...; " \
                        "run uenvcmd; " \
                "fi\0" \

So your uEnv.txt file on SD card will be:

fdn=z7020

serverip=0.1.2.3

bit_addr=0x10000000
img_addr=0x11400000

bit_name=system.bit
img_name=image.ub

tftp_fpga=tftpboot $bit_addr $bit_name && fpga loadb $fdn $bit_addr $filesize;
tftp_boot=tftpboot $img_addr $img_name && bootm $img_addr;
uenvcmd=dhcp && env run tftp_fpga && env run tftp_boot;

Note you have to change serverip variable to match you tftp server IP address

 

12 hours ago, m3atwad said:

One last thing - How did you choose the fpga bitstream address of 0x10000000?  How does uboot know to get the image from that address and where does it send the bitstream data - what interface gets that bitstream into the PL section?

Line:

tftp_fpga=tftpboot $bit_addr $bit_name && fpga loadb $fdn $bit_addr $filesize;

tftpboot command will get the .bit file $bit_name  form your tftp server into RAM at address $bit_addr then if success (&&) command fpga loadb will get the 'file' from RAM and load it into fpga.

I have shifted image.ub address == ${netstart} to make space for the bitstream. :) The u-boot will move itself once it is started so will the kernel

Link to comment
Share on other sites

Hi lonel,

Thanks so much for the help!  That makes senese!

Do you know how to modify uEnv.txt in petalinux?  Since I'm using tftp boot I'd like to clean up my uEnv.txt as you've described.  I think the correct way to do this is to have petalinux produce an accurate uEnv.txt file with all my build images.  I see that petalinux does in fact produce a uEnv.txt after the build.  Do you know how to apply modifications to uEnv.txt via petalinux so that the petalinux build produces a correct one for my application along with the output products? 

Link to comment
Share on other sites

Ok - so would I add a new recipe to overwrite this?  I've found the file in build/tmp/deploy/images/zedboard-zynq7/uEnv.txt.

Also - can the tftpboot command pull down the uEnv.txt file from my tftp server even though it isn't an image like image.ub, uImage etc...?

Link to comment
Share on other sites

I load FSBL (I think) via jtag using ps7_init.tcl  My process is below:

1. Connect via jtag using xsct

2. Load ps7_init.tcl and run ps7_init

3. dow u-boot.elf

4. execute 'con' command

5 switch over to console and interact with u-boot.

6. Launch kernel boot process via tftpboot calls

I'm trying to avoid the sd card while i'm developing the images and learning/researching and testing stuff with petalinux.  The jtag approach seems more streamlined because I can do it all via ethernet from my build machine using tftp.  

I have also finally gotten the zynq to boot into linux following your advice!  My problem was a missing PL bitstream that caused the boot process to hang.  I am thinking that the gpio IP core in PL that has an axi interface wasn't there causing the bootprocess to hang.  

 

Link to comment
Share on other sites

Most of the problems you face could have been avoided if you booted from sd card and place the uEnv.txt alongside BOOT.bin and image.ub.

For debugging Linux kernel JTAG can actually create errors since is multithreading & multicore system.

To pack bitstream in BOOT.BIN use petalinux-package --boot --u-boot --fpga images/linux/{filename}.bit --force

--force is for overwriting BOOT.BIN file if exists.

Do you understand the paradox of uEnv.txt in your context? "Run instructions in uEnv.txt before you obtain the uEnv.txt"
In this case you may want to change platform-top.h to do everything inside uEnv.txt. and you won't need the uEnv.txt but you will have to recompile u-boot on any changes in u-boot environment. You end up doing more work just to start the system over JTAG. If your target is to develop fsbl or u-boot that is what you will do. But since you need the tftp to boot the system from network your bootflow adds manual labour for every boot.

A normal workflow will be:

1. Do changes in vivado

2. Generate hdf that includes the bitstream

3.  Import it in petalinux (petalinux-config --get-hw-description=/path/to/hdf/directory)

4. Do changes to device tree, rootfs or any other petalinux components  if necessary.

5. Build and generate BOOT.BIN

6. Copy BOOT.BIN and image.ub on sd card (uEnv.txt in this case to boot image.ub from tftp thus image.ub on sd card is no longer needed)

7. Power on the board.

If you change one of: fsbl, device tree or u-boot you need to regenerate the BOOT.BIN and copy it to SD card for the canges to take efect on next boot.

Link to comment
Share on other sites

12 hours ago, m3atwad said:

The jtag approach seems more streamlined because I can do it all via ethernet from my build machine using tftp.

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_1/ug1144-petalinux-tools-reference-guide.pdf

Quote

TFTP boot saves a lot of time because it is much faster than booting through JTAG and you donot have to flash the image for every change in kernel source.

Link to comment
Share on other sites

Hi lonel,

Thanks so much - this has been a huge help and I now have my zynq up and running!

I'm going to play around with different boot options for a little while as well and test some of your recommendations out!

Thanks again!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...