Jump to content

Running self-build image on QEMU arm64


Go to solution Solved by AlexK,

Recommended Posts

Posted

Hi!

 

Currently try to figure out how to run my freshly builded Armbian using QEMU arm64.

According to this tutorial: https://docs.armbian.com/Developer-Guide_Build-Preparation/  I prepare clean Jammy VM.

Build using this CMD: 

./compile.sh BOARD=qemu-uboot-arm64 BRANCH=current RELEASE=bookworm

 

Build process was going smoothly i pick up two files from output folder: 

1) Armbian-unofficial_24.5.0-trunk_Qemu-uboot-arm64_bookworm_current_6.6.29_minimal.img.qcow2 2) Armbian-unofficial_24.5.0-trunk_Qemu-uboot-arm64_bookworm_current_6.6.29_minimal.u-boot.bin

 

Currently boot up process stucked, i can run U-boot and mount qcow2 image using this CMD:

qemu-system-aarch64 \
-machine virt -cpu cortex-a57 \
-netdev user,id=net0 -device e1000,netdev=net0 \
-serial stdio \
-bios Armbian-unofficial_24.5.0-trunk_Qemu-uboot-arm64_bookworm_current_6.6.29_minimal.u-boot.bin \
-drive if=none,file=Armbian-unofficial_24.5.0-trunk_Qemu-uboot-arm64_bookworm_current_6.6.29_minimal.img.qcow2,id=mydisk \
-device ich9-ahci,id=ahci \
-device ide-hd,drive=mydisk,bus=ahci.0

 

U-boot see the drive with rootfs, but during boot process i had this error:

Failed to load '/boot/uInitrd'
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
Boot failed (err=-14)

 

Full boot process log:

U-Boot 2023.10-armbian (Mar 14 2024 - 01:18:23 +0000)

DRAM:  128 MiB
Core:  51 devices, 14 uclasses, devicetree: board
Flash: 64 MiB
Loading Environment from Flash... *** Warning - bad CRC, using default environment

In:    pl011@9000000
Out:   pl011@9000000
Err:   pl011@9000000
Net:   e1000: 52:54:00:12:34:56
       eth0: e1000#0
Hit any key to stop autoboot:  0 
Scanning for bootflows in all bootdevs
Seq  Method       State   Uclass    Part  Name                      Filename
---  -----------  ------  --------  ----  ------------------------  ----------------
Scanning global bootmeth 'efi_mgr':
Scanning bootdev 'fw-cfg@9020000.bootdev':
fatal: no kernel available
No working controllers found
scanning bus for devices...
Target spinup took 0 ms.
SATA link 1 timeout.
SATA link 2 timeout.
SATA link 3 timeout.
SATA link 4 timeout.
SATA link 5 timeout.
AHCI 0001.0000 32 slots 6 ports 1.5 Gbps 0x3f impl SATA mode
flags: 64bit ncq only 
  Device 0: (0:0) Vendor: ATA Prod.: QEMU HARDDISK Rev: 2.5+
            Type: Hard Disk
            Capacity: 54564.0 MB = 53.2 GB (111747072 x 512)
Scanning bootdev 'ahci_scsi.id0lun0.bootdev':
  0  script       ready   scsi         1  ahci_scsi.id0lun0.bootdev /boot/boot.scr
** Booting bootflow 'ahci_scsi.id0lun0.bootdev.part_1' with script
scanning bus for devices...
  Device 0: (0:0) Vendor: ATA Prod.: QEMU HARDDISK Rev: 2.5+
            Type: Hard Disk
            Capacity: 54564.0 MB = 53.2 GB (111747072 x 512)
Device 0: (0:0) Vendor: ATA Prod.: QEMU HARDDISK Rev: 2.5+
            Type: Hard Disk
            Capacity: 54564.0 MB = 53.2 GB (111747072 x 512)
<DIR>       4096 .
<DIR>       4096 ..
<SYM>         28 Image
<SYM>         24 dtb
<DIR>       4096 dtb-6.6.29-current-arm64
           38518 boot.bmp
               0 .next
<SYM>         28 uInitrd
             906 boot.cmd
         6040046 System.map-6.6.29-current-arm64
             978 boot.scr
        49178863 uInitrd-6.6.29-current-arm64
          318778 config-6.6.29-current-arm64
        38134272 vmlinuz-6.6.29-current-arm64
        49178799 initrd.img-6.6.29-current-arm64
KERNEL LOAD ADDRESS: kernel_addr_r : 0x40400000
INITRD LOAD ADDRESS: ramdisk_addr_r: 0x44000000
FDT LOAD ADDRESS   : fdt_addr      : 0x40000000
38134272 bytes read in 853 ms (42.6 MiB/s)
** Reading file would overwrite reserved memory **
Failed to load '/boot/uInitrd'
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
Boot failed (err=-14)
---  -----------  ------  --------  ----  ------------------------  ----------------
(1 bootflow, 1 valid)

 

Any ideas what i'm doing wrong?

<
  • Solution
Posted

The problem was with -m flag, i forget to allocate enough memory for VM to start, so working CMD:

qemu-system-aarch64 \
-machine virt -cpu cortex-a57 -m 512 \
-netdev user,id=net0 -device e1000,netdev=net0 \
-serial stdio \
-bios Armbian-unofficial_24.5.0-trunk_Qemu-uboot-arm64_bookworm_current_6.6.29_minimal.u-boot.bin \
-drive if=none,file=Armbian-unofficial_24.5.0-trunk_Qemu-uboot-arm64_bookworm_current_6.6.29_minimal.img.qcow2,id=mydisk \
-device ich9-ahci,id=ahci \
-device ide-hd,drive=mydisk,bus=ahci.0

 

  • Igor pinned this topic
Posted

A quick look at the shell code makes me think that it is a different purpose compared to how I use virtualization. I use only HW accelerated based virtualization, so -enable-kvm flag is missing, but might be added by virt-install. Also mostly Arm on Arm although I also use x86 on x86 as well. I do not use qcow2, but just flat images or a physical SD-card or NBD or LVM.

 

Before I got my Rock3A, I downloaded the Armbian Noble image for it (was 6.6.62) but put a 6.12 *rk3588 kernel on it as well. With the default Armbian U-Boot for QEMU I could then prepare everything and already 'run' my Rock3A as a VM on NanoPi-R6C like this:

taskset --cpu-list 0-3 qemu-system-aarch64 \
-M virt -cpu host -enable-kvm -m 2048 -smp 4 \
-bios u-boot.bin \
-drive if=none,file=rock3a.img,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-netdev bridge,id=hn1 -device virtio-net,netdev=hn1,mac=xx:xx:xx:xx:xx:xx \
-nographic

The taskset is needed if host runs 6.1.x  vendor kernel and also makes it more realistic w.r.t. speed as then the VM gets 4x Cortex-A55, same as real Rock3A.

The 6.12/rk3588 kernel (inside the VM) was needed as that one has all included w.r.t. machine virt (same as vanilla Debian Bookworm kernel).

 

A note is that I later on added Btrfs support to a custom build u-boot for QEMU and converted Ext4 in rock3a.img into Btrfs, but principle is the same. Btrfs offers online shrink and differential snapshots that I use for remote backups. And with a MAC-address equal to the real Rock3A, it is easy flipping between real and VM.

 

Also note is that the following file needs to be created on the host, assuming it uses br0 as base for network I/O:

# cat /etc/qemu/bridge.conf 
allow br0

 

To use full graphics in VM and for multi-year running VM on my RPi4B, I also use virsh and UEFI. But usually only CLI is needed.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines