Recompiling the firmware

Asus provides everything required to recompile the firmware yourself.  Note that it can only be done under Linux, and will require some basic skills related to compiling stuff, and flashing your router.  There is also a distinct chance that you might brick your router by flashing it with a buggy/incorrect firmware.  You might be able to restore it by putting the router in recovery mode, but if that fails, a serial cable or JTAG might be your only way out.  So BE CAREFUL!

These are my notes regarding how I am recompiling the firmware.  My environment is a Virtualbox virtual machine running Ubuntu 10.04 LTS 64-bit.

I installed all the packages specified by Asus in the top-level README.txt (all through apt-get, no custom package at all).

 
I am doing everything as root (not recommended if this is an actual production machine, but this is a development VM so I go with what's simplest).
 
Only required the first time:
 
cd /root
untared the tarball inside /root (so, the sources are under /root/asuswrt/.....)
ln -s $HOME/asuswrt/tools/brcm /opt/brcm
export PATH=$PATH:/opt/brcm/hndtools-mipsel-linux/bin:/opt/brcm/hndtools-mipsel-uclibc/bin (this one is required every time you log in)
cd ~/asuswrt/release/src-rt
mkdir -p /root/asuswrt/release/src-rt/wl/sysdeps/default/linux
mkdir -p /media/ASUSWRT/
ln -s ~/asuswrt /media/ASUSWRT/asuswrt
 
This will set up your build environment, and create a few directories that are missing from Asus' tarball (and prevents it from properly compiling).
 
Now, to recompile the firmware:
 
cd $HOME/asuswrt/release/src-rt
make clean
make rt-n66u
 
Sometimes I get an error while it's recompiling iptables. I usually just re-run "make rt-n66u" and it works - possibly a missing dependency in the build environment that is resolved when you recompile a second time.
 
A few notes:
 
  • While you can run make menuconfig inside the router/ folder to configure build options, these will be overriden by the parent Makefile.  To enable or disable an option, you have to edit $HOME/asuswrt/release/src-rt/target.mak .  You can see the name of the available options by running make menuconfig from inside the router/ directory.
  • If you suspect you messed up something (like your config files), it's often simpler to untar again from the source tarball, and start all over.
  • Let me repeat it once again: there is a chance you will render your router useless if you are not careful here!