Hello everyone,
I'm experiencing a weird problem when trying to add my own boot.scr to the boot partition. My setup looks like the following: imx8mnddr4evk EvalBoard, SD Card as flash memory
WKS File:
part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk1 --no-table --align 32
part /boot --source bootimg-partition --ondisk mmcblk1 --fstype=vfat --label boot --active --align 4096 --size 64
part /rootA --source rootfs --ondisk mmcblk1 --fstype=ext4 --label ROOTA --align 4096
part /rootB --source rootfs --ondisk mmcblk1 --fstype=ext4 --label ROOTB --align 4096
bootloader --ptable msdos
So I'm planning a symmetric rootfs on the SD card. I placed the devicetree inside the /rootfs/boot/. I also installed rauc and added my boot.scr to the boot partition. It looks like the following (sorry, the indentation is messed up):
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "ROOTA ROOTB"
test -n "${BOOT_ROOTA_LEFT}" || setenv BOOT_ROOTA_LEFT 3
test -n "${BOOT_ROOTB_LEFT}" || setenv BOOT_ROOTB_LEFT 3
setenv bootargs
setenv loaddevicetree "ext4load mmc 1:2 ${fdt_addr} /boot/imx8mn-ddr4-evk.dtb"
for BOOT_SLOT in "${BOOT_ORDER}"; do
if test "x${bootargs}" != "x"; then
# skip remaining slots
elif test "x${BOOT_SLOT}" = "xROOTA"; then
if test ${BOOT_ROOTA_LEFT} -gt 0; then
echo "Found valid slot A, ${BOOT_ROOTA_LEFT} attempts remaining"
setexpr BOOT_ROOTA_LEFT ${BOOT_ROOTA_LEFT} - 1
setenv load_kernel "ext4load mmc 1:2 ${loadaddr} /boot/Image"
setenv bootargs "${default_bootargs} root=/dev/mmcblk1p2 rauc.slot=ROOTA rootwait rw"
fi
elif test "x${BOOT_SLOT}" = "xROOTB"; then
if test ${BOOT_ROOTB_LEFT} -gt 0; then
echo "Found valid slot rootB, ${BOOT_ROOTB_LEFT} attempts remaining"
setexpr BOOT_ROOTB_LEFT ${BOOT_ROOTB_LEFT} - 1
setenv load_kernel "ext4load mmc 1:3 ${loadaddr} /boot/Image"
setenv bootargs "${default_bootargs} root=/dev/mmcblk1p3 rauc.slot=ROOTB rootwait rw"
fi
fi
done
if test -n "${bootargs}"; then
saveenv
else
echo "No valid slot found, resetting tries to 3"
setenv BOOT_ROOTA_LEFT 3
setenv BOOT_ROOTB_LEFT 3
saveenv
reset
fi
echo "Loading Device Tree"
run loaddevicetree
echo "Loading kernel"
run load_kernel
echo "Starting..."
booti ${loadaddr} - ${fdt_addr}
And finally the system.conf of rauc:
[system]
compatible=XYZ
bootloader=uboot
[slot.rootfs.0]
device=/dev/mmcblk1p2
type=ext4
bootname=ROOTA
[slot.rootfs.1]
device=/dev/mmcblk1p3
type=ext4
bootname=ROOTB
When I now flash the SD Card with the image created by wic, then uboot boots, it's executing the script, loads the kernel and the device tree and Linux is booting. However, when I now reset the system and let u-boot come up again, it tells me, that no filesystem could be found. And when analyzing the SD card with ubuntu, the partition FS type of the boot (!) partition is "unknown". I found out that when NOT adding my own boot.scr to the boot partition, it boots properly again and again. So how can my own boot.scr mess up the partition? FYI, I haven't set up the fw_env.config yet since I cannot find out the necessary info like device offset, env size and so on. But could that also lead to a destroyed first boot partition? What am I missing here?
Thank you VERY much in advance for your help, guys!
Hanky
"I had to build the environment with the mkenvimage tool and then let the fw_env.config know where to find that file inside the vfat boot partition." How exactly is this done?
Solved. The fw_env.config is very critical. It needs to be set up correctly or it simply writes at the wrong place screwing up your partition(s). That's one point. The other point is that the BSP imx-yocto-bsp does NOT provide any U-Boot environment build script or recipe in order to access the environment of U-Boot from the linux user space. I had to build the environment with the mkenvimage tool and then let the fw_env.config know where to find that file inside the vfat boot partition. Then it worked.