PINE64
Uboot says bad image magic - mainline kernel - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64-LTS / SOPINE Compute Module (https://forum.pine64.org/forumdisplay.php?fid=66)
+--- Forum: Linux on PINE A64-LTS / SOPINE (https://forum.pine64.org/forumdisplay.php?fid=69)
+--- Thread: Uboot says bad image magic - mainline kernel (/showthread.php?tid=19460)



Uboot says bad image magic - mainline kernel - lash - 10-13-2024

In an attempt to troubleshoot failing to get generic alpine linux to run on PA64-2G-LTS, I've tried to reduce the problem to the smallest steps that are legible to me. 

When booting the kernel, I get "Bad ARM64 Image Magic" I can't figure out what this means, and why it is happening. Sources I have searched seem to be board specific, and found nothing on this board. I've arrived at a point where I cannot find a way to reason further about it, so thus I am reaching out.

I am currently loading the kernel and dtb manually at the uboot prompt:

setenv bootargs loglevel=7 earlyprintk
fatload mmc 0:1 0x42000000 boot/vmlinux
fatload mmc 0:1 0x4a000000 boot/u-boot.dtb
booti 0x42000000 - 0x4a000000

My current configuration is:

        - linux 5.14 from mainline (git:7d2a07b769330c34b4deabeed939325c77a7ec2f)
        - u-boot v2024.10 from https://source.denx.de/u-boot/u-boot (git:f919c3a889f0ec7d63a48b5d0ed064386b0980bd)
        - dtb from the u-boot build
        - bl31.bin from PLAT=sun50i_a64 https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git lts-v2.10.6 (git:f2aebf361050d69176d60016170291efa9e08a68)
        - scp.bin from https://github.com/crust-firmware/crust 0.6 (git:ffe9f1ac9c675e6e67db9084bd19fbdeffd8e162)
        - u-boot-sunxi-with-spl.bin written to offset 8k
        - tried sd and emmc vfat single partition (whole disk) with
                * boot/vmlinux
                * boot/u-boot.dtb

Files:
    - uboot defconfig: https://g33k.holbrook.no/c36cab0e6a15127fa6c280912ece5fa01bfac44d68e701356ef4f57b25f71bdd
    - uboot environment (saved from soc): https://g33k.holbrook.no/1c4d93e6510eb49b9eb5660ec5a2ccdf4f81c5aa84093d79f928062329468b73
    - linux defconfig: https://g33k.holbrook.no/5bde4487e333f5af3502075e337007a034d363cb3f1f8a363804c819beb3382f


RE: Uboot says bad image magic - mainline kernel - lash - 10-14-2024

Sigh, of course I was trying to load the wrong kernel file, vmlinux instead of arch/arm64/boot/Image

Thanks to apritzel@itc:oftc:#linux-sunxi for pointing it out


RE: Uboot says bad image magic - mainline kernel - tllim - 10-14-2024

(10-14-2024, 09:15 AM)lash Wrote: Sigh, of course I was trying to load the wrong kernel file, vmlinux instead of arch/.../Image

Thanks to apritzel@itc:oftc:#linux-sunxi for pointing it out

Spot your IRC messages with apritzel at Linux-Sunxi chatroom :-)


RE: Uboot says bad image magic - mainline kernel - lash - 10-14-2024

This was great fun, I reached the first milestone and if it's of interest to anyone I thought I'd share my experience:

Did not see usb stick assigned to sdX, but spotted kmod "uas" depending on usb_storage on my own PC. Thus added CONFIG_USB_UAS=y to config. After that it shows up in pine's kernel.

(Though, when usb stick plugged in at powerup, path for root /dev/mmcblk0p1 does not work anymore, but that can be sorted later).

Statically built bash and used as init (using crosstool-ng, works like a charm):

Code:
bash
        export CROSS_COMPILE=aarch64-unknown-linux-gnu-
        export ARCH=arm64
        export PATH=$PATH:/home/lash/x-tools/aarch64-unknown-linux-gnu/bin
        ./configure --host aarch64-unknown-linux-gnu --enable-static-link --enable-minimal-config 
        make CFLAGS="-Wl,-w" -j8


final u-boot command sequence:


Code:
        setenv bootargs root=/dev/mmcblk0p1 init=/bin/bash earlycon console=tty debug loglevel=7
        fatload mmc 0:1 0x42000000 /boot/Image
        fatload mmc 0:1 0x45000000 /boot/u-boot.dtb
        booti 0x42000000 - 0x45000000


sdcard tree:


Code:
/mnt:
bin  boot

/mnt/bin:
bash

/mnt/boot:
Image  u-boot.dtb


can't do much with this of course, but from here on it is pretty familiar territory

Ah yes, and still on the 5.14 kernel.