UC20 and uboot.env

I prepared a SD card with raspberry-pi-core 20 image, I could see boot.scr in boot-seed partition and no boot-assets present. I understand that I need to prepare boot-assets with boot.scr and other required files and instruct build sequence place into boot-seed.

Core 20 gadget preparation expects the boot.scr in boot-seed partition in boot media. Is that correct?

At image creation time the boot-assets are copied to / of the volume (i.e. ubuntu-seed in this case):

there is indeed no requirement that the dir is called “boot-assets” or that there is even a dir, as long as this is reflected in the gadget.yaml which defines what bits of your gadget go where in the image in the end …

Yes, this is correct but i think ubuntu-image still expects a uboot.conf somewhere in the gadget as well (this used to be a symlink to uboot.env in the old design and as i understand needs to be an empty file in the new setup when boot.scr is used):

1 Like

Hi,
boot script feature is up and running on custom boot loader.
I looked into bootscr.rpi file in pi-gadget source understand more about the UC20 specific boot arguments part.

I understand in UC18, We instructed boot loader to pick root= and eventually passing to snappy_boot with /dev/disk/by-label/writable ${snappy_cmdline} instructions. But UC20, I could not find such instructions.

How does it manage for UC20?

my UC20 gadget picks kernel and boots.Then stopping at init as below

[    2.987953] rtc-ds1307 2-0068: setting system clock to 2000-01-01T00:18:52 UTC (946685932)
[    2.990641] mmc1: new high speed SDHC card at address 59b4
[    3.002631] mmcblk1: mmc1:59b4 SMI   15.0 GiB
[    3.010149]  mmcblk1: p1
[    3.348519] imx6q-pcie 33800000.pcie: Phy link never came up
[    3.354224] imx6q-pcie 33800000.pcie: failed to initialize host
[    3.360160] imx6q-pcie 33800000.pcie: unable to add pcie port.
[    3.366891] Freeing unused kernel memory: 512K
[    3.380038] Run /init as init process
Loading, please wait...
starting version 229
[    3.426101] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[    3.429835] random: udevadm: uninitialized urandom read (16 bytes read)
[    3.433629] random: systemd-udevd: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/nfs-top ... done.
Begin: Running /scripts/nfs-premount ... done.
Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... [    5.158693] random: crng init done

I am using microSD card for booting, I could see mmc is getting detected as mmcblk1. We can see in above log as well.
Do I need to add any additional boot arguments to complete UC20 boot?

this uses an UC16/18 initrd, something went wrong with your kernel snap … the scripts/ stuff is gone in UC20 …

for a proper UC20 kernel you need to use this custom kernel plugin:

and make sure to have base: core20 in your kernels snapcraft.yaml …

Yes, I am using base: core20 in my kernel snapcraft. I did multiple time fresh kernel snap build and tried on device.But seeing same status.

Regarding suggested https://github.com/kubiko/snapcraft-kernel-plugin , Do I need to add kernel.py into my current kernel’s snap/plugins path and generate snap again?

Sorry I am not clear. :pensive:

Yes, exactly …

Hi,

I included kernel.py intp snap/plugins path ( plugins was not there, I created manually) and regenerated the kernel snap.

But the UC boot is not getting completed. Getting stopped at mounting phase(as same as in previous comments ).

[    3.340102] Run /init as init process
Loading, please wait...
starting version 229
[    3.385695] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[    3.388784] random: udevadm: uninitialized urandom read (16 bytes read)
[    3.393369] random: systemd-udevd: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/nfs-top ... done.
Begin: Running /scripts/nfs-premount ... done.
Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... [    4.979081] random: crng init done
findfs: unable to resolve 'LABEL=writable'
done.
the requried kernel commandline snap_core is not set
Rebooting automatically due to panic= boot argument

How can I check kernel.py getting used during kernel snap build?

this uses an UC16/18 initrd, something went wrong with your kernel snap … the scripts/ stuff is gone in UC20 …
How did you concluded possibility of something wrong with initrd+kernel snap build? Is that reflecting in my boot log?
Do I need to include initrd.py as well into kernel snap plugins?

and make sure to have base: core20 in your kernels snapcraft.yaml …
base: core20 is present in kernel and gadget snapcraft.yaml file and also present in .model file which is passed to ubuntu-image command for generating UC20 image.

Is there any debugging option to understand the issue more.

this would be a question to @ondra

the old “initramfs-tools” scripts are being spawned from a script called /init that prints Run /init as init process and they are run from /scrips in the initrd … the core20 initrd’s actually ship a cut down systemd as init and the scripts have been replaced by actual systemd units, so the log looks quite different when booting the proper UC20 initrd …

Is there any debugging option which I can make use to understand the issue in detail?
Which build is shipping initrd ? Kernel snap or ubuntu-command build?

Can you give me UC20 model assertion file reference for pi-gadget link which you have shared. I will check if anything missing in my model file. I am using gadget and kernel snap from local path and grade is dangerous.

I am using Ubuntu 18.04 host PC to build UC20, Is that can cause such issues?

After switching to Ubuntu 20.04 host PC for generating UC20 images, I am getting below log

[    2.840446] mmc1: host does not support reading read-only switch, assuming write-enable
[    2.858311] mmc1: new high speed SDHC card at address 59b4
[    2.866664] mmcblk1: mmc1:59b4 SMI   15.0 GiB
[    2.873225] rtc-ds1307 2-0068: setting system clock to 2000-01-01T00:07:27 UTC (946685247)
[    2.875388]  mmcblk1: p1
[    3.320876] imx6q-pcie 33800000.pcie: Phy link never came up
[    3.328943] imx6q-pcie 33800000.pcie: failed to initialize host
[    3.337291] imx6q-pcie 33800000.pcie: unable to add pcie port.
[    3.345590] Freeing unused kernel memory: 512K
[    3.360223] Run /init as init process
Loading, please wait...
starting version 229
[    3.406155] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[    3.408959] random: udevadm: uninitialized urandom read (16 bytes read)
[    3.415807] random: systemd-udevd: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/nfs-top ... done.
Begin: Running /scripts/nfs-premount ... done.
Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... [    4.879963] random: crng init done
[    4.885723] random: 7 urandom warning(s) missed due to ratelimiting

discussed initramfs-tools related issues got solved , currently I am getting /scrips instead of /init in above log. But, boot is not going further from this point.

the image generation does not matter at all, since only binary snaps are used … what matters and is essential is that your kernel snap uses the correct initrd. the mentioning of /scripts in the log shows you are still on an 16/18 initrd here … and that can not boot a UC20 file-system (as you found, it hangs) … it looks like the kernel.py plugin does not seem to be used at kernel build time (note that you might also need the initrd.py file next to it in the plugins/ dir, even though the README does not explicitly state it)

I have added initrd.py and tried but i am getting same status.I am bit confused.
Can you share me UC20 kernel snap link for Raspberry Pi. I will try to understand more from reference.

that will not help you much since the official kernels are just re-packed from the deb binaries, they are not actually built from source … i fear only @ondra can help us here …

Okay… Is there any another debugging options to understand the problem?

i guess you could use the --debug option with snapcraft to get more details, perhaps that shows why it is not using the plugin correctly …

i just dug around a little, and found i have actually built a kernel using that plugin a while back: https://github.com/ogra1/rockpi-n10-kernel

but i really only copied the two py files into the snap/plugins dir … it might be that you need to experiment with the build-base: setting in snapcraft.yaml …

Thank you I will look into this example.
is lxc shell environment mandatory for building kernel snap?

not at all, important is though that you are using a release on the host that matches your base: entry (i.e. core->16.04, core18->18.04, core20 -> 20.04)

Okay…i will try on lxc shell environment.

it might be that you need to experiment with the build-base: setting in snapcraft.yaml …

I made build-base: core20,

root@ubuntuone:~/rockpi-n10-kernel# snapcraft --destructive-mode --target-arch=arm64
Setting target machine to 'arm64'
*EXPERIMENTAL* '--target-arch' configured, but not enabled. Enable with '--enable-experimental-target-arch' flag.
root@ubuntuone:~/rockpi-n10-kernel# snapcraft --destructive-mode --target-arch=arm64 --enable-experimental-target-arch
*EXPERIMENTAL* --target-arch for core20 enabled.
Setting target machine to 'arm64'
Loaded local plugin for kernel
The plugin used by part 'kernel' does not support snaps using base 'core20'.
root@ubuntuone:~/rockpi-n10-kernel# vim snap/snapcraft.yaml 

Looks like I need understand more on UC20 snap preparations

try dropping base: core20 the build-base: entry should be enough …