How to Compile a 16-Year-Old OpenWrt on a Modern Linux System

Since I’ve always enjoyed tinkering with retro hardware (and partly out of nostalgia), I decided to revisit something I last did back in 2009 – building OpenWrt from source.

I still have a few old SparkLAN WX-7800A / Tonze AW-6660 devices lying around, which I once hacked to run Linux (my old page about it). They’re based on Atheros AR5312 (MIPS 4Kc V0.9).

The only things I had left were the old kernel image and an NFS root directory. Back then, I used to boot the kernel over TFTP and mount the root filesystem via NFS – much more convenient than flashing and dealing with limited onboard storage.

From the kernel banner I learned that I had been using OpenWrt Kamikaze (bleeding edge, r14600).
Fortunately, the official OpenWrt repository still preserves the old SVN history (massive respect to the maintainers for that!).

So locally, it boiled down to:

git clone git://git.openwrt.org/openwrt/openwrt.git
cd openwrt
git log | grep "SVN-Revision: 14600"
git checkout 26754768121227b2fb8ee44809192aaa032e7816

That gave me the exact tree from 2009.
Of course, trying to build it directly on a modern Linux system would almost certainly fail miserably – so I needed an environment from that era.

Here’s where ChatGPT came in handy – it pointed out that around the same time (mid-2009), Debian Lenny was the current stable release. I wondered if I could somehow run such an ancient Debian inside Docker… and surprisingly, yes! There’s a great image available called debian/eol.

I fired up a container like this (on my modern x86_64 host):

docker run -it --name openwrt-lenny --platform linux/386 -v "$(pwd)":/work debian/eol:lenny bash

(The --platform linux/386 flag was crucial – without it, Bash would just crash.)

Inside the container, it felt like stepping back in time:

apt-get update
apt-get install build-essential libz-dev ncurses-dev gawk bison unzip python wget subversion automake autoconf flex git-core

Then I created a regular user, switched to it, and ran:

cd /work
make menuconfig   # selected Atheros CPU
make V=99

Of course, there were still a few bumps along the way. The build system pointed to old source URLs, but thankfully OpenWrt used mirrors even back then, so most packages still downloaded fine. For the few that didn’t (like binutils), I manually grabbed the correct versions from the web and dropped them into the dl/ directory.

I also had to remove a few patches that no longer applied cleanly:

deleted: package/libpcap/patches/104-no_rej_files.patch
deleted: package/libpcap/patches/105-space_optimization.patch
deleted: toolchain/binutils/patches/2.17/500-avr32.patch
deleted: toolchain/binutils/patches/2.17/501-avr32-fix-pool-alignment.patch

The final hurdle was a failing patch in libpcap called wlan_filtering.patch.
I didn’t want to waste too much time debugging it, so I used a quick hack:

cp /dev/null build_dir/target-mips_uClibc-0.9.29/libpcap-0.9.8/wlan_filtering.patch
chattr +i build_dir/target-mips_uClibc-0.9.29/libpcap-0.9.8/wlan_filtering.patch
make -i
# interrupt, then resume
make V=99

And… it worked!
I successfully built a 2009-era OpenWrt system on a modern Linux host, cleanly and neatly, thanks to Docker – without polluting my main system with old dependencies.

Long live Docker, Debian EOL images, and all the folks who keep these old OpenWrt sources alive! 🧡

Leave a Reply

Your email address will not be published. Required fields are marked *