quickemu-project / quickemu

Quickly create and run optimised Windows, macOS and Linux virtual machines
MIT License
10.73k stars 470 forks source link

feat: add support for running Raspberry Pi images on foreign host #230

Open AquaMCU opened 2 years ago

AquaMCU commented 2 years ago

I would like to request a rather complex feature:

Starting Raspberry Pi Images with QEMU on an x84 ubuntu is a pain. But if you develop for a PI, it would be nice to use quickemu to start for example a Ubuntu Mate Pi Edition with this script.

Would that be possible? It would make my live so much easier!

vrince commented 2 years ago

Hi,

I think a good start could be to take a look at : https://github.com/lukechilds/dockerpi

I have been using dockerpi for a little while but end run qemu-system-arch manually since the 2 layer vm in docker is a little overwhelming when things are moving a lot ...

So looking at the entrypoint.sh we can see how qemu is setup to run rpi 1 / 2 / 3 https://github.com/lukechilds/dockerpi/blob/master/entrypoint.sh

...
if [ "${target}" = "pi1" ]; then
 emulator=qemu-system-arm
  kernel="/root/qemu-rpi-kernel/kernel-qemu-4.19.50-buster"
  dtb="/root/qemu-rpi-kernel/versatile-pb.dtb"
  machine=versatilepb
  memory=256m
  root=/dev/sda2
  nic="--net nic --net user,hostfwd=tcp::5022-:22"
elif [ "${target}" = "pi2" ]; then
  emulator=qemu-system-arm
  machine=raspi2b
  memory=1024m
  kernel_pattern=kernel7.img
  dtb_pattern=bcm2709-rpi-2-b.dtb
  append="dwc_otg.fiq_fsm_enable=0"
  nic="-netdev user,id=net0,hostfwd=tcp::5022-:22 -device usb-net,netdev=net0"
elif [ "${target}" = "pi3" ]; then
  emulator=qemu-system-aarch64
  machine=raspi3b
  memory=1024m
  kernel_pattern=kernel8.img
  dtb_pattern=bcm2710-rpi-3-b-plus.dtb
  append="dwc_otg.fiq_fsm_enable=0"
  nic="-netdev user,id=net0,hostfwd=tcp::5022-:22 -device usb-net,netdev=net0"
...
exec ${emulator} \
  --machine "${machine}" \
  --cpu arm1176 \
  --m "${memory}" \
  --drive "format=raw,file=${image_path}" \
  ${nic} \
  --dtb "${dtb}" \
  --kernel "${kernel}" \
  --append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=${root} rootwait panic=1 ${append}" \
  --no-reboot \
  --display none \
  --serial mon:stdio
...

But be carefull I think qemu only supports rpi1 rpi2 officially rpi3 is kinda of a strech use of rpi2 (not really emulating cortex cpu) and no rpi4 as far as I know.

M0Rf30 commented 2 years ago

For this, please have a look at https://github.com/M0Rf30/simonpi . It's an old project of mine. It use dedicated kernels for qemu and RPI family. You'll find a working qemu commandline for armv6 v7 and aarch64. It also support AVMF (edk2 for ARM) environment. Thanks for this simple but clever project.

Hi-Phile commented 1 year ago

This RFQ seems dead. This would be a nice to have feature, ARM support. Actually, QEMU already has the ability to boot and use ARM qcow2 images from a large variety of existing ARM devices. QEMU ARM Wiki

It seems possible to add/implement, but not sure where to make changes in the quickemu and .conf file and/or can use the extra_argsoption. I think the first hurdle is having the ability to use 'qemu-system-aarch' and then pass the arguments via the .conf file.

jspraul commented 1 year ago

MacOS in QEMU – ARM edition [pdf] | https://news.ycombinator.com/item?id=36889092

KVM Forum 2023 Day 2 10:15 AM https://youtu.be/hyrw4j2D6I0?t=4684