Gesendet: Dienstag, 15. März 2022 um 11:09 Uhr
Von: "Peter Maydell" <peter.mayd...@linaro.org>
An: "Johannes Zirngibl" <finc...@web.de>
Cc: qemu-discuss@nongnu.org
Betreff: Re: Emulating a Raspberry3 on Debian11 using QEMU6.2.0
Von: "Peter Maydell" <peter.mayd...@linaro.org>
An: "Johannes Zirngibl" <finc...@web.de>
Cc: qemu-discuss@nongnu.org
Betreff: Re: Emulating a Raspberry3 on Debian11 using QEMU6.2.0
On Tue, 15 Mar 2022 at 07:36, Johannes Zirngibl <finc...@web.de> wrote:
> 2.) sudo qemu-system-aarch64 -machine raspi3b -drive file=kube-worker-1.img,format=raw -drive- if=none,id=stick,file=/home/john/Downloads/2022-01-28-raspios-bullseye-armhf/2022-01-28-raspios-bullseye-armhf.img,format=raw -device usb-storage,drive=stick -boot c -m 1G
The raspi3b machine does not have a default BIOS/firmware image
or any emulation of it, so it cannot boot directly from a
disk image. You'll need to directly pass a kernel/initrd/devicetree
to QEMU, I think.
-- PMM
> 2.) sudo qemu-system-aarch64 -machine raspi3b -drive file=kube-worker-1.img,format=raw -drive- if=none,id=stick,file=/home/john/Downloads/2022-01-28-raspios-bullseye-armhf/2022-01-28-raspios-bullseye-armhf.img,format=raw -device usb-storage,drive=stick -boot c -m 1G
The raspi3b machine does not have a default BIOS/firmware image
or any emulation of it, so it cannot boot directly from a
disk image. You'll need to directly pass a kernel/initrd/devicetree
to QEMU, I think.
-- PMM
Thank you so much. Directly passing the kernel/initrd and devicetree worked out!
At first i have to say that i found a Step by Step Guide following this link. https://linuxconfig.org/how-to-run-the-raspberry-pi-os-in-a-virtual-machine-with-qemu-and-kvm
Please keep in mind: Everything that follows is just my adoption to my usecase! I am not the Author of this Guide! Though it worked for me i can't guarantee that i will work for anybody else.
Prerequisites:
STEP 1 Download the source code of qemu 6.2.0 and build it manually according to the given instructions on the Website https://www.qemu.org/download/#linux
STEP 2 Install the missing packages $ sudo apt-get update && sudo apt-get install qemu-system-arm qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager
STEP 3 Download the Pi OS Lite (this is the core version without GUI)# Using wget $ wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf-lite.zip # Using curl $ curl -O https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf-lite.zipOR Download the PI OS Desktop# Using wget $ wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf.zip # Using curl $ curl -O https://downloads.raspberrypi.org/raspios_lite_armhf/raspios_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf.zipSTEP 4 Verify the integrity of you DownloadFor Pi OS Lite (Assuming the zip-file is downloaded the home directory otherwise you have to type the full path)Download the hashsumfile and extract it.SHA256 hashsum-file (https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf-lite.zip.sha256)Generate hashsum of your zipfile
$ sha256sum 2022-01-28-raspios-bullseye-armhf.zipFor the Desktop-Version (Assuming the zip-file is downloaded the home directory otherwise you have to type the full path)Download the hashsumfile and extract it.SHA256 hashsum-file (https://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf.zip.sha256)Generate hashsum of your zipfile $ sha256sum 2022-01-28-raspios-bullseye-armhf-lite.zipCompare the two Hashsums. If they match you can proceedSTEP 5 Download the repository to obtain the bullseye kernel and the devicetree$ git clone https://github.com/dhruvvyas90/qemu-rpi-kernel (Please notice that here I assume the working directory is the same where we downloaded the system image)By typing ls qemu-rpi-kernel you will get this output:$ ls qemu-rpi-kernel
kernel-qemu-3.10.25-wheezy README.md
kernel-qemu-4.14.79-stretch tools
kernel-qemu-4.19.50-buster versatile-pb-bullseye-5.10.63.dtb
kernel-qemu-4.4.34-jessie versatile-pb-buster-5.4.51.dtb
kernel-qemu-5.10.63-bullseye versatile-pb-buster.dtb
kernel-qemu-5.4.51-buster versatile-pb.dtb
native-emulationYou want to have the bullseye-version so you have to choose 'kernel-qemu-5.10.63-bullseye' and 'versatile-pb-bullseye-5.10.63.dtb' when you emulate the raspi3, so you have to note them down or open a new bash to go on with the next stepSTEP 6 Build the virtual Network interfaceDebian requires to create and start a virtual Networkinterface for you VMs due to fact that it's not done automatically. (I used the default setting which is a NATed bridged NIC)This will enable the VMs to communicate with each other, with the host, and vice versa. They also gain access to the interne but without additional configuration, devices on your LAN wont be able to communicate with the VMs.$ sudo virsh --connect=qemu:///system net-start defaultif you want to have it started automatically in the future also type:$ sudo virsh --connect=qemu://system net-autostart defaultSTEP 7 Build the VM and Emulate Raspi3$ sudo virt-install \ --name rpios \ --arch armv7l \ --machine versatilepb \ --cpu cortexa53 \ --vcpus 4 \ --memory 1024 \ --import \ --disk 2022-01-28-raspios-bullseye-armhf-lite.img,format=raw,bus=virtio \ --network bridge,source=virbr0,model=virtio \ --video vga \ --graphics spice \ --boot 'dtb=qemu-rpi-kernel/versatile-pb-bullseye-5.10.63.dtb,kernel=qemu-rpi-kernel/kernel-qemu-5.10.63-buster,kernel_args=root=/dev/vda2 panic=1' \ --events _on_reboot_=destroyWith the '--name' option you define the hostname of the VM. Change it into the one you like.in the '--disk' section i chose the Pi OS Lite. If you're using the desktop version you have to change that accordingly by deleting '-lite' in the img.filenameNow a virt-viewer window should pop out and you'll be able to se the Pi OS bootRegards