Thursday, September 16, 2010

bsdbox - take #1

One of the nice things about building embedded Linux "stuff" is busybox. The other is "uClibc", which isn't really the focus of this post.

I've fleshed out a basic busybox style thing based on the crunched binary stuff which generates sysinstall and the rescue binaries. Thankfully, most of the hard work (read: the hacks needed) are done for you - both in the rescue Makefile and the general FreeBSD build framework.

So, I give you "bsdbox" - a not-so-small static binary busybox style solution to help build a standalone image.

# ls -l /sbin/bsdbox
-rwxr-xr-x 1 0 0 2958668 Sep 16 17:44 /sbin/bsdbox

# /sbin/bsdbox

usage: bsdbox ..., where is one of:

ls cat dd df cp hostname kill mkdir sleep sh -sh dmesg sysctl init reboot

mount mdmfs mount_mfs mdconfig newfs ifconfig route ping true false hexdump

tail netstat chown chgrp arp hostapd hostapd_cli bsdbox


And with that, I have this TP-Link device happily running FreeBSD as a WPA-enabled wireless access point.

Combined with the GEOM uzip module, the entire filesystem (which is the above binary and a few shell scripts) - is just slightly above 1 megabyte in size. (geom_lzma will make that even smaller.)

The bsdbox stuff is in my GIT repository in "bsdbox". It's built as part of the base system and installed in /bsdbox/. The binary can then be cherry picked and built into an image with whatever symlinks are needed. There's more to do - more binaries for a start; but also making it a bit easier to configure bits than a single Makefile - but it's useful right now.

3 comments:

  1. Sounds like most of the size would be libc symbols?

    ReplyDelete
  2. Well I can certainly compare it to a non-static binding; there's just a lot of random libraries that are pulled in for one task or another.

    I'm hoping to use it as a bit of an excuse to kick the FreeBSD developers into seeing the sensibility in actually reusing things, rather than implementing new things in libraries that get used by only one program. Grr.

    ReplyDelete
  3. With -lc and -lm dynamic:

    -r-xr-xr-x 1 root wheel 2002312 Sep 18 08:06 /data/freebsd/mips/head/root-tplink/bsdbox/bsdbox

    I'll have to do some digging to find out exactly what footprint each of the above binaries have.

    ReplyDelete