Raspberry pi 64 bit can destroy itself through apt upgrade

Hi,

Problem on 64-bit raspberry pi

did you know that for 64-bit raspberry pi, you “abusively” copy uboot into /boot/firmware/kernel8.img

thereby overwriting the official location of the actual Rpi kernel in the boot-partition.

(done here: link)

If you now do

sudo apt update
sudo apt upgrade

it can happen that
/boot/firmware/kernel8.img (which is uboot, not the kernel), is overwritten with an actual kernel (an update) via this mechanism, and then (re)booting fails with

${mender_kernel_root}: Can'l lookup blockdev
mount: mounting ${mender_kernel_root} on /root/failed: No such file or directory
Failed to mount ${mender_kernel_root} as root file system.

Did not happen on 32 bit raspberry pi (pre-bookworm)

On 32 bit raspberry pi (pre-bookworm, e.g. bullseye), this could not happen, because there you created /uboot, which it not part of the standard filesystem of raspberry pi. There we find a symlink:

/boot/kernel7l.img -> /uboot/kernel7l.img

(done here: link)

And then… if apt upgrade delivers a new kernel, it will simply overwrite the symlink /boot/kernel7l.img; but uboot will remain in /uboot/kernel7l.img and it will still boot fine.

Possible fix for 64 bit

A fix for 64 bit is e.g. to make sure that uboot lands up in e.g. /boot/firmware/u-boot.bin and not /boot/firmware/kernel8.img and set boot/firmware/config.txt to have the line kernel=u-boot.bin

(By the way on RPi 5, you load kernel8.img. It would be better to use kernel_2712.img. There’s a pull-request for that on the mender-convert repo)