(14/06/2009) The Bifferboard

Recently, I bought a Bifferboard. It’s in fact a tiny embedded computer based on a processor x86. More specificaly, it’s a 486SX (150Mhz), with 1 USB 2.0 port and 1 ethernet port (+ 2 to 6 GPIOs). One of the main assets of this computer is its electric consumption of 1 Watt. In my case, it makes a big difference with my personnal computer (1KW). One of its other assets is its price: About 50 euros.

Currently, I’m using it to wake up remotly my personnal computer and as a DHCP/DNS cache server. However, since there are GPIOs, I may use later it for some other crazy projects of mine :)

Basics


Zoom

The Bifferboard has 1MB of flash, and 32MB of RAM. On the flash memory, there are the BIOS (BiffBoot) and a basic Linux kernel (2.6.27.5 on mine) configured to boot directly on /dev/sda1. Since this kernel has USB controller and USB mass storage device support, /dev/sda can be any kind of USB device (USB key or USB hard drive). Bifferos, Bifferboard creator and vendor, also provides a firmware based on OpenWRT and its source. However, I’m a Debian user, and so the first question I asked myself was: "What would happen if I put a Debian on my USB key and boot on it ?". As you can guess, it worked. You don’t even have to reflash the kernel. The way I did it is a little bit ugly on some points, but as long as it works, who cares ? :)

The first step should be to have a working official Bifferos firmware.

Bifferos firmware

Generating the official firmware and puting it on an USB key is pretty easy. Just read the README provided with it.

If, like me, you plan to use your BifferBoard without serial cable, don’t forget to read these instructions.

Once you have your firmware on your USB key (ie, an ext3 fs on your key), the next step is to test it. Qemu can be very helpful to figure out answers to questions like "why the hell this thing doesn't work?".

Testing your USB key rootfs in Qemu

Bifferos website mentions shortly how to simulate a BifferBoard in Qemu. However, as they say, Qemu simulates a UHCI USB controller instead of an OCHI one like the one on the Bifferboard. Same problem for the network device. Two solutions:

In very short:

$ cd ~/tmp
$ wget http://bifferos.planetlee.eu/bifferboard/bb-src-1.4.tar.bz2
$ tar -xvjf bb-src-1.4.tar.bz2
$ cd bb-src-1.4
$ make -j8 # core i7 rules !
# first build that will also take care of downloading all the OpenWRT stuff we
# may need
$ make kernel_menuconfig
[activate UHCI support (must be in hard in the kernel, not as a module)]
[activate ne2k_pci support (in hard, it's easier to manage)]
$ make -j8 remake V=99

From this point, you should have your kernel in ./openwrt/bin/openwrt-bifferboard.bzImage.

Next, follow the instructions on the bifferos website to merge the kernel with the Bifferos BIOS and start Qemu with the correct invocation. Note: Qemu needs direct access to your USB key, so either you change the permissions on the USB device (not /dev/sda !) or you start Qemu as root.


The bifferboard in its plastic case

Debian running on a BifferBoard

Usually, I would be the first one to grumble about the fact that all Debian packages are built for 386/486, but in this specific case, it makes our life much easier.

What to do:

From this point, unmount your USB key (but don’t unplug it) and test in Qemu to see what happens. If it boots as expected, your can plug it on your Bifferboard. It usually takes a long time to boot on the Bifferboard (about 1 or 2 minutes) and even more if you killed your Qemu savagely since the Bifferboard will have to do a full FS check at boot time then.

Optionnally, I suggest you put /tmp, /var/run and /var/log on a tmpfs (file system in RAM) to not write too often on your USB key.

In the end, your fstab will look like that:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/sda1	/		ext3	defaults,errors=remount-ro	0	1
tmpfs		/tmp		tmpfs	defaults,size=64k 0 	0
tmpfs		/var/log	tmpfs	defaults,size=1m	0	0
tmpfs		/var/run	tmpfs	defaults,size=128k	0	0

with a script /etc/rc2.d/S01mnt:

#!/bin/sh
touch /var/log/dmesg
mkdir /var/log/apt
mkdir /var/run/network

# If lighttpd:
mkdir /var/log/lighttpd
mkdir /var/run/lighttpd
chown -R www-data:www-data /var/log/lighttpd

# If dbus
mkdir /var/run/dbus

# If sudo
mkdir /var/run/sudo

Have fun :-)