cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
815 Views
Registered: ‎02-19-2018

Using PetaLinux for NFS and TFTP boot

Jump to solution

Hello,

I am using PetaLinux 2020.1. In petalinux-config, I've enabled the NFS root filesystem and have set up my TFTP server and DHCP server on the host. I've loaded the BOOT.BIN file onto my SD card, and when the device boots into U-Boot it seems that the settings I've selected in petalinux-config are not being respected. In particular, I've specified in petalinux-config that I want to use the image.ub file as the name for bootable kernel image under Image Packaging Configuration; however, U-Boot still loads rootfs.cpio.gz.u-bootImage, and system.dtover TFTP and uses the rootfs.cpio.gz.u-boot as the root FS, instead of loading image.ub and using NFS as the root fs.

Do I need to configure U-Boot separately, and is there a reason that even when specifying these parameters in petalinux-config that U-Boot is not also configured appropriately? If so, what changes do I need to make?

 

EDIT: Perhaps a simpler way to say this is: following the UG1144 (PetaLinux Reference) steps to boot from using NFS and TFTP is insufficient and/or incomplete. I followed those steps precisely but the kernel is not using NFS. It looks like U-Boot needs to specially configured, but UG1144 doesn't contain any information on that.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Explorer
Explorer
317 Views
Registered: ‎02-19-2018

Thanks @aravindb.

 

I opened a service request for this and was able to get some answers from the engineer who helped me there. She told me that Xilinx will be updating the PetaLinux documentation in future iterations to address some of these open questions.

View solution in original post

8 Replies
Highlighted
Explorer
Explorer
807 Views
Registered: ‎02-19-2018

I see that there are some new files in the meta-user/recipes-bsp/u-boot directory that contain a recipe to create a U-Boot .scr file. Is it correct that the supported flow is now to modify this file in order to configure how we want U-Boot to boot the OS?

If so, I have some questions about this. The first line of the .scr file is for boot_target in ${boot_targets}. Where is ${boot_targets} defined? Further, the script checks for different boot targets such as a jtag, mmc, qspi, and nand, but it is noticeably missing any kind of tftp or network option. Is there documentation available somewhere that specifies how to modify this file to support tftp boot?

0 Kudos
Highlighted
Moderator
Moderator
747 Views
Registered: ‎09-12-2007

Can you try tftpb image.ub. You may need to update the uboot header files to take the actual image you want

0 Kudos
Highlighted
Explorer
Explorer
706 Views
Registered: ‎02-19-2018

@stephenm wrote:

You may need to update the uboot header files to take the actual image you want


Can you point me to any documentation that explains how to do this?

I'm able to boot the image.ub file via TFTP and boot from memory using:

> dhcp image.ub
> bootm

I would like to modify my PetaLinux meta-user layer to make this the default. How do I do that?

0 Kudos
Highlighted
Explorer
Explorer
676 Views
Registered: ‎02-19-2018

I can also no longer use saveenv in U-Boot:

ZynqMP> saveenv
Unknown command 'saveenv' - try 'help'

So trying to update the default bootcmd doesn't persist between boots.

Also missing is the update_boot command.

It seems like Xilinx made quite a few changes to how U-Boot works with PetaLinux in 2020.1.

0 Kudos
Highlighted
Explorer
Explorer
656 Views
Registered: ‎02-19-2018

So I've found a few things:

It looks like the netboot command was removed in this commit: https://github.com/Xilinx/u-boot-xlnx/commit/5c16c2bdb48e8a2cbec0459165d97cbd299571b2

I don't know when, why, or how saveenv was removed though

The explanation in that commit is that users should switch to using the distro_bootcmd, which iterates through all of the storage devices (SD card, flash, etc.) looking for a boot.scr.uimg file and will use that to boot the device.

I've also discovered that the reason U-Boot was booting an init RD and the Image file (instead of just booting image.ub) was because it was using the pxe boot target in the distro_bootcmd command. The pxe boot target loads the file pxelinux.cfg/default from the host's TFTP boot directory. I did not create this file, PetaLinux did, and its contents are

LABEL Linux
KERNEL Image
FDT system.dtb
INITRD rootfs.cpio.gz.u-boot

This begs my original question: why is this file being written to the TFTP dir with these contents, since I've set the image name to be image.ub in petalinux-config and I've also enabled NFS root fs, not init RD. This seems like a bug.

Finally, I modified the file project-spec/meta-user/recipes-bsp/u-boot/u-boot-zynq-scr/boot.cmd.default.initrd to have the following contents:

@@PRE_BOOTENV@@

tftpboot @@FIT_IMAGE_LOAD_ADDRESS@@ @@FIT_IMAGE@@;
bootm @@FIT_IMAGE_LOAD_ADDRESS@@;
exit;

This creates the file boot.scr in the TFTP boot directory. This still doesn't work though, since U-Boot by default looks for a script file called boot.scr.uimg. If I 1) delete the pxelinux.cfg directory and 2) rename boot.scr to boot.scr.uimg (with the modification mentioned above), then VOILA! I get working TFTP boot!

This leads to a few more questions:

1. Why does PetaLinux create boot.scr instead of boot.scr.uimg (meaning users have to manually rename the file)?

2. Why does the default contents of boot.cmd.default.initrd not contain anything that supports tftpboot? By default, it only contains commands for jtag, mmc, spi, or NAND flash. Why does TFTP boot get the shaft?

3. Also, why the .initrd file extension? Looking at the u-boot-zynq-scr.bbappend recipe file, it looks like it only looks at the file with the .initrd extension and it's not clear to me why.

4. Is this the "proper" expected way to configure netboot now as of PetaLinux 2020.1? None of anything I wrote above is mentioned in either the user guides or the Xilinx Wiki as far as I can tell, I just dug through the source code long enough to figure this out. I would love for a Xilinx employee to chime in and let me know what the official supported path is for network booting.

0 Kudos
Highlighted
Contributor
Contributor
451 Views
Registered: ‎05-30-2018

I'm replying to this thread with some recent issues that I ran into as well with customizing U-boot 2020.1 in Petalinux 2020.1. I was eventually able to get saveenv to work which was originally missing by default.

It seems that the key to integrating any changes in Petalinux 2020.1 is to first use petalinux-config -c <component> first then performing a build as follows:

petalinux-build -c u-boot -x finish

If you directly try to hand-modify the .cfg files for a component I've noticed that most of the time it will not recognize or ignore the changes. It seems for most components (ie: U-boot, Linux kernel), doing a petalinux-config -c will write a .config file to a temporary .config file in /build/tmp rather than in your Petalinux workspace. Using the petalinux-build -c <component> -x finish  command will rectify this by copying over a "devtool-fragment.cfg" to the workspace directories that you're working in. I was initially not able to get saveenv to work because of this. After some tweaking and using the -x finish command I was finally able to get a build that included saveenv. Here was what my U-boot config file looks like:

project-spec/meta-user/recipes-bsp/u-bootfiles/devtool-fragment.cfg

# CONFIG_SPL_BOOTCOUNT_LIMIT is not set
CONFIG_SPL_ENV_SUPPORT=y
CONFIG_SPL_SAVEENV=y
# CONFIG_SPL_ETH_SUPPORT is not set
# CONFIG_ENV_IS_NOWHERE is not set
CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_FAT_INTERFACE="mmc"
CONFIG_ENV_FAT_DEVICE_AND_PART="0:auto"
CONFIG_ENV_FAT_FILE="uboot.env"
# CONFIG_SPL_ENV_IS_NOWHERE is not set
CONFIG_SPL_ENV_IS_IN_FAT=y

To save yourself with time with trying to boot up the board, you can confirm if the saveenv utility is included in your build by doing a grep inside your /images/linux/ folder:

% grep -r saveenv
Binary file u-boot.bin matches
Binary file BOOT.BIN matches
Binary file u-boot.elf matches

If it does not show up, it means it was not included in the build. 

Hope this helps.

0 Kudos
Highlighted
Moderator
Moderator
396 Views
Registered: ‎02-07-2018

HI @greande 

In current u-boot default configuration CONFIG_ENV_IS_NOWHERE is selected by default. Please unselect CONFIG_ENV_IS_NOWHERE and select preferred env storage device to save env variables.

 

Thanks & regards

Aravind

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
---------------------------------------------------------------------------------------------

Highlighted
Explorer
Explorer
318 Views
Registered: ‎02-19-2018

Thanks @aravindb.

 

I opened a service request for this and was able to get some answers from the engineer who helped me there. She told me that Xilinx will be updating the PetaLinux documentation in future iterations to address some of these open questions.

View solution in original post