borys
October 7, 2023, 4:47pm
1
Hi Folks,
I want to test Raspberry Pi builds on my laptop by emulating Raspberry Pi.
I know that this is possible by running QEMU with official Raspberry Pi image and with Ubuntu Raspberry Pi images as described for example here .
I tried to do the same with NixOS Raspberry Pi image (which is generic SD image).
I downloaded https://hydra.nixos.org/build/237120771/download/1/nixos-sd-image-23.11pre531102.fdd898f8f79e-aarch64-linux.img.zst
and:
I prepared disk image:
cat ....img.zst | unzstd -o disk.img
qemu-img resize disk.img 8G
I temporarily mounted each partitions and copied:
cp mounted/bcm2711-rpi-4-b.dtb treeblob.dtb # from first partition
cp mounted/boot/nixos/vgr4bvi1msxfjhkr6sijqj07slchvbf4-linux-6.1.55-Image kernel.img # from second partition
and then I run
qemu-system-aarch64 \
-machine raspi3b \
-cpu cortex-a72 \
-smp 4 -m 1G \
-dtb treeblob.dtb \
-drive "file=disk.img,format=raw,index=0,if=sd" \
-device usb-net,netdev=net0 -netdev user,id=net0,hostfwd=tcp::50022-:22 \
-monitor tcp:127.0.0.1:50021,server,nowait \
-nographic
And nothing. I tried with -nographic
which should give me serial port output and I also tried without -nographic
which should give me VGA output. But I didn’t get any serial / VGA output.
I assume there is something wrong with QEMU configuration and what works for Raspbian, doesn’t work for NixOS.
Could you please help? Do you know how to run it?
Thank you.
borys
October 8, 2023, 4:51pm
3
Thank you, but that doesn’t work.
I tried another 10 configurations with -kernel linux-6.1.55-Image
and -kernel u-boot-rpi3.bin
and -kernel u-boot-rpi4.bin
but nothing is giving me any serial / VGA output.
danf
October 9, 2023, 9:00am
4
Maybe instead of -kernel
get BIOS file and run it like:
qemu-system-aarch64 -M virt -cpu cortex-a72 \
-m 256M -smp 2 -nographic \
-bios QEMU_EFI.fd \
-drive if=none,file=disk.img,id=hd0,format=raw -device virtio-blk-device,drive=hd0 \
-device virtio-net-device,netdev=vmnic -netdev user,id=vmnic
borys
October 9, 2023, 12:17pm
5
I found QEMU_EFI.fd
in qemu-efi-aarch64_2022.11-6_all.deb
but I’m getting
BdsDxe: failed to load Boot0001 "UEFI Misc Device" from VenHw(837DCA9E-E874-4D82-B29A-23FE0E23D1E2,003E000A00000000): Not Found
>>Start PXE over IPv4.
I don’t get it - why NixOS SD image that works on rpi doesn’t run under QEMU…
nixme
October 9, 2023, 5:53pm
6
It would be super useful to figure out how to run Raspberry Pi image to test ARM config before build.
Any QEMU experts?
Thank you.
The following works with Raspbian:
qemu-system-aarch64 \
-machine raspi3b \
-cpu cortex-a72 \
-smp 4 -m 1G \
-kernel kernel.img \
-dtb treeblob.dtb \
-drive "file=2023-05-03-raspios-bullseye-arm64.img disk.img,format=raw,index=0,if=sd" \
-append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" \
-device usb-net,netdev=net0 -netdev user,id=net0,hostfwd=tcp::1234-:22 \
-nographic
Does it not work with NixOS image?
borys
October 11, 2023, 6:57am
8
Unfortunately it doesn’t
This thread is related but we never were able to get SSH running.
Well and that didn’t work either.
I reckon I’m now as lost as you are.
Maybe @samueldr knows if the problem from the qemu Gitlab repository is related?
nix build .#images.raspi
error: builder for '/nix/store/9rm1hqc9d3paphpx8pmfzw3i1bc5wla2-linux-5.15.32-1.20220331-modules-shrunk.drv' failed with exit code 1;
last 10 log lines:
> copying dependency: /nix/store/zmpsqch7hz0zkjgg1fjcpr3f7vf1dzi3-linux-5.15.32-1.20220331-modules/lib/modules/5.15.32/kernel/drivers/message/fusion/mp…
1 Like
borys
October 12, 2023, 2:01pm
10
Thank you.
For some reason my Google foo didn’t find the post.
I’ve just run
qemu-system-aarch64 \
-M raspi3b \
-dtb ./bcm2837-rpi-3-b.dtb \
-m 1G \
-smp 4 \
-drive "format=raw,file=disk.img" \
-kernel ./u-boot-rpi3.bin \
-device usb-net,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-append "console=ttyAMA0 root=/dev/mmcblk0p2 rw rootwait" \
-nographic
and it gives me some output. As you mentioned I can’t SSH-in but it’s a progress .