richardk Posted November 19, 2019 Posted November 19, 2019 I'm trying to create a microSD card to boot Armbian, but first would be inserted into a Windows laptop to edit some configuration. To make the microSD show up in Windows, the first partition must be a FAT partition, and so Linux would be ext4 partion 2. I suspect I'll need to put the /boot partition on the FAT volume, with directions to load from mmcblk1p2. In case it matters, this is a Rock64 without emmc. I've just started this research, but I'd be grateful for any u-boot-savvy person's help here. Thanks.
richardk Posted November 19, 2019 Author Posted November 19, 2019 Okay, make sure to set BOOT flag on the second partition. Adding setenv rootdev "/dev/mmcblk0p2" to armbianEnv.txt to the second partition's /boot/armbianEnv.txt doesn't work. Moving on... 1
richardk Posted November 19, 2019 Author Posted November 19, 2019 Wow, copying the contents of p2:/boot in ext4 to p1:/boot in FAT is worse. Gets into a loop... SdmmcInit=2 0 BootCapSize=0 UserCapSize=0MB FwPartOffset=2000 , 0 SdmmcInit=2 0 BootCapSize=0 UserCapSize=0MB FwPartOffset=2000 , 0 SdmmcInit=2 0 ...
martinayotte Posted November 19, 2019 Posted November 19, 2019 22 minutes ago, richardk said: Adding setenv rootdev "/dev/mmcblk0p2" to armbianEnv.txt to the second partition's /boot/armbianEnv.txt doesn't work. armbianEnv.txt is not a script, it is environment. So change the following : rootdev=UUID=69c4417e-e866-4934-8625-bd5fed6f21d5 to : rootdev=/dev/mmcblk0p2
richardk Posted November 19, 2019 Author Posted November 19, 2019 Well, firstly don't overwrite your u-boot sectors with a fat partition. Nothing works. Secondly: rootdev=/dev/mmcblk0p2 isn't it either. I get: This seems like the relevant portion of the log: mmc1 is current device Scanning mmc 1:2... Found U-Boot script /boot/boot.scr 2949 bytes read in 21 ms (136.7 KiB/s) ## Executing script at 00500000 Boot script loaded from mmc 1 reading /boot/uInitrd ** Unable to read file /boot/uInitrd ** reading /boot/Image ** Unable to read file /boot/Image ** reading /boot/dtb/rockchip/rk3328-rock64.dtb ** Unable to read file /boot/dtb/rockchip/rk3328-rock64.dtb ** It appears it found /boot/boot.scr, but then didn't find other files. Oh - maybe it's mmcblk1p2...
MacBreaker Posted November 19, 2019 Posted November 19, 2019 Hello @richardk, to edit file from ext x filesystem on Windows machines, use Ext2Fsd-0.69.exe https://www.heise.de/download/product/ext2fsd-57713 works pefect...
richardk Posted November 19, 2019 Author Posted November 19, 2019 Sigh, no change using /dev/mmcblk1p2. Found U-Boot script /boot/boot.scr 2949 bytes read in 21 ms (136.7 KiB/s) ## Executing script at 00500000 Boot script loaded from mmc 1 reading /boot/uInitrd ** Unable to read file /boot/uInitrd ** reading /boot/Image ** Unable to read file /boot/Image ** reading /boot/dtb/rockchip/rk3328-rock64.dtb ** Unable to read file /boot/dtb/rockchip/rk3328-rock64.dtb **
richardk Posted November 19, 2019 Author Posted November 19, 2019 It loos like maybe "first partition" is coded into boot.scr... # get PARTUUID of first partition on SD/eMMC the boot script was loaded from if test "${devtype}" = "mmc"; then part uuid mmc ${devnum}:1 partuuid; fi I'll need to edit boot.cmd and recompile boot.scr.
richardk Posted November 19, 2019 Author Posted November 19, 2019 Well, progress made. Added to boot.cmd: setenv partnum "2" setenv devnum "${devnum}:${partnum}" After that, the kernel image gets loaded, but shortly thereafter it resets and boots again... [ 44.604791] reboot: Restarting system The device tree seems to be unresolved... Scanning mmc 1:2... Found U-Boot script /boot/boot.scr 3048 bytes read in 21 ms (141.6 KiB/s) ## Executing script at 00500000 Boot script loaded from mmc 1:2 171 bytes read in 18 ms (8.8 KiB/s) 8018124 bytes read in 394 ms (19.4 MiB/s) 20498944 bytes read in 959 ms (20.4 MiB/s) 51131 bytes read in 33 ms (1.5 MiB/s) 293 bytes read in 38 ms (6.8 KiB/s) Applying kernel provided DT overlay rockchip-spi1.dtbo 2698 bytes read in 32 ms (82 KiB/s) Applying kernel provided DT fixup script (rockchip-fixup.scr) ## Executing script at 39000000libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND ## Loading init Ramdisk from Legacy Image at 04000000 ... Image Name: uInitrd Image Type: AArch64 Linux RAMDisk Image (gzip compressed) Data Size: 8018060 Bytes = 7.6 MiB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK ## Flattened Device Tree blob at 01f00000 Booting using the fdt blob at 0x1f00000 Loading Ramdisk to fc75b000, end fcf0088c ... OK reserving fdt memory region: addr=1f00000 size=72000 Loading Device Tree to 00000000fc6e6000, end 00000000fc75afff ... OK Starting kernel ...
richardk Posted November 19, 2019 Author Posted November 19, 2019 SUCCESS. I've got it booting the second partition. Lessons: armbianEnv.txt really wants UUID=. If you make a new partition, make sure to match UUIDs. Edit boot.cmd; find: echo "Boot script loaded from ${devtype} ${devnum}" Before that line, add: setenv partnum "2" setenv devnum "${devnum}:${partnum}" That's how it's working. I thought I could adjust so that it took partnum=2 from armbianEnv.txt (and move the new setenv devnum down after armbianEbv.tct is loaded). I don't know why that didn't work; I might have messed something else up. Anyway, I'm good to go. 1
Caletronics Posted March 29, 2020 Posted March 29, 2020 I too wanted to boot to a second partition and struggled. The workaround by @richardk sort of fixes of the problem but isn't a general solution. After examining the U-Boot environment (printenv at the u-boot prompt) and /boot/boot.cmd I feel that boot.cmd needs to be patched. If you set the boot flag on the second partition (parted or fdisk, etc.) then U-Boot correctly sets 'distro_bootpart' and thereafter uses '${devnum}:${distro_bootpart}'. I modified boot.cmd to follow the same convention, rebuilt boot.scr and it works. *** a/boot.cmd 2020-03-29 11:47:02.268576905 -0700 --- b/boot.cmd 2020-03-29 11:55:28.541325423 -0700 *************** *** 18,25 **** echo "Boot script loaded from ${devtype}" ! if test -e ${devtype} ${devnum} ${prefix}armbianEnv.txt; then ! load ${devtype} ${devnum} ${load_addr} ${prefix}armbianEnv.txt env import -t ${load_addr} ${filesize} fi --- 18,25 ---- echo "Boot script loaded from ${devtype}" ! if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}armbianEnv.txt; then ! load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}armbianEnv.txt env import -t ${load_addr} ${filesize} fi *************** *** 34,71 **** if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=memory swapaccount=1"; fi ! load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile} fdt addr ${fdt_addr_r} fdt resize 65536 for overlay_file in ${overlays}; do ! if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/allwinner/overlay/${overlay_prefix}-${overlay_file}.dtbo; then echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo" fdt apply ${load_addr} || setenv overlay_error "true" fi done for overlay_file in ${user_overlays}; do ! if load ${devtype} ${devnum} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then echo "Applying user provided DT overlay ${overlay_file}.dtbo" fdt apply ${load_addr} || setenv overlay_error "true" fi done if test "${overlay_error}" = "true"; then echo "Error applying DT overlays, restoring original DT" ! load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile} else ! if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/allwinner/overlay/${overlay_prefix}-fixup.scr; then echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" source ${load_addr} fi ! if test -e ${devtype} ${devnum} ${prefix}fixup.scr; then ! load ${devtype} ${devnum} ${load_addr} ${prefix}fixup.scr echo "Applying user provided fixup script (fixup.scr)" source ${load_addr} fi fi ! load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd ! load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}Image booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} --- 34,71 ---- if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=memory swapaccount=1"; fi ! load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}dtb/${fdtfile} fdt addr ${fdt_addr_r} fdt resize 65536 for overlay_file in ${overlays}; do ! if load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}dtb/allwinner/overlay/${overlay_prefix}-${overlay_file}.dtbo; then echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo" fdt apply ${load_addr} || setenv overlay_error "true" fi done for overlay_file in ${user_overlays}; do ! if load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then echo "Applying user provided DT overlay ${overlay_file}.dtbo" fdt apply ${load_addr} || setenv overlay_error "true" fi done if test "${overlay_error}" = "true"; then echo "Error applying DT overlays, restoring original DT" ! load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}dtb/${fdtfile} else ! if load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}dtb/allwinner/overlay/${overlay_prefix}-fixup.scr; then echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" source ${load_addr} fi ! if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}fixup.scr; then ! load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}fixup.scr echo "Applying user provided fixup script (fixup.scr)" source ${load_addr} fi fi ! load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${prefix}uInitrd ! load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}Image booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} 1
Gediz Posted September 7, 2020 Posted September 7, 2020 On 11/19/2019 at 3:56 PM, richardk said: Okay, make sure to set BOOT flag on the second partition. Thank you so much. Somehow I forgot to add bootable = "true" flag to the genimage.cfg. If it weren't for your post, I'd waste several more hours debugging U-Boot.
Lexingtonian Posted April 22, 2021 Posted April 22, 2021 On 11/19/2019 at 8:21 AM, martinayotte said: armbianEnv.txt is not a script, it is environment. So change the following : rootdev=UUID=69c4417e-e866-4934-8625-bd5fed6f21d5 to : rootdev=/dev/mmcblk0p2 This got me going again today after I over-wrote my armbianEnv.txt. Thank you!
Recommended Posts