Raspberry Pi 4 emulation QEMU 9

emulation
Forum rules
do not spam respect other forum members
Post Reply
User avatar
david
Site Admin
Posts: 366
Joined: Sat May 21, 2016 7:50 pm

Raspberry Pi 4 emulation QEMU 9

Post by david »


youtu.be/thImUPLsEj8

Join our telegram group if you wana chat or have specific questions:
https://t.me/+h2K5CX5jEZA0MWJk

Prerequisites
Install QEMU:

On Ubuntu/Debian:
bash
Copy code

Code: Select all

sudo apt-get install qemu-system-aarch64

Download a Raspberry Pi OS image from the official website.

https://www.raspberrypi.com/software/op ... os-64-bit

Create virtual sdcard with size 16GB and restore original Pi OS to new image:

Code: Select all

qemu-img create pipi.img 16G
Mount virtual sdcard image:

Code: Select all

modprobe nbd max_part=8
qemu-nbd --connect=/dev/nbd0 --format=raw pipi.img
Use gnome-disks to restore official 2024-10-22-raspios-bullseye-armhf.img.xz image and resize root partition of nbd0 to 16G.
Copy kernel8.img and bcm2711-rpi-4-b.dtb and place them on your host OS filesystem.

Unmount virtual sdcard image:

Code: Select all

qemu-nbd --disconnect /dev/nbd0
rmmod nbd


Use the following QEMU command to start the Pi4 emulation:

Code: Select all

qemu-system-aarch64 -machine type=raspi4b -m 2048 \
-smp 4,cores=4,threads=1,sockets=1 \
-cpu max \
-accel tcg,thread=multi \
-kernel /home/.../kernel8.img \
-dtb /home/.../bcm2711-rpi-4-b.dtb \
-serial stdio \
-usb \
-device usb-mouse \
-device usb-kbd \
-netdev user,id=net0,hostfwd=tcp::5022-:22 \
-device usb-net,netdev=net0 \
-drive "file=/home/.../pipi.img,id=mysdcard,if=sd,format=raw" \
-append 'root=/dev/mmcblk1p2 rootfstype=ext4 rootwait console=ttyAMA0,115200 loglevel=8'
It seems Pi4 has problem with USB emulation and the same configuration can be used for Pi3 that do not have problem with usb emulation it seems this is Qemu 9 problem . :roll:



Use the following QEMU command to start the Pi3 emulation:

Code: Select all

qemu-system-aarch64 -machine type=raspi3b -m 1024 \
-smp 4,cores=4,threads=1,sockets=1 \
-cpu max \
-accel tcg,thread=multi \
-kernel /home/.../kernel8.img \
-dtb /home/...bcm2710-rpi-3-b.dtb \
-serial stdio \
-usb \
-device usb-mouse \
-device usb-kbd \
-netdev user,id=net0,hostfwd=tcp::5022-:22 \
-device usb-net,netdev=net0 \
-drive "file=/home/.../pipi.img,id=mysdcard,if=sd,format=raw" \
-append 'root=/dev/mmcblk0p2 rootfstype=ext4 rootwait console=ttyAMA0,115200 loglevel=8'


Post Reply