u-boot multiboot issues
#1
Hi everyone, I've been working through this multiboot method.  I compiled u-boot with the volume key patch, flashed it to an SD card, hooked up a serial console cable, and verified that the key presses were detected.  That part is all well and good.  Now I'm running into a few problems making it actually boot things and I'm sure I'm missing something minor.  This is being tested on a ubports edition Pinephone, not that it matters but Mobian Bookworm is on my eMMC.

My goal is to boot eMMC with no key press, jumpdrive with a volume up key press, and Mobian from SD card with a key down press.


Problem 1

I set my SD card partitions up like this with sdb1 for boot, sdb2 for Mobian, sdb3 for eMMC Mobian /home:
Code:
Disk /dev/sdb: 119.25 GiB, 128043712512 bytes, 250085376 sectors
Disk model: USB3.0 CRW   -SD
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x07dcfc8d

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sdb1           2048   2099199   2097152     1G 83 Linux
/dev/sdb2        2099200  33347583  31248384  14.9G 83 Linux
/dev/sdb3       33347584 250085375 216737792 103.3G 83 Linux

I setup the folder structure as described in the wiki and put the Image.gz, initramfs.gz, and sun50i-a64-pinephone.dtb into multiboot/jumpdrive on the first partition of the card.  I setup the boot.text as show below, created the boot.src, and moved it to boot/ on the SD card.
Code:
setenv kernel_addr_z 0x44080000

setenv bootargs loglevel=0 silent console=tty0 vt.global_cursor_default=0

if test "${volume_key}" = "up" ; then
echo "yes im here"
setenv devtype mmc
setenv devnum 0
setenv distro_bootpart 1
gpio set 114

if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_z} /multiboot/jumpdrive/Image.gz; then
  unzip ${kernel_addr_z} ${kernel_addr_r}
  if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} /multiboot/jumpdrive/sun50i-a64-pinephone.dtb; then
    if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} /multiboot/jumpdrive/initramfs.gz; then
      booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
    else
      booti ${kernel_addr_r} - ${fdt_addr_r};
    fi;
  fi;
fi
exit
fi

It boots, detects the key press, then the kernel hangs when loading.  This is the serial console output:
Code:
U-Boot 2022.04-rc2-00121-g17a0dc6abf-dirty (Feb 21 2022 - 22:50:21 +0000) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: Pine64 PinePhone (1.2)
DRAM:  2 GiB
Core:  36 devices, 13 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0, mmc@1c10000: 2, mmc@1c11000: 1
Loading Environment from FAT... Unable to use mmc 0:1...
In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
2714 bytes read in 3 ms (882.8 KiB/s)
## Executing script at 4fc00000
yes im here
3991895 bytes read in 168 ms (22.7 MiB/s)
Uncompressed size: 8706056 = 0x84D808
33457 bytes read in 4 ms (8 MiB/s)
1068435 bytes read in 47 ms (21.7 MiB/s)
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
   Loading Ramdisk to 49efb000, end 49fffd93 ... OK
   Loading Device Tree to 0000000049eef000, end 0000000049efa2b0 ... OK

Starting kernel ...

Not sure what is going on there, any thoughts?  I tried two versions of jumpdrive (0.4 and 0.8 I think) with the same end result.  I read that the "Starting kernel ..." message is generated by the kernel itself, so it is as least getting that far.  It will hang there forever with no more output, not sure how to proceed.  Perhaps there are some debug flags that I could enable if I recompile the jumpdrive kernel?  I'd be open to try that if one of you kernel hacking gods can direct my weak mortal brain on what to enable in menu config.


Problem 2

Next I figured I'll try to make Mobian boot from a down key press while I research why the kernel might be hanging.  So I set that section of the boot.text up like below, created another boot.src, moved it to boot/, and got the below output.  This is a little more clear, the Ramdisk image format from the Mobian iso doesn't seem to play nice with u-boot, which I find odd since it boots happily when imaged to the device itself.  It finds the extlinux.conf so maybe my boot.src is confusing things somehow? 

Here is my boot.text section for Mobian (obvious, but if you add this to the entry for jumpdrive above you have my whole boot.text):
Code:
if test "${volume_key}" = "down" ; then
echo "down"

setenv bootdev 0
setenv bootargs init=/init.sh rw console=tty0 console=ttyS0,115200 no_console_suspend earlycon=uart,mmio32,0x01c28000 panic=10 consoleblank=0 loglevel=1 cma=256M boot=/dev/mmcblk${bootdev}p3 root=/dev/mmcblk${bootdev}p3

printenv

echo Loading DTB
load mmc ${mmc_bootdev}:1 ${fdt_addr_r} /multiboot/mobian/dtb-5.15-sunxi64/allwinner/sun50i-a64-pinephone-1.2.dtb

echo Loading Initramfs
load mmc ${mmc_bootdev}:1 ${ramdisk_addr_r} /multiboot/mobian/initrd.img-5.15-sunxi64

echo Loading Kernel
load mmc ${mmc_bootdev}:1 ${kernel_addr_r} /multiboot/mobian/vmlinuz-5.15-sunxi64

gpio set 115

echo Resizing FDT
fdt addr ${fdt_addr_r}
fdt resize

echo Booting kernel
gpio set 116
gpio clear 98
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# This ELSE statement assumes you have UBUNTU PORTS on your EMMC by default it says the following
# If nothing is being pressed than load the boot script on the EMMC drive, 1,4 where the boot script resides
# on Mobian EMMC device


else

setenv devtype mmc
setenv devnum 1
setenv partnum 4
load ${devtype} ${devnum}:2 ${scriptaddr} /boot.scr
source ${scriptaddr}
fi


Here is the serial console from it trying to boot with volume key down:
Code:
U-Boot 2022.04-rc2-00121-g17a0dc6abf-dirty (Feb 21 2022 - 22:50:21 +0000) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: Pine64 PinePhone (1.2)
DRAM:  2 GiB
Core:  36 devices, 13 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0, mmc@1c10000: 2, mmc@1c11000: 1
Loading Environment from FAT... Unable to use mmc 0:1...
In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
2714 bytes read in 3 ms (882.8 KiB/s)
## Executing script at 4fc00000
down
arch=arm
baudrate=115200
board=sunxi
board_name=sunxi
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fi
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_}
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=fel mmc_auto pxe dhcp
bootargs=init=/init.sh rw console=tty0 console=ttyS0,115200 no_console_suspend earlycon=uart,mmio32,0x01c3
bootcmd=run distro_bootcmd
bootcmd_dhcp=devtype=dhcp; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;seten;
bootcmd_fel=if test -n ${fel_booted} && test -n ${fel_scriptaddr}; then echo '(FEL boot)'; source ${fel_si
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_mmc_auto=if test ${mmc_bootdev} -eq 1; then run bootcmd_mmc1; run bootcmd_mmc0; elif test ${mmc_bi
bootcmd_pxe=dhcp; if pxe get; then pxe boot; fi
bootdelay=2
bootdev=0
bootfstype=ext4
bootm_size=0xa000000
console=ttyS0,115200
cpu=armv8
devplist=1
dfu_alt_info_ram=kernel ram 0x40080000 0x1000000;fdt ram 0x4FA00000 0x100000;ramdisk ram 0x4FF00000 0x4000
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethaddr=02:ba:ba:17:48:b0
fdt_addr_r=0x4FA00000
fdtcontroladdr=b9f3d600
fdtfile=allwinner/sun50i-a64-pinephone-1.2.dtb
fdtoverlay_addr_r=0x4FE00000
fileaddr=4fc00000
filesize=a9a
kernel_addr_r=0x40080000
kernel_addr_z=0x44080000
kernel_comp_addr_r=0x44000000
kernel_comp_size=0xb000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x42000000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
mmc_bootdev=0
partitions=name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};name=loader2,size=984k,uuid=${uuid_gpt;
pxefile_addr_r=0x4FD00000
ramdisk_addr_r=0x4FF00000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv dt
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; i
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart}e
scriptaddr=0x4FC00000
serial#=92c0b5baba1748b0
soc=sunxi
stderr=serial,vidconsole
stdin=serial
stdout=serial,vidconsole
uuid_gpt_esp=c12a7328-f81f-11d2-ba4b-00a0c93ec93b
uuid_gpt_system=b921b045-1df0-41c3-af44-4c6f280d3fae
volume_key=down

Environment size: 4661/131068 bytes
Loading DTB
Failed to load '/multiboot/mobian/dtb-5.15-sunxi64'
Loading Initramfs
19944004 bytes read in 830 ms (22.9 MiB/s)
Loading Kernel
7433919 bytes read in 310 ms (22.9 MiB/s)
gpio: pin 115 (gpio 115) value is 1
Resizing FDT
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
Booting kernel
gpio: pin 116 (gpio 116) value is 1
gpio: pin 98 (gpio 98) value is 0
   Uncompressing Kernel Image
Moving Image from 0x40080000 to 0x40200000, end=415c0000
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
SCRIPT FAILED: continuing...

I did a little reading and found that u-boot is expecting a uImage format initramfs.  So I tried to repackage it like this:
Code:
mkimage -A arm -T ramdisk -C none -n uInitrd -d /path/to/initrd.img /path/to/uInitrd

Once again I edited my boot.text, created a new boot.src, moved it to /boot, lather, rinse, repeat... It didn't like that either.  Is it clear to anyone what I'm doing wrong?  I'm having a little trouble finding documentation that relates to this directly, but it could just be due to my lack of experience with u-boot.

I've been a Linux user for many years, but haven't spent much time messing with u-boot and arm64 images.  Can someone point me to a good resource to better understand u-boot and how Mobian boots in general?
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How boot Alpine Linux realroot 4 678 11-02-2024, 01:00 PM
Last Post: linmob
  Tow boot MTXP 5 1,618 08-22-2024, 03:11 AM
Last Post: Pavlos1
  Pinephone won't boot. spha 13 5,916 05-15-2024, 10:31 PM
Last Post: Richy_T
  Pinephone boot. Richy_T 5 1,589 05-15-2024, 03:35 PM
Last Post: Richy_T
  PinePhone - boot from microSD laserpyramid 9 2,952 05-03-2024, 10:09 AM
Last Post: laserpyramid
  PinePhone Doesn't Boot LED Doesn't Show Any Signs When Charging dorkydev 1 1,098 04-02-2024, 11:50 AM
Last Post: Kevin Kofler
  Multiple issues with the Pinephone MTXP 12 4,668 12-28-2023, 07:55 AM
Last Post: MTXP
  Boot screen stuck at 'K' because of firmware deleted. poundantisec 9 6,800 08-28-2023, 11:38 AM
Last Post: fxc
  New Pinephone is dead. eMMC, boot, hardware issues. Shane 4 2,284 05-10-2023, 03:31 AM
Last Post: fxc
  New Phone Opening Issues LuluFrance 5 3,054 03-15-2023, 05:33 AM
Last Post: anonymous

Forum Jump:


Users browsing this thread: 1 Guest(s)