Closed synaption closed 2 years ago
The recovery image comes before the A and B rootfs partitions, so if you just comment out the recovery partition section in the genimage.cfg the A and B partition numbers will change. You will need to update the U-Boot script with the appropriate settings (eg: load_* and rauc_args environment variables) with the proper mmc device numbers and root= device for the Linux kernel.
Given your genimage configuration, I believe your uSD partitions should be:
1: boot 2: rootfs0 3: rootfs1 4: extended partition 5: upload 6: data
You'll need to adjust the U-Boot script to use mmc 0:2 or mmc 0:3 and set root= to /dev/mmcblk0p2 or /dev/mmcblk0p3
...but you should double-check exactly what the genimage utility is doing. I've had it do some unexpected things, so make sure everything is really getting written out the way you're expecting.
On 6/17/2022 3:59 PM, bob mcgrath wrote:
I thought that would be all I had to do as well, but now I am having no luck. Maybe you can spot the problem.
image data.ext4 { name = "Data" mountpoint = /data ext4 { use-mke2fs = true label = "Data" features = "^64bit" } size = 20000M } image upload.ext4 { name = "Upload" empty = true ext4 { use-mke2fs = true label = "Upload" features = "^64bit" } size = 3000M } image sdcard.img { hdimage { partition-table-type = mbr extended-partition = 4 } partition ubootenv0 { image = "uboot-env.bin" in-partition-table = false offset = 1M } partition ubootenv1 { image = "uboot-env.bin" in-partition-table = false offset = 2M } partition boot0 { partition-type = 0xC bootable = true image = "boot.vfat" # Leave room for U-Boot environment offset = 4M } partition boot1 { image = "boot.vfat" in-partition-table = false # 256M + 4M offset = 260M } # partition rescue { # partition-type = 0x83 # image = "rootfs.squashfs" # size = 256M # } partition rootfs0 { partition-type = 0x83 image = "rootfs.ext4" size = 3000M } partition rootfs1 { partition-type = 0x83 image = "rootfs.ext4" size = 3000M } partition upload { partition-type = 0x83 image = "upload.ext4" size = 3000M } partition data { partition-type = 0x83 image = "data.ext4" size = 20000M } }
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B" test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3 test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3 test -n "${bootargs_default}" || setenv bootargs_default coherent_pool=1M vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 rootwait test -n "${DTB_FILE}" || setenv DTB_FILE bcm2711-rpi-cm4.dtb # RPi firmware uses a dynamic fdt_addr, but U-Boot does not use the fw # provided address if fdt_addr is already defined in the environment! # Copy fdt_addr to a local variable and delete the environment variable # so it never gets accidentally saved: fdt_addr=${fdt_addr} env delete fdt_addr # To boot from the rescue partition, tie GPIO4 (pin 7) to GND (pin 9) # The gpio input command will return an exit status of 0 (true) # If the pin is high (pulled up by default) the exit status is 1 (false) # if gpio input gpio4 ; then # # GPIO4 is shorted to ground so boot in rescue mode # echo "Booting from rescue partition" # setenv load_uenv "load mmc 0:2 ${kernel_addr_r} /boot/uEnv.txt" # setenv load_fdt "load mmc 0:2 ${fdt_addr_r} /boot/${DTB_FILE}" # setenv load_kernel "load mmc 0:2 ${kernel_addr_r} /boot/Image" # raucargs="root=/dev/mmcblk0p2" # rescue=true # else raucargs=unset for BOOT_SLOT in "${BOOT_ORDER}"; do if test "x${raucargs}" != "xunset"; then # skip remaining slots elif test "x${BOOT_SLOT}" = "xA"; then if test ${BOOT_A_LEFT} -gt 0; then echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining" setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1 setenv load_uenv "load mmc 0:5 ${kernel_addr_r} /boot/uEnv.txt" setenv load_fdt "load mmc 0:5 ${fdt_addr_r} /boot/${DTB_FILE}" setenv load_kernel "load mmc 0:5 ${kernel_addr_r} /boot/Image" raucargs="root=/dev/mmcblk0p4 rauc.slot=A" fi elif test "x${BOOT_SLOT}" = "xB"; then if test ${BOOT_B_LEFT} -gt 0; then echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining" setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1 setenv load_uenv "load mmc 0:6 ${kernel_addr_r} /boot/uEnv.txt" setenv load_fdt "load mmc 0:6 ${fdt_addr_r} /boot/${DTB_FILE}" setenv load_kernel "load mmc 0:6 ${kernel_addr_r} /boot/Image" raucargs="root=/dev/mmcblk0p5 rauc.slot=B" fi fi done #fi if test "x${raucargs}" = "xunset"; then echo "No valid slot found, resetting tries to 3" setenv BOOT_A_LEFT 3 setenv BOOT_B_LEFT 3 saveenv reset fi # Examine the fdt loaded by the firmware # Pass fw_dtb to use the dtb loaded by the firmware fdt_live=unset fdt addr ${fdt_addr} fdt get value bootargs_fw /chosen bootargs for arg in ${bootargs_fw} ; do if test "x${arg}" = "xfw_dtb" ; then fdt_live=${fdt_addr} fi done # Save bootargs_fw in a local variable for later use bootargs_fw=${bootargs_fw} env del bootargs_fw # If we're not using the dtb loaded by the firmware, load our dtb # and fixup the emmc2 dma-ranges setting so newer SOCs will boot # For details of what the FW modifies, see this RPi forum post: # https://forums.raspberrypi.com/viewtopic.php?t=329799#p1974233 if test "x${rescue}" = "xtrue" -o "x${fdt_live}" = "xunset"; then # Using device-tree from rootfs # Check to see if we have any customizations in a uEnv.txt file env del bootargs_force bootargs_extra echo "Checking for /boot/uEnv.txt" if run load_uenv ; then echo "Importing uEnv.txt" env import -t -r ${fileaddr} ${filesize} fi # Fixup emmc2 dma range, which varies based on SOC revision # U-Boot's fdt get/set functions don't seem to work as expected # on properties with multiple values, so just do a memcpy() # Get a ptr/len for the FW modified dma-ranges fdt addr ${fdt_addr} fdt get addr tmp_src /emmc2bus dma-ranges fdt get size tmp_len /emmc2bus dma-ranges # Load our actual device-tree file echo "Loading device-tree" run load_fdt # Copy FW fixed-up dma-ranges to loaded device-tree fdt addr ${fdt_addr_r} fdt get addr tmp_dst /emmc2bus dma-ranges cp $tmp_src $tmp_dst $tmp_len # FIXME: Update PCIe dma-ranges if using PCIe! # Point to run-time device-tree fdt_live=${fdt_addr_r} # cleanup environment env del tmp_src tmp_len tmp_dst; # Setup kernel parameters if test -n "${bootargs_force}" ; then setenv bootargs "${bootargs_force} ${raucargs}" else setenv bootargs "${bootargs_default} ${bootargs_extra} ${raucargs}" fi else # Using FW provided device-tree # Append rauc boot arguments to FW generated command line # This setting will override /chosen/bootargs in the device-tree echo "Using firmware device-tree" setenv bootargs "${bootargs_fw} ${raucargs}" fi # Store updated boot state... # ...above code should have modified BOOT_(AB)_LEFT and bootargs setenv silent 1 #not sure this should be here saveenv echo "Loading kernel" run load_kernel echo "Starting kernel" booti ${kernel_addr_r} - ${fdt_live}
I tried root=/dev/mmcblk0p3 and 4 too.
-- Charles Steinkuehler @.***
I think all I had to do previously was comment out the recovery partition section in the genimage.cfg, but since pulling this latest version, it does not work. Maybe I'm just missing a step. I think it has something to do with looking for the partitions in the wrong place now. Here is some of the output at boot if that helps: