[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Booting Debian Raspberry Pi image under QEMU?



At Fri, 14 Nov 2025 14:33:04 +0100 <tomas@tuxteam.de> wrote:

>
> Hi,
>
> I'm trying to boot a Debian raspberry Pi image under qemu; specifically,
> it is
>
>   https://raspi.debian.net/tested/20231109_raspi_4_bookworm.img.xz
>
> listed in
>
>   https://raspi.debian.net/tested-images/.
>
> After downloading, checking sha256sum, unxz-ing and resizing the image
> to 4G with qemu-img resize, this is the incantation I try:
>
>     qemu-system-aarch64 \
>     -display none \
>     -machine raspi4b \
>     -cpu cortex-a72 \
>     -dtb bcm2711-rpi-4-b.dtb \
>     -m 2G \
>     -smp 4 \
>     -serial stdio \
>     -kernel vmlinuz-6.1.0-13-arm64 \
>     -append "earlycon=pl011,mmio32,0xfe201000 \
>             console=ttyAMA0,115200 \
>             root=/dev/mmcblk1p2 \
>             rootfstype=ext4 \
>             fsck.repair=no \
>             rootwait \
>             init=/bin/bash" \
>     -initrd initrd.img-6.1.0-13-arm64 \
>     -drive format=raw,20231109_raspi_4_bookworm.img

Two things that are partitular to Raspberry Pi's:

The Raspberry Pi "images" are for a two partituon uSD.  The first partition is
a *FAT* file system, and contains the kernel and init ramdisk, along with the
the boot overlays. etc.  The Raspberry Pi boot ROM/bootloader is a unique
beast.  I am not sure if qemu really implements the Raspberry Pi boot ROM.

I guess what you are trying to do is get around the Raspberry Pi boot
ROM/bootloader by passing the kernel directly yo qemu.  If you are doing that,
then the vmlinuz and initrd.img files must be on the host file system.  Eg
*qemu* is NOT going to look for them in 20231109_raspi_4_bookworm.img.

You need to mount the image (eg losetup -P / mount), and then *copy* the
vmlinuz and initrd.img files out.

Secondly, I am not sure if the root FS you are specifying above
(/dev/mmcblk1p2) is going to work, unless you specify the proper 'if" for
the -drive option.  Eg:

    -drive if=sd,format=raw,20231109_raspi_4_bookworm.img

>
> (don't ask ;-)
>
> But qemu complains
>
>   qemu-system-aarch64: could not load kernel 'vmlinuz-6.1.0-13-arm64'
>
> Mounting the image's first partition (losetup -P, then mount the first,
> e.g /dev/loop0p1) confirms that there is a "vmlinuz-6.1.0-13-arm64"
> there, also a 20231109_raspi_4_bookworm.img (in that partition's file
> systems root).
>
> Could someone beat me with a clue stick to get one step further?
>
> How does one go about debugging such a boot machinery?
>
> Thanks for any insight.
>
> Please keep ratten@buecherratten.in-berlin.de in CC since they aren't
> subscribed.
>
> Cheers

--
Robert Heller             -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller@deepsoft.com       -- Webhosting Services



Reply to: