Emulating Raspbian /Noobs on qemu

This is an article on how to setup QEMU as an ARM emulator and hence install Raspbian or Noobs as the OS for a Raspberry Pi, this was stumbled upon when i wanted a Raspberry Pi emulator for a passion project I had thought about.

A Raspberry Pi is a small computer circuit board that has WiFi, HDMI, USB, RAM, CPU and takes it’s OS on a memory card, it is good for projects that don’t need a lot of computing power. Raspbian / Noobs is a Linux like flavor of operating system built on Debian.

Steps

1- Download Rasbian Image, click Raspbian downloads
qemu-img.exe resize 2015-02-16-raspbian-wheezy.img +10G
2. – Download qemu ARM emulator, click QEMU Emulator
3. – Download qemu ARM kernel, click QEMU Kernel download
4. – user 7zip on the qemu.exe file and extract it
5. – Powershell to the qemu directory and expand the rasbian image – This command gets the image and expands it to 10GB, think of it like a drive partition

command: qemu-img.exe resize 2016-09-23-raspbian-jessie.img +10G
The error below might appearĀ  it is okay, notice at the end it says Image resized

capture
PS E:\Software\qemu> .\qemu-img.exe resize .\2016-09-23-raspbian-jessie.img +10G
WARNING: Image format was not specified for ‘.\2016-09-23-raspbian-jessie.img’ and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the ‘raw’ format explicitly to remove the restrictions.
Image resized.
PS E:\Software\qemu>

6. – Create a startup batch file, i.e. using notepad create a new file and save as “startup.bat”, keep the quotes so the extension is .bat in the qemu dir, – this assigns the book Kernel, CPU type, drive parition mount point, shell and image
qemu-system-arm.exe -kernel kernel-qemu-4.4.13-jessie -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append “root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash” -hda 2016-09-23-raspbian-jessie.img
7. – Click on startup.bat to start the emulation
8. – I got the error:

error libstdc++-6.dll was missing, i downloaded it from here and all started fine
9. – Edit the /etc/ld.so.preload file, you can use the nano Or vi editor: nano /etc/ld.so.preload and add a # at the beginning
10. – Exit nano, press ctrl+X, then press y for “Yes”, to save the changes, and Enter, to overwrite the file.
11. – Create a new file and open it in edit mode, nano /etc/udev/rules.d/90-qemu.rules
12. – Add the following lines; This adds Rasbian rules that are loaded at start, in particular for symbolic links for the drive sda, please note that this is the same drive passed in the command above in step6 (sda2)

90-qemu-rules
KERNEL==”sda”, SYMLINK+=”mmcblk0″
KERNEL==”sda?”, SYMLINK+=”mmcblk0p%n”
KERNEL==”sda2″, SYMLINK+=”root”
13. – Exit nano, press ctrl+X, then press y for “Yes”, to save the changes, and Enter, to overwrite the file.
14. – Type exit to exit the editor
15. – Edit batch file in step6 again and remove init=/bin/bash, leave the quote at the end of the word bash then doubleclick it to startup the emulator again, this will remove the starting of the shell “/bin/bash” and load the gui instead
16. – The GUI should load and you are good to go

screen2

You may also like...

Popular Posts