Building Linksys WRT54G images from source
That’s my goal today. Linksys released source for their WRT54G among other access points that run Linux. I’m going to attempt to build an image.
I grabbed the 1.42.2 firmware version, which oddly they don’t have an
image up for on their site yet. Read the top level README.TXT and
followed its instructions up to type 'make dep' at which point it
failed:
/nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/linux/linux/scripts/mkdep -D__KERNEL__ -I/nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/linux/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -I /nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/linux/linux/include/asm/gcc -G 0 -mno-abicalls -fno-pic -pipe -nostdinc -iwithprefix include -- offset.c > .depend realpath(/nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/linux/linux/include/asm/gcc) failed, No such file or directory make[2]: *** [fastdep] Error 1 make[2]: Leaving directory `/nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/linux/linux/arch/mips/tools' make[1]: *** [_sfdep_arch/mips/tools] Error 2 make[1]: Leaving directory `/nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/linux/linux' make: *** [dep-files] Error 2
(No effort made to wrap the above, sorry.) It looks like it wants
asm/gcc. There is include/asm-mips/gcc and
include/asm-mips64/gcc. So I’ll just ln -s asm-mips
include/asm and… that seems to have fixed the above error. So
we’re moving on.
While my machine is running make dep I’ll go ahead and mention
that the default configuration for the kernel it builds is in
arch/mips/defconfig-bcm947xx. Also, check out
WRT54G/release/src/router/rc for a good time. Lots of interesting
stuff in there that I’m guessing is performed on boot by the Linksys.
Since I’m giving out links,
http://www.seattlewireless.net/index.cgi/LinksysWrt54g is a great
source for information on this device, including information on how to
stick a serial console on it and some promising-sounding TFTP stuff.
So now make dep is done, and I’m on to make in the
release/src directory (per instructions).
Now that’s chugging so I have more time to talk. It looks like
Broadcom basically makes this whole device for Linksys, more or less.
Linksys brands it and ships it out, basically. All the stuff here
that was made by anyone appears to have been made by Broadcom, except
for maybe the “ASP” files (HTML)… which were probably made by
Broadcom and hacked on just enough by Linksys to make it look like
theirs. In release/src/router/config (I think) there’s what looks
like a hacked-up kernel menuconfig for configuring features on the
Broadcom device.
I will now wait patiently (yeah right) for this to complete. I hope
ccache is doing its thing. Cache misses increasing along with files
in cache/cache size. (Thanks Nightwolf for telling me about
watch. Try watch -d -n 1 ccache -s.)
Oops:
mipsel-uclibc-ld -r -o .pppoecd magic.o fsm.o lcp.o ipcp.o upap.o pppoehash.o pppoe_client.o libpppoe.o main.o auth.o options.o demand.o utils.o sys-linux.o pppoe.o md5.o chap.o md4.o chap_ms.o /home/darkness/usr/lib/libcrypt.a /opt/brcm/hndtools-mipsel-linux/bin/mipsel-linux-ld: cannot open /home/darkness/usr/lib/libcrypt.a: No such file or directory make[2]: *** [pppoecd] Error 1 make[2]: Leaving directory `/nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/router/ppp/pppoecd' make[1]: *** [ppp] Error 2 make[1]: Leaving directory `/nfs/verin/array0/home/darkness/tmp/wrt54g/WRT54G/release/src/router' make: *** [all] Error 2
Now where did it get that path? I’m able to run make from
WRT54G/release/src/router and get the same result. Somewhere in
there something is defaulting to my home directory. Ah,
$(TOOLCHAIN) is coming out to be /home/darkness, probably
because I’ve got the ccache links for the compilers in
/home/darkness/ccache-bin and it appears to assume the toolchain
root is the parent of that directory. Set TOOLCHAIN for both
mipsel-linux and mipsel-ulibc and we’re in business again. Build
continues. Actually, I’m going to make clean then make again
just in case those bad paths were mucking anything up.
Oops, to make clean make sure you have RCS installed. It uses
/usr/bin/rcsclean. make again and a bunch of stuff goes by
real fast. The real test of whether ccache was working or not. (It
was. Duh.)
[darkness@verin release]$ ls -l image total 5588 -rw------- 1 darkness darkness 2855936 Oct 19 16:01 code.bin -rw-rw-r-- 1 darkness darkness 2854912 Oct 19 16:01 linux.trx
Voila. Now I don’t know if I have the balls to flash it. I wonder if I can TFTP boot it.
Hey, thanks! That was just what I needed. Seriously, my wife hates this Linux stuff and has GOT to have her 802.11g. You saved me much marital discord.
Comment by Colin from Bklyn — Sunday, 22 May 2005 @ 21:37:27