Search this site


Metadata

Articles

Projects

Presentations

soekris adventures

So for this new part-time job I've got, I'm working on a Soekris net4501. FreeBSD has some surprisingly cool support for these things thanks mostly to [email protected]'s work. Now that I've managed to get a slimmed down version of freebsd built and running (7.3meg world, 2.2 meg kernel) of a pxe boot, I've had a chance to actually play with the darned thing.

The first thing I noticed was /dev/led/error. You can do

echo 1 > /dev/led/error

and viola! The error led on the board is on. This device supports quite the array of syntax you can throw at it. For instance, I can do

echo "f1" > /dev/led/error

and the error led will start blinking. Read led(4) if you care to know more about the rest of the syntax it supports (it'll even handle morse code from running /usr/games/morse -l).

I also discovered there was support for the GPIO pins on the board, too. This is done through the same /dev/led interfaces. To enable one of the pins as a device, you fudge around with the machdep.elan_gpio_config sysctl and you'll end up with devices such as /dev/led/gpio5. Neato! More about the GPIO-specific stuff here:
http://lists.freebsd.org/pipermail/freebsd-current/2003-November/014700.html

So far so good, I've got a usable shell with most tools I use (short of gcc and gdb) in 8.7 megs.

# df -h
Filesystem    Size    Used   Avail Capacity  Mounted on
/dev/md0       19M    8.7M    8.8M    50%    /

Since it's less than 10 megs, I have it mounted in memory instead of nfs. Doesn't hurt too much, seeing as how the board has 64 megs of ram, and with everything booted and me logged in I have 26 megs free.

Speaking of disk size, /usr/bin/host is a whopping 1.1 megs. That's quite large for dynamically linked binary. However, I think it was statically linked against libbind or something silly. Either way in the final product it'll go away, shaving more disk usage off.

This project has been a grand adventure into freebsd's world build system. My whole time working on this has been me writing one makefile. The way it works is fairly slick, I think. First, it generates a 20 meg vnode-backed filesystem, then builds a bunch of things from /usr/src and installs them to that new filesystem. Once this is done, I clean out some unnecessary files like library archives (.a files), worthless things in /usr/share, etc. The kernel is handled much in the same way, doing make buildkernel in /usr/src and then plopping a new kernel.gz in /tftpboot.

The cool part is how libraries are built. The makefile builds all the necessary binaries, installs them, and then uses ldd(1) to look for library dependencies. With this list of required libraries, it builds each required library from /usr/src and installs those. To make things easier to work with, I have two other make targets that let me test the system in both a jail(8) and chroot(8). This soekris board is so cool :)