How to emulate Raspberry Pi Raspbian with QEMU?
You should expand the Raspbian Image file before starting
Mount the Raspbian Image file with kpartx (might have to install kpartx)
$ sudo kpartx -av your-image.img
add map loop0p1 (252:5): 0 117187 linear /dev/loop0 1
add map loop0p2 (252:6): 0 3493888 linear /dev/loop0 118784
$ sudo mount /dev/mapper/loop0p2 /mnt/img1
$ cd /mnt/img1
Modify the /etc/fstab and comment out the MMCBLK mounts
$ sudo nano etc/fstab
proc /proc proc defaults 0 0
#/dev/mmcblk0p1 /boot vfat defaults 0 2
#/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
Modify /etc/ld.so.preload and comment out lines ...
$ sudo nano etc/ld.so.preload
#/usr/lib/arm-linux-gnueabihf/libarmmem.so
Unmount and destroy loops from kpartx
$ sudo umount /mnt/img1
$ sudo kpartx -d your-image.img
Get the Qemu kernel matching the Raspbian image here...
https://github.com/dhruvvyas90/qemu-rpi-kernel
I used this command to successfully emulate Raspbian Jessie
qemu-system-arm -kernel kernel-qemu-4.4.12-jessie -cpu arm1176 -m 256 -M versatilepb \
-no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
-redir tcp:5022::22 \
-hda 2016-05-27-raspbian-jessie-lite.img
How to emulate the Raspberry Pi 2 on QEMU?
If you're comfortable building qemu, you can find support for pi2 system emulation here: https://github.com/0xabu/qemu. It's not particularly speedy, and the device emulations are incomplete, but you can resize the RAM and framebuffer.
There are brief instructions for booting Raspbian at the end of https://github.com/0xabu/qemu/wiki
Is there a Raspberry Pi hardware emulator that supports custom ISOs?
For most of the complex hardware (i.e. CPU, GPU, RAM, network cards, disks and so on), qemu has you covered, there also seem to be a --machine raspi3b
flag that's supposed to be close to a Raspberry Pi 3B but I can't find any information about what is included exactly.
If you want to emulate some other raspi, you can use qemu-system-aarch64 --machine help
to list all 64bits ARM devices that can be emulated by qemu (note that as of writing this, qemu has no support for the raspi4).
If the emulation offered by qemu doesn't include some hardware you want, a lot of things can be emulated using dummy kernel modules such as the GPIO mockup driver as explained here and the mac80211_hwsim module. It's probably not as close to the hardware as you'd like though, if you prefer a more hands on approach you could create qemu "hardware" to be a perfect replica of the pi.
Related Topics
Loading Linux Text File into Excel Using Vba
How to Set Environment Variables on Ec2 Instance via User Data
Microsecond Accurate (Or Better) Process Timing in Linux
Svn: Ignoring an Already Committed File
Problems Installing R on Linux Centos 6.2
Split Files Based on File Content and Pattern Matching
Have 5 Scripts Running at Any Given Time
How to Disable or Change the Timeout Limit for the Gpu Under Linux
How to Change the Mime Type of a File from the Terminal
Where Does Output of Print in Kernel Go
Why Doesn't "History | Vim" Work
Scripts Launched from Udev Do Not Have Display Access Anymore