WRT54G and OpenEmbedded

2009-07-24 17:00

Some time ago I bought a cheap `Linksys WRT54G`_ because I aquired a laptop with WiFi. It worked well enough, but being the technologist I am, I soon found out that the device ran an embedded Linux distribution, and that it was possible to replace the firmware with a more capable (if more arcane) variant. I did so, using OpenWRT_. I was quite satisfied with this distro, though wireless was flaky due to requiring the use of a proprietary 2.4 kernel-only Broadcomm driver for the wireless. To make a boring story as short as possible, I'm now using a separate device as an access point and using the WRT54G solely as a router.

Thus, I take my first stab at using a 2.6 kernel on the device, upgrading to a recent build of OpenWRT_. Unfortunately, I don't like what the project has done recently, and want less magic configuration. UCI seems like a nice system, but I just want what I'm used to when configuring a Linux system, a bunch of files in /etc. I don't need a unified syntax, I already know the tools and the configuration syntax for the functionality I need. I don't want to learn yet another specialized language for doing the same damn thing.

Don't get me wrong, I understand the need for UCI, I just don't have the same needs. (Dual-stack IPv6/v4 with firewalling and VPN, DNS and static DHCP leases, to start...) So I'm left with radically modifying the OpenWRT build system, or rolling my own.

So I turned to the OpenEmbedded_ project, which provides a customizable and flexible cross-build system for many targets, including the WRT54G.

Setting up OpenEmbedded

First things first, in order to build an image for the WRT54G, you need the OpenEmbedded_ build environment set up. Follow the `Getting Started`_ guide and come back when you're done.

Then, create a local.conf file with the appropriate values for the WRT54G:

BBFILES = "/stuff/openembedded/recipes/*/*.bb"
DISTRO = "wrt54oe"
MACHINE = "wrt54"

PREFERRED_PROVIDERS += " virtual/${TARGET_PREFIX}gcc-initial:gcc-cross-initial"
PREFERRED_PROVIDERS += " virtual/${TARGET_PREFIX}gcc:gcc-cross"
PREFERRED_PROVIDERS += " virtual/${TARGET_PREFIX}g++:gcc-cross"
PREFERRED_PROVIDERS += " virtual/${TARGET_PREFIX}binutils:binutils-cross"

Just to make sure everything is working, try building task-base:

$ cd /stuff/build/
$ bitbake task-base

This will take some time, so feel free to go do something else for a while.

I had this part fail several times, needing manual downloads, md5 corrections, etc. Your milage may vary.

Docutils System Messages

System Message: ERROR/3 (<string>, line 1); backlink

Unknown target name: "linksys wrt54g".

System Message: ERROR/3 (<string>, line 1); backlink

Unknown target name: "openwrt".

System Message: ERROR/3 (<string>, line 10); backlink

Unknown target name: "openwrt".

System Message: ERROR/3 (<string>, line 23); backlink

Unknown target name: "openembedded".

System Message: ERROR/3 (<string>, line 29); backlink

Unknown target name: "openembedded".

System Message: ERROR/3 (<string>, line 29); backlink

Unknown target name: "getting started".