Minggu, 25 Agustus 2013

Xathrya Sabertooth

Xathrya Sabertooth


Emulating Raspberry Pi using QEMU on Windows

Posted: 24 Aug 2013 06:18 AM PDT

Previously, we have discussed installation of various Raspberry Pi‘s Operating System. All have been done on the actual board. But what if we are in situation where we can’t afford the board? Emulation sure is the way to experiment and QEMU open the possibility.

Although emulation can make our life easy, you can’t always rely on emulation. Remember that emulation trying to imitate the real hardware, but can’t be the one.

In this article, we will discuss about how to emulate Raspberry Pi board using QEMU. For this purpose I use:

  1. Windows 8 64-bit as host system
  2. QEMU 1.4.0
  3. Soft-Float Debian Wheezy with version 2013-05-29.
  4. OpenVPN

For Linux machine, you can go to this article instead.

Obtain the Material

Make sure you have QEMU installed. On Windows, you can follow this article.

Next, download the images. As stated above, we will use Soft Float Debian Wheezy. You can download it from Raspberry Pi’s official download page. The version I use is the 2013-05-29 or latest version per August 24th 2013 and can be downloaded here.

We also require linux kernel for QEMU. Download it from here.

Download and install OpenVPN. This will add a TAP 32 network adapter.

The Hardware – Overview

Before we go to next section, it is always a good idea to understand what system we want to work with. In this case, raspberry Pi. You can see the Architecture of Raspberry Pi for detail.

For the system we will create in using QEMU:

  1. ARM1176JZF-S, see the datasheet here
  2. Ethernet

Note that QEMU cannot emulate GPIO and GPU.

Also, to encapsulate network we need TAP network for full networking support. See next section.

Preparing the environment

Create a working directory. In this case, qemu-raspberry.

Extract the disk image and kernel image we have downloaded on previous section.

Now open “Network and Sharing Center” and click “Change Adapter Settings” in the left menu.

Rename the TAP 32 network adapter to just TA32 and double click the adapter. Do the settings like this (adjust with your setting):

Now bridge the adaptor with an active connection with the TAP32 adapter.

Next create a file raspberry.bat and fill with following:

qemu-system-arm.exe -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda 2013-05-29-wheezy-raspbian.img -net nic -net tap,ifname=TAP32

Booting the disc image

Just double click the rasperry.bat and if you did correctly, you will get similar to this:

Emulating Raspberry Pi using QEMU

Posted: 24 Aug 2013 06:16 AM PDT

Previously, we have discussed installation of various Raspberry Pi‘s Operating System. All have been done on the actual board. But what if we are in situation where we can’t afford the board? Emulation sure is the way to experiment and QEMU open the possibility.

Although emulation can make our life easy, you can’t always rely on emulation. Remember that emulation trying to imitate the real hardware, but can’t be the one.

In this article, we will discuss about how to emulate Raspberry Pi board using QEMU. For this purpose I use:

  1. Slackware64 14.0 as host system
  2. QEMU 1.4.0
  3. Soft-Float Debian Wheezy with version 2013-05-29.
  4. OpenVPN

For Windows machine, you can go to this article instead.

Obtain the Material

Make sure you have QEMU installed. For Linux, you can follow this article to compile QEMU (using Slackware64 as example).

Next, download the images. As stated above, we will use Soft Float Debian Wheezy. You can download it from Raspberry Pi’s official download page. The version I use is the 2013-05-29 or latest version per “August 24th 2013″ and can be downloaded here.

We also require linux kernel for QEMU. Download it from here.

The Hardware – Overview

Before we go to next section, it is always a good idea to understand what system we want to work with. In this case, raspberry Pi. You can see the Architecture of Raspberry Pi for detail.

For the system we will create in using QEMU:

  1. ARM1176JZF-S, see the datasheet here
  2. Ethernet

Note that QEMU cannot emulate GPIO and GPU.

Also, to encapsulate network we need TAP network for full networking support. See next section.

Preparing the environment

Create a working directory. In this case, qemu-raspberry.

Now open up command prompt and enter the working directory.

Extract the disk image and kernel image we have downloaded on previous section.

Check whether you have /dev/net directory and /dev/net/tun or not. If you don’t have it yet, do following:

mkdir /dev/net  mknod /dev/net/tun c 10 200  /sbin/modprobe tun

Now create the two new files, /etc/qemu-ifup and /etc/qemu-ifdown. Make sure you give them executable permission.

#!/bin/bash  ETH0IPADDR=192.168.1.100  GATEWAY=192.168.1.1  BROADCAST=192.168.1.255    # First take eth0 down, then bring it up with IP address 0.0.0.0  /sbin/ifconfig eth0 down  /sbin/ifconfig eth0 0.0.0.0 promisc up    # Bring up the tap device (name specified as first argument, by QEMU)  /usr/sbin/openvpn --mktun --dev $1 --user `id -un`  /sbin/ifconfig $1 0.0.0.0 promisc up    # Create the bridge between eth0 and the tap device  /usr/sbin/brctl addbr br0  /usr/sbin/brctl addif br0 eth0  /usr/sbin/brctl addif br0 $1    # Only a single bridge so loops are not possible, turn off spanning tree protocol  /usr/sbin/brctl stp br0 off    # Bring up the bridge with ETH0IPADDR and add the default route    /sbin/ifconfig br0 $ETH0IPADDR netmask 255.255.255.0 broadcast $BROADCAST  /sbin/route add default gw $GATEWAY

and

#!/bin/bash    # Bring down eth0 and br0  /sbin/ifconfig eth0 down  /sbin/ifconfig br0 down    # Delete the bridge  /usr/sbin/brctl delbr br0    # Bring up eth0 in "normal" mode  /sbin/ifconfig eth0 -promisc  /sbin/ifconfig eth0 up    # Delete the tap debice  /usr/sbin/openvpn --rmtun --dev $1

Make sure you already have openvpn installed.

Booting the disc image

Make sure the TAP interface have been activated. You just need activated it once and use it until you had enough. Do following:

/etc/qemu-ifup tap0

To boot the QEMU, invoke following command (make sure all materials have been downloaded and extracted):

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb \  -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda 2013-05-29-wheezy-raspbian.img \  -net nic -net tap,ifname=tap0,script=no,downscript=no

When you decide to stop TAP interface, do following:

/etc/qemu-ifdown

Here’s the result:

pi_qemu_linux

Tidak ada komentar:

Posting Komentar