Using uEnv.txt or boot.scr for u-boot customization

We are wanting to add some additional functionality to u-boot so that we can do simple gpio input and output. I have been able to create a custom u-boot that has what we need, but I’m wondering if there’s a better way to do this? In other systems, you can create a uEnv.txt and/or boot.scr file that contains environment variables/scripts that are needed. Is there a way to do this through the Jetson flash system? and if so, how?

hello steamedcotton,

here’re approaches for GPIO configuration in u-boot.

  1. modify the pinmux in the DTB to the correct non-SFIO setting to allow the GPIO function
  2. interrupt u-boot, set the pinmux and gpio registers via ‘write 0xNNNNNNNN’ commands
  3. code implementation, for example, on Nano it would be board/nvidia/p3450-0000/p3450-0000.c. please add your GPIO init to ft_board_setup().

Hey @JerryChang,

I have the GPIO functionality working by modifying and building the uboot source code: when a button is held down during boot, a “recovery mode” is initiated.

I’m overriding the bootcmd with something like this:

if gpio input U5; then run companion_recovery_boot; else run companion_standard_boot; fi

and adding those other env variables/scripts elsewhere (ie companion_recovery_boot and companion_standard_boot).

This all works great, but I was hoping there was a better way to add/override the environment variables. I’ve seen in other systems the option to have a uEnv.txt file that uboot loads. Is that an option in the world of Jetson?

hello steamedcotton,

may I know which Jetpack release you’re working with?
env import should works if that’s not an old release version, please have a try to create an uEnv.txt under /boot .

you may have a try to create boot.scr for the usage, please put it under /, otherwise it’ll load /boot/extlinux.conf.
for example, you should creating a boot.txt with the following contents.

setenv fdt_copy_node_paths
setenv fdt_copy_prop_paths
setenv fdt_copy_src_addr
setenv fdt_del_prop_paths

and, executing the following command to create boot.scr, i.e. $ mkimage -A arm -T script -O linux -d boot.txt boot.scr
you should see below messages if the boot script works

Found U-Boot script /boot.scr

I am using L4T 32.7.2 which has JetPack 4.6.2.

Providing an uEnv.txt file under /boot doesn’t seem to have any effect on the boot process. I am able to get the boot.scr to load and execute (by following your instructions, thank you!). Unfortunately, boot.scr runs after the bootcmd has been executed. I think I might just have to stick with a modified uboot.

hello steamedcotton,

okay, are we able to close this thread if no further uboot customization related questions?

@JerryChang You can close this thread, thank you for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.