QEMU emulating Rasbian OS & running Minecraft-pi

This post is a run-down of my efforts to run minecraft-pi in an emulator of Raspbian OS in Windows 10.  While I was able to run Raspbian OS in both Virtual Box and QEMU, emulator limitations prevent minecraft-pi from running because Raspbian needs to use the raspberry pi GPU and the emulators do not provide support for that.

The error that I received when typing minecraft-pi in a terminal:

grep: /proc/device-tree/soc/v3d@7ec00000/status: no such file or directory ‘ failed to open vchiq instance

The reason that it won’t run as described from Raspi stackoverflow Dec 2016:
“The error message makes clear that Minecraft can’t find the Pi GPU since it’s not there. I’m pretty sure there is no way around that requirement either.”

Note that I had already tried Virtual Box and Minecraft-Pi wouldn’t start either. It’s been a few weeks since I went away from that so I don’t recall what the error was, but suffice to say, it didn’t work. I think the root cause was that virtual box was using an x86 emulator vs using an ARM emulator and some incompatibility there.

The reason that I wanted  run minecraft-pi in Raspbian in my Windows 10 pc was because I wanted to play around with minecraft-pi, python, and tkinter on my PC and then work w/ my son on the ‘real’ raspberry pi without being tied to the raspberry pi at a table in the kitchen. IE, it’s hard to take the Raspberry Pi w/ me on the airplane or other places. Not impossible, but not convenient. Also, I don’t think I want to go through the trouble of setting up minecraft-pi w/ raspberryjuice on my pc, either.  Since I had issues with the emulators, I think I’ll try VNC as described here https://www.raspberrypi.org/documentation/remote-access/vnc/ or simply use the PI itself.

I did try two things from this page:
[code]sudo usermod -a -G video $pi[/code]
and then I tried adding to boot/config.txt.
[code]start_x=1
gpu_mem=256[/code]
Then run sudo raspistill -o cam.jpg, but that didn’t seem to work either (after a reboot) and I don’t recommend them other than I wanted to try to get the system working.

NOTES from my QEMU Setup

I was able to get QEMU to run rasbian and very happy that I got it working. Here are some of the links and issues that I found out that I want to share. Files used:
image: 2017-11-29-raspbian-stretch.img
kernel: kernel-qemu-4.9.59-stretch
Qemu download: qemu-w32-setup-20181211.exe
At first I didn’t know which kernel to use, or even if the one I had was compiled, but if you search wikipedia and raspbian OS, there is a chart that shares linux kernel along with which release. That was helpful. In the example above, iimage 2017-11-29-raspbian-stretch uses linux Kernel 4.9.

Websites that helped:
https://github.com/dhruvvyas90/qemu-rpi-kernel
https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki
https://web.archive.org/web/20150326230511/http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
https://qemu.weilnetz.de/w32/
https://blogs.msdn.microsoft.com/iliast/2016/11/10/how-to-emulate-raspberry-pi/

I moved the image and kernel to the QEMU folder that was at C:\Program Files (x86)\qemu. I had unzipped the image with 7-zip. I also followed the instructions https://github.com/dhruvvyas90/qemu-rpi-kernel and included the versatile-pb.dtb file in the qemu folder as well.

There are 3 different pages that talk about how to write the commands in the windows cmd terminal to start qemu. I originally started with the one from a microsoft blog (about 2 years old) and ended up using the https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki github instructions from the same guy that has provided the kernels.

BRITISH KEYBOARD

Ugh, one of the first issues I ran into was to use the # symbol to comment out a line in /etc/ld.so.preload. But raspbian was setup with a GBR (Great Britain) locale and the british keyboard. So, the # symbol had switched to the british pound that looked like a squiggly ‘L’. I did find the # symbol later which happened to be the “\”. I solved this problem by writing down the line in a separate build log and deleting it from the ld.so.preload file (same as commenting it out). Note, there was only 1 line in that file anyway…

Also, the double quote ” and at symbol @ are swapped. At one point you need to add some double quotes ” for 3 lines similar to KERNEL==”sda”, SYMLINK+=”mmcblk0″. I found them by trial and error.

Ultimatley, you would change your locale to US, but I didn’t get around to that.   There were at least 2 different places that showed how to do that, of which I don’t have the link any longer.

qemu-system-armw vs qemu-system-arm

If I had more time, I’d like to figure out what the difference is between qemu-system-armw and qemu-system-arm. But, here were 2 observations:
1. qemu-system-armw did not give ANY feedback from the windows cmd line. So, when I first tried it, I didn’t know if it was working or not. When I switched to qemu-system-arm, I then got feedback about errors, like typing the image name incorrectly or other errors I needed to work around when first trying it.
2. Once I was comfortable starting qemu, when I used qemu-system-arm (no w), it appeared as though it was a terminal window to raspbian and while booting listed the many, many lines of information. I figured that’s why the qemu-system-armw (with a w) was created – to not have all that (I guess) unneeded output.

My take-away was to use qemu-system-arm when first starting and then switch to qemu-system-armw once I got qemu working. I’m not sure if it really mattered or not.

SUCCESS RUNNING QEMU

My takeaway was to use the steps here: https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki

I entered the following commands in the windows cmd tool after navigating to C:\Program Files (x86)\qemu. I had also moved the raspbian image, kernel, and versatile-pb files to the same folder C:\Program Files (x86)\qemu:
INITIAL BUILD
qemu-system-armw -kernel kernel-qemu-4.9.59-stretch -cpu arm1176 -m 256 -M versatilepb -dtb versatile-pb.dtb -no-reboot -append “root=/dev/sda2 panic=1 rootfstype=ext4 rw” -net nic -net user,hostfwd=tcp::5022-:22 -hda 2017-11-29-raspbian-stretch.img

RE-EMULATE BY RUNNING
qemu-system-arm -kernel kernel-qemu-4.9.59-stretch -cpu arm1176 -m 256 -M versatilepb -dtb versatile-pb.dtb -serial stdio -append “root=/dev/sda2 panic=1 rootfstype=ext4 rw” -drive “file=2017-11-29-raspbian-stretch.img,index=0,media=disk,format=raw” -net nic -net user,hostfwd=tcp::2222-:22

CONCLUSION

Both the virtual box and QEMU will emulate the rasbian OS in windows 10. However, not all features and programs are supported. Programs that need the GPU to run are not supported because the emulators currently don’t offer that support.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" extra="">