Last week we wrote about the Raspberry Pi, a single-board computer running Linux. The (pre-)orders of the Raspberry Pi will start end January – mid February. Because of that, yes we are impatient for this new Linux computer, we will show you how to emulate the Raspberry Pi with the help of QEMU under Debian. So this guide will work on every Debian-based distribution.
- A computer running Debian with a graphical UI
- around 4gb of free space on your hard drive
- We assume that you run every command as root, so ‘su’ before you begin!
First, we need a recent version of QEMU, which is provided by the experimental and the unstable package-releases of debian so we will edit our sources.list. To do so, open up a terminal and enter the following:
nano -w /etc/apt/sources.list
This will show up your sources which you use to install new packages. Add the following two lines to it:
deb http://ftp.belnet.be/debian experimental main deb http://ftp.belnet.be/debian unstable main
We use a Belgian source, you can always use a source closer to your country as long as they have the unstable and experimental Debian packages. Next, we will update our package list and install QEMU.
apt-get update apt-get install qemu-system -t experimental
Getting the R-Pi files
Now we will download the kernel and a Debian root filesystem which were made by the author from CNXSoft.
wget http://dl.dropbox.com/u/45842273/zImage wget http://dl.dropbox.com/u/45842273/rootfs.ext2.gz gzip -d rootfs.ext2.gz
The last command will extract the gzip file. If you don’t have installed gzip do an ‘apt-get install gzip’ and try the last command again. So the final thing to do is to emulate the R-Pi, we will do this by running the following command:
Booting Raspberry with QEMU
qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -hda rootfs.ext2 -kernel zImage -append "root=/dev/sda" -serial stdio
An explanation of this last command might be useful:
- qemu-system-arm: the command to emulate a arm system
- -M versatilepb: the machine we need to emulate
- -cpu arm1176: the cpu we need to emulate
- -m 256: the amount of memory that the R-Pi has (256 for model B)
- -hda rootfs.ext2: the file which contains the filesystem
- -kernel zImage: the kernel which we use
- -append “root=/dev/sda”: we mount our root filesystem to /dev/sda in the emulated R-Pi
- -serial stdio: redirect the serial port to the standard input output device
Once the command is executed, your freshly emulated Raspberry will boot. Once done, it will ask you for login details which are the following:
login: root password: raspberry
Once you’ve logged into the Raspberry Pi you notice that it is enforced that you have to change your current password every time you login. To only update your password every 30 days, type the following in the R-Pi console:
chage -d 30 root
We all love apt-get install to install packages in debian, but we need the right repository. So we need to edit the sources.list on the R-Pi, so ‘nano -w /etc/apt/sources.list’ and paste the following in it:
deb http://ftp.belnet.be/debian squeeze main
Do an ‘apt-get update’ and an ‘apt-get upgrade’ so that we have a package list and our system is up-to-date.The next thing we need to do is to set the system clock right. If we don’t do that, we will get errors like ‘error: newly created file is older than distributed files!’ while you are running some ./configure’s. To do so, we install ntp, the linux network time protocol.
apt-get install ntp
Now you’re ready to start programming for the Raspberry Pi!Tags: Debian, hardware, linux, QEMU, R-Pi, raspberry pi