install qemu
pamac install qemu-system-aarch64
unpack raspios
xz -d 2022-09-22-raspios-bullseye-arm64.img.xz
check in fdisk partitions
fdisk -l 2022-09-22-raspios-bullseye-arm64.img
mount boot partition to get the files
mkdir /media/raspberriet
sudo umount /media/raspberriet/
sudo mount 2022-09-22-raspios-bullseye-arm64.img -o offset=$((8192*512)) /media/raspberriet/ # <-- put offset here that you found using fdisk
enable ssh and setup default user on the raspberry
sudo touch /media/raspberriet/ssh
openssl passwd -6 # generate password with this tool
sudo touch /media/raspberriet/userconf.txt # create file to put in username and password
echo "pi:$6$9Yvl.a74RAkVKrRA$XqnHn0VOP2qLc9A/XiTY8wl/djB84kyi0de4nzqSPLZzx2bi2Ej0/zDcwJUWP28AYnHOZ.Vu.5gP84gX3wfHC/" > /media/raspberriet/userconf.txt #default user = pi, pass = raspberry
sudo cat /media/raspberriet/userconf.txt
convert the sd card image to qcow2 for qemu
qemu-img convert -f raw -O qcow2 2022-09-22-raspios-bullseye-arm64.img raspberry.qcow2 # <- maybe first unmount the boot partition but i don care
qemu-img resize raspberry.qcow2 4G # resize it so that its proper size
create a file with the script to run the raspberry pi image in qemu:
#!/usr/bin/env bash
sudo qemu-system-aarch64 -kernel /media/raspberriet/kernel8.img \
-M raspi3b \
-cpu cortex-a72 \
-dtb /media/raspberriet/bcm2710-rpi-3-b-plus.dtb \
-m 1G -smp 4 \
-no-reboot \
-serial stdio \
-append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1 rootfstype=ext4 fsck.repair=yes rootwait" \
-sd raspberry.qcow2 \
-usb -device usb-mouse -device usb-kbd \
-device usb-net,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::5555-:22 \ # this should give you an ssh port to connect to
start qemu with the script
./start-rpi.sh
find out how to get this performant, figure out a way to make the gui work, check /boot/cmdline.txt
https://raduzaharia.medium.com/system-emulation-using-qemu-raspberry-pi-3-4973260ffb3e
https://azeria-labs.com/emulate-raspberry-pi-with-qemu/
https://farabimahmud.github.io/emulate-raspberry-pi3-in-qemu/