Emulating Arch Linux For the Raspberry Pi in QEMU

Emulating Arch Linux For the Raspberry Pi in QEMU

In my last post about QEMU I showed how easy it was to emulate the Raspberry Pi in Windows. If you are just getting started with the Pi, that is the way to go. Personally, I prefer to use Arch Linux over Debian. There is nothing wrong with Raspbian, I am just used to how Arch Linux works. But, emulating Arch Linux under QEMU is not that simple. To start, not everything can be found in one easy download package. But, I worked through the problems and here are the instructions:

  1. To start,you will need a working QEMU working Rasbian to modify the Arch Linux img file. Follow the instructions in this post to get Raspbian running.
  2. Next, download QEMU 1.6 from QEMU FOR WINDOWS (52MB). Extract in a different location from the Rasbian install.
  3. Download the latest Linux kernel for QEMU from http://xecdesign.com/downloads/linux-qemu/kernel-qemu NOTE: http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/ has some great information about QEMU and the Raspberry Pi
  4. Download the latest Arch image from http://archlinuxarm.org/platforms/armv6/raspberry-pi
  5. Before we boot the Arch image we are going to make a few changes to the img file. One, it needs to be bigger and have a swap partition and two, the way the Arch image specifies the boot partition does not work with QEMU. We need to modify the /etc/fstab to make it work.
  6. Add 2 GB of space to the fake SD card with the following command (in Windows)
    qemu-img <Arch img filename> resize +2G
  7. Next, we will add the Arch img as a second drive in Rasbian. Add the following to the BAT file that starts the Rasbian QEMU session
    -hdb ArchLinuxARM-20##.##-rpi.img
    Add the correct date code for you file. That addition puts the Arch img on /dev/sdb when you start Rasbian.
  8. Start Rasbian. Watch the messages to see that the sdb partitions are now available. Don’t worry if the message go by too quickly, the next step can also check.
  9. Now create the swap partition. Login and use
    sudo fdisk /dev/sdb and create a linux swap partition. Detailed instructions are here. The next step shows how to edit the fstab to make the swap used at boot.
  10. Next, we will mount the Arch partition and edit the fstab. Do the following:
    sudo mkdir /mnt/arch
    sudo mount /dev/sdb5 /mnt/arch
    sudo nano /mnt/arch/etc/fstab
  11. In fstab, change the /boot line from /dev/mmcblk0 to /dev/sda1
  12. Add the following as the list line to activate swap on boot
    /dev/sda3 none swap defaults 0 0
  13. Save fstab, exit nano and umount /mnt/arch.
  14. Halt Rasbian and move the Arch img file to the QEMU 1.6 install directory
  15. Arch can be started with the following command
    qemu-system-armw.exe -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda5 panic=1 rootfstype=ext4 rw" -hda ArchLinuxARM-2014.02-rpi.img
  16. All should start and you can log in with username root and password root
  17. Check your swap with
    free -m

You’re done. You new have a QEMU system emulating Arch Linux. Update Arc with pacman to get all of the latest goodness.

Easy IO Controll With BerryIO

Easy IO Controll With BerryIO

One of the most interesting aspects of the Rasberry Pi is the general purpose input/output port (GPIO) that makes interfacing easy. Generally speaking, there are 17 pins that are available for use on the pin header. These pins can be input or outputs and are very easy to control and read from both the command line or program. But, what if you need some quick and dirty to test the new hardware you are developing. You don’t want write a script or program just to check on your new hardware’s IO. Well, that is where BerryIO can help. BerryIO is a program that lets you remotely control and monitor the GPIO ports via a web page. You can select the input/output state of each pin and the output level. For the inputs, you can monitor the level of each pin – all through a web browser. BerryIO also gives you control over an LCD if you have one connected, there are some simple system tools, SPI system and camera controls.

A video demo can be found here.

BerryIO can be downloaded from GitHub

Unlocking the power of the Raspberry PI GPU

The CPU of the Raspberry Pi is a slow moving, general purpose device. Don’t get me wrong, it is an amazing combination of price, low energy use and flexibility. But, The Graphical Processing Unit (GPU) in the Pi is downright amazing. It can convert a compressed video and pump it out to the screen at the same resolution of a Blu-Ray player. But the GPU is limited to specific number crunching activities and it isn’t very flexible.

Up until this point the GPU has been a black box. The features were restricted to graphics processing for items on screen. But no longer. Andrew Holme has created a Fast Fourier Transform (FFT) library using the GPU. Most engineers know what a FFT is and they know, computing a FFT is mathematically complex. If you’re not an engineer, the FFT takes a signal (sound for example) and splits it up into the frequency parts. It is similar to the spectrum analyzers found on stereos.spectrum The sound is split into the different frequencies and the level or volume of each frequency is shown. The left is usually the low end and it is easy to see the beat of the bass drum as the left bars shoot up. Using the GPU for FFTs on the Pi gives between a 5x-12x speed improvement.

Unless you are planning on building a software based radio or adding a spectrum analyzer to you streaming media server, this may not sound like big news but the FFT library is only the start. Unlocking the GPU means that more libraries are coming. To start, I expect that the Pi will get some audio altering filters so your playback can get effects like “concert hall” fond on high end receivers. Also, I expect that someone will build a GPU based transcoder allowing the PI to recode audio ad video without having to move that task to a higher powered device. Lastly, everyone knows the best bitcoin miners use GPUs. Look for new bitcoin libraries soon.

Instructions to install the FFT routines can be found here.

Connecting a Wii Controller to the Raspberry Pi

Connecting a Wii Controller to the Raspberry Pi

Normally you control a computer with a keyboard and mouse. But, the the purpose of a Raspberry Pi is to invent something new. To that end, you have have to come up with some new, creative ways to get information into the RPi. The Wii controllers are a miracle of engineering and communicate to the Wii (and whatever else you would like) using Bluetooth. Using a USB Bluetooth interface and some simple programming you can use the Wii controller as an input for whatever you need. Check out this video:

If you need more information on the subject, see the Brian’s Life Blog. Also, I will be posting a follow-up on how to connect the balance board.

Emulate the Raspberry Pi in Windows for free

Emulate the Raspberry Pi in Windows for free

With the QEMU software you can run a a Raspberry Pi emulator in Windows for free. QEMU is an open source application for creating virtual hardware. It is similar to VMWare and Virtual Box. Where it differs is that it can CPUs and they have created a virtualization for the Raspberry Pi CPU (the ARM1176JZFS). Also, all the required tools and kernel tweaks have been made and collected into a single downloadable package. The whole package is available here: http://sourceforge.net/projects/rpiqemuwindows/

(more…)

What is the Raspberry Pi

What is the Raspberry Pi

Simply put, the Raspberry Pi is a low end computer. It doesn’t have any secret technology. It wasn’t put together by NASA. It doesn’t have MIT patents. It was the idea of four guy from the University of Cambridge’s Computer Laboratory to put affordable computes into the hand of kids to help them learn how to program.

Based on off-the-shelf parts, the Raspberry Pi is a credit=card sized computer that is designed to be tinkered with. Plug in a USB keyboard and mouse and a HDMI display and it will start Linux. It doesn’t boast high speed or a great graphics but it does offer low cost and the ability to ‘add’ features and hardware (to hack it). See the hardware pages for detailed information about how to add hardware.