Search code examples
partitioningyoctou-bootnvidia-jetson

Loading custom u-boot script


I've created an image (with Yocto and meta-tegra) and got a Jetson Nano devkit running with two rootfs that RAUC updating uses. I am currently (temporarily during testing) using the Jetson Nano devkit SPI flash to store the u-boot environment.

I have a script that I successfully got running on my device with tftp. I've also manually typed in every line of my script to an environment variable, saved it and set bootcmd to run it. But if i want more than one device with this u-boot, i wouldn't want to manually type in the script for every device i make. But I also don't want a tftp server to be running at the side to be able to boot.

I want to run my script completely independent and automatically. So I've been thinking about having the script on a partition on it's own and get u-boot to load the script from there. But how do i tell u-boot to look for at script in the specific partition? Can i use source SCRIPT_PARTITION_OFFSET?

I've also seen that the standard boot.scr can be run from the u-boot shell. Where is this boot.scr located? I can't seem to find where it is created or where it is stored.

*****************************************************EDIT:***************************************************** As a temporary solution I have put the boot script image into /boot/ folder and set the u-boot to scan for scripts in the that folder on both rootfs and then run it if it can find it.

For this solution i still have to edit the u-boot env to make u-boot boot this custom way, so it is not a solution i can use in the long run. I might as well make a script to run once via tftp that will set bootcmd to be the entire boot script content.

Can i edit the u-boot source code with a patch that has my script in it's environment? - if so, how?


Solution

  • As said in the comments, i was able to make a patch for u-boot-tegra/include/config_distro_bootcmd.h that has the variable distro_bootcmd set to my script content. When i then build my yocto image and boot up my Jetson Nano, i can see that the variable is in fact set.

    This way should work for any u-boot and not just for Jetson Nano. Just find the bootcmd variable in the u-boot that runs at default boot and patch it.