UC20 and uboot.env

gadget snap is not taking boot-arguments from uboot.env. I am trying for UC20.

@ogra, Below statements are from one of our discussion
with UC20 everything changed (specifically uboot.env is gone and has been replaced) and i do not know where/if there is any documentation of what bits and pieces are needed yet …

What are the uboot modification and uboot.env configurations required for UC20?

it uses boor.sel and boot.scr now, take a look at the pi gadgets (specifically at the Makefile, since all snapcraft.yaml integration from before has been reverted to be a Makefile hack) that i linked to in our other thread …

for more details perhaps @waveform and @sil2100 can probably help (they took over the gadget maintenance with UC20)

@waveform and @sil2100,

Could you please give uboot level reference for gadget snap preparation for UC20.

1 Like

Hi, Is there any reference for UC20 gadget preparation?

I understand UC20 expects boot.sel and boot.scr with gadget snap.
For custom hardware UC18 gadget, I have added CONFIG_ENV_FAT_FILE=“uboot.env” which may not required for UC20.

Do I need to make any patch on my boot loader source code for UC20 specific?

i have not done a lot of porting to UC20 yet, but yes, it can use boot.scr and boot.sel … your log shows it uses uboot.env currently though, so you should either make that one work. or re-work your gadget to use boot.sel and boot.scr like

https://github.com/snapcore/pi-gadget does (see the Makefile, sadly the UC20 gadget is a bit messy and moved away from using snapcraft.yaml proper here)

I am doing UC18 and UC20 gadget porting/preparation.

probably mentioned log is from UC18 boot sequence and I am checking few issues during first UC boot.

I thought of using same uboot source code for UC20 except "CONFIG_ENV_FAT_FILE and CONFIG_ENV_IS_IN_FAT configurations.Since UC20 expects bootscripts.

yeah, that should work …

Do we have ARM/ARM64 based UC20 gadget reference link other than pi-gadget? I am bit confused with uboot binary placement with pi-gadget.

not yet, and sadly the required changes were not really documented either (i fear you have to read the code … unlike gadgets before all the logic sadly went into a Makefile now) … i plan to do a beaglebone gadget for UC20 that could serve as reference for other plain u-boot boards but lately my spare time got a bit more rare so i’m not able to give any ETA …

Okay, I am doing UC20 gadget preparation for i.MX8 (ARM64 ) platform. I will try to contribute what I can do.

Thank you.

When we get "error: cannot find boot config " message with ubuntu-image command?

Copying "variscite-imx8mmini-kernel_5.4.85_arm64.snap" (variscite-imx8mmini-kernel)
Copying "var-som-mxm8mini_20-1_arm64.snap" (var-som-mxm8mini)
error: cannot find boot config in "/tmp/tmpkdrap8yu/unpack/gadget"
ERROR:ubuntu-image:COMMAND FAILED: snap prepare-image --channel=stable --snap=var-som-mxm8mini_20-1_arm64.snap --snap=variscite-imx8mmini-kernel_5.4.85_arm64.snap var-som-mxm8mmini.model /tmp/tmpkdrap8yu/unpack
ERROR:ubuntu-image:Full debug traceback follows
Traceback (most recent call last):
  File "/snap/ubuntu-image/220/lib/python3/site-packages/ubuntu_image/assertion_builder.py", line 29, in prepare_image
  File "/snap/ubuntu-image/220/lib/python3/site-packages/ubuntu_image/helpers.py", line 159, in snap
    run(cmd, stdout=None, stderr=None, env=os.environ)
  File "/snap/ubuntu-image/220/lib/python3/site-packages/ubuntu_image/helpers.py", line 124, in run
  File "/snap/ubuntu-image/220/usr/lib/python3.5/subprocess.py", line 659, in check_returncode
subprocess.CalledProcessError: Command '['snap', 'prepare-image', '--channel=stable', '--snap=var-som-mxm8mini_20-1_arm64.snap', '--snap=variscite-imx8mmini-kernel_5.4.85_arm64.snap', 'var-som-mxm8mmini.model', '/tmp/tmpkdrap8yu/unpack']' returned non-zero exit status 1

there is a --debug option for ubuntu-image i think … that should get more info … my guess is that the uboot.conf link is missing in your gadget (but i dont know where it needs to point to in UC20, if that is boot.scr or boot.sel)

For UC20, the boot.scr script has effectively replaced the uboot.env file, and if you try to add a uboot.env file, you will end up breaking boot for UC20 since then u-boot completely ignores the boot.scr file when there is a uboot.env (unless you specifically patch uboot itself or otherwise load boot.scr from the uboot.env).

Basically, you need to have a boot.scr file, you can’t have a uboot.env file at the moment. You can compile all the logic into uboot itself and not have a uboot.env file at all, and then just have an empty boot.scr file or something like that, but we currently use the boot.scr file to identify the uboot bootloader for UC20.

If there is no uboot.env , Does uboot go for uboot.scr if there is uboot,env .

I am checking in source code to understand the uboot.scr loading sequence to instruct bootloader to pick up and load uboot.scr.

Do we need to instruct uboot to load uboot.scr from ubuntu-seed partition using boot arguments?

Note that the filename is boot.scr, I’m not sure which version of uboot added support for this or if it’s an Ubuntu specific thing or not unfortunately

Sorry, That was typo. Yes the file is boot.scr.
I am using U-Boot 2020.04 which was ported for Non ubuntu custom hardware.

the “support” for it is there since a decade or so … the problem is that loading boot.scr is an absolute per-device thing and if your device usually does not use boot.scr you have to figure out a way to change your u-boot default env to make it load that file … (which is one of the (many !) reasons that we originally decided to pick uboot.env in the first place, because it just works with all existing setups once you have the build config in place)

Yes, my device is not using boot.scr. As you suggested , I need to instruct bootloader to load boot.scr from boot media partition and run boot script. I think that might be sufficient for UC20.

Do I need to load the file from boot-assets or boot-seed?

you should ship it in boot-assets … and there is a symlink that gets checked during install called “uboot.conf” that needs to point to it (i think that latter one lives in / of the gadget, check the existing gadgets) …