qemu-rpi-kernel icon indicating copy to clipboard operation
qemu-rpi-kernel copied to clipboard

Notes for native-emulation on Arch Linux

Open jchidley opened this issue 5 years ago • 5 comments
trafficstars

Thanks for doing this. I had to make some adjustments to get the native emulation to work on Arch Linux.

For Arch, packages qemu and qemu-arch-extra are required.

After unzipping the Raspbian download to a img file, I needed to use fdisk -u sectors -l ../Downloads/2020-08-20-raspios-buster-armhf-lite.img to work out the correct options to setup a loop device. This showed that the first partition's Start (in sectors) was 8192 and Sectors was 524288. So the offset in bytes will be 8192 * 512 and the sizelimit 524288 * 512

losetup -f --show -P --offset $((8192 * 512)) --sizelimit $((524288 * 512))  ../Downloads/2020-08-20-raspios-buster-armhf-lite.img

Because qemu-system-aarch64 kept complaining that the image was in the raw format, and I couldn't work how to specify the format for the -sd option, I converted the raspbian image from a raw format to the qcow2 one using

qemu-img convert -f raw -O qcow2 ../Downloads/2020-08-20-raspios-buster-armhf-lite.img rpi.qcow2

Finally, my modified command to start the image was:

qemu-system-aarch64 -M raspi3 -append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" -dtb ./bcm2710-rpi-3-b-plus.dtb -sd rpi.qcow2 -kernel kernel8.img -m 1G -smp 4 -serial stdio -usb -device usb-mouse -device usb-kbd

jchidley avatar Nov 11 '20 12:11 jchidley

@jchidley : Thank you !! That's very useful info. Would you like to create a wiki post on how to emulate rpi-arch / do you mind if I add the posted info in a wiki post ?

dhruvvyas90 avatar Nov 18 '20 17:11 dhruvvyas90

You have my permission to reuse what I wrote in this issue, above. If I were you, I would test the commands to be sure that a syntax error hasn’t crept in. I am glad that you found it helpful.

jchidley avatar Nov 18 '20 21:11 jchidley

Thank you !! I will double check the instructions before publishing it under wiki.

dhruvvyas90 avatar Nov 19 '20 00:11 dhruvvyas90

I was able to use the raw image directly without the limitation by replacing -sd filename.img with -drive file=filename.img,format=raw,index=0,media=disk, however the newer raspi images start directly to raspi-config (which opens in the graphical output window) and while QEMU captured input devices, I was unable to navigate it. I tried all available options for -serial with or without the console boot option in -append , tried omitting the usb options or replacing them with -usb -usbdevice keyboard -usbdevice mouse, to no success. Any ideas on that?

k1ba-meow avatar Jan 31 '23 11:01 k1ba-meow

Update: I tried to boot the 2022-09-22-bullseye-arm64 image, in my above comment the lite version, now I also tried the regular version with GUI and again, QEMU captures input devices but no input is recognized on the pi

k1ba-meow avatar Jan 31 '23 12:01 k1ba-meow