-
Notifications
You must be signed in to change notification settings - Fork 364
Home
Dhruv Vyas edited this page Oct 20, 2023
·
23 revisions
Emulation is a necessary aspect of embedded system development and QEMU is the right open source tool to do so for linux based SBCs.
To emulate RPi on QEMU, you will need these two files.
- RPi kernel,
- RPi rootfs (which would be a second portion of official .img file).
If you want to emulate newer jessie images with 4.x.xx kernel from this repo, you should prepare your image as per given on this Emulating-Jessie-image-with-4.x.xx-kernel.
- Ubuntu (generally, any OS based on Debian):
sudo apt-get install qemu
- OS X:
brew install qemu
-
Windows:
Grab the latest QEMU from official Download page.
Once QEMU is installed and you have necessary files for emulation as mentioned above, follow the following steps to emulate RPi.
- Run:
qemu-system-arm -kernel kernel-qemu \
-cpu arm1176 \
-m 256 \
-M versatilepb \
-no-reboot \
-serial stdio \
-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" \
-hda image-file-name.img
You should get #
prompt (bash) at the end of processing.
- Edit
/etc/ld.so.preload
by commenting (with # symbol) the 1st line, e.g.:
# /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
#
# ... rest of the file
- Edit
/etc/udev/rules.d/90-qemu.rules
by adding the following lines:
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"
- Run:
sudo poweroff
- Re-emulate by running:
qemu-system-arm -kernel kernel-qemu \
-cpu arm1176 \
-m 256 \
-M versatilepb \
-serial stdio \
-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
-drive "file=image-file-name.img,index=0,media=disk,format=raw"
- You can have maximum ram upto 256 only as there's a bug in versatilepb which doesn't allow to emulate more than 256 MB.
- You might want to set up ssh by adding this extra flag while using QEMU:
-net nic -net user,hostfwd=tcp::2222-:22
Hope it helps.