Before we start the painful process of trying to build an entirely new firmware from source code ourselves, let's make sure we can at least build the Asus firmware using the tools and source they provide.

  1. Start with the massive GPL zip file you get from Asus. When you unpack it, you'll have a toolchain tarball and a GPL tarball. (Said tarball is temporarily mirrored here)
  2. Unpack the toolchain tarball into /opt, so that it becomes /opt/brcm/.... The path is significant -- GCC toolchains must be built specifically to live in a particular filesystem location, and this cross-toolchain is built to live in /opt/brcm.
  3. Unpack the "GPL" "source" tarball wherever you like. It presumes that it will be live in /root/WL700g, but one of the first things we're going to do is fix that so that it can be built from wherever you want, and doesn't have to be built as root. I put "GPL" and "source" in quotes because a lot of the stuff in that tarball is not source code and is not under the GPL. For example, the real-time-clock chip (as far as I can tell) has two source files, only one of which is present in source form at all (the other is a precompiled binary object file), and that source file is not under GPL anyway. Once you have unpacked the tarball, change all the directories to be writeable with something like: find . -type d -exec chmod 775 {} \;
  4. Ensure that you have the program ash available. I installed dash 0.5.3, which I got from here. I've also used ash 0.4.0, but it doesn't build very easily on modern systems.
  5. You also will need a program rcsclean because it is invoked during the build process. This is part of RCS, an ancient version control system that nobody should ever use any more. I worked around the need for this program by creating an empty bash script that just returns 0 (success).
  6. Add the MIPS cross-toolchain binaries to your PATH with: export PATH=/opt/brcm/hndtools-mipsel-linux/bin:$PATH
  7. Change directory to the nasoc/src/apps directory. There is a README_ASUS there that reveals that the process to build the firmware image is make rebuild && make image-WL700gE
  8. Some files have the build directory path /root/WL700g hard-coded, which is absurd. Fix this in all of the *.pc files. If you've unpacked the bundle into $HOME/src you can do this with: for file in $(find . -name "*.pc"); do cp $file{,.orig}; sed -e "s/\/root\//\/home\/$USER\/src\//" $file > $file.new; mv $file.new $file; diff $file.orig $file; done;
  9. Delete all the .depend files under busybox. find ./busybox -name ".depend" -exec rm {} \;
  10. Execute make clean.
  11. Now you need to ensure that the tarfiles (in the tarfiles subdirectory) have the right privileges on their contents. (Initially they don't.) So:
    1. pushd mipsel
    2. you don't need install.rc3 at all: rm -rf install.rc3
    3. tar xzvf ../tarfiles/install.tar.gz
    4. tar xzvf ../tarfiles/exinstall.tar.gz
    5. popd
    6. find . -type d -exec chmod 775 {} \;
    7. make clean (yes, again)
  12. There are several places where Makefiles try to run mkcramfs. I don't have one of those; I have mkfs.cramfs instead. If that's your situation as well, you can either create a mkcramfs symlink or modify the relevant Makefiles: Makefile, mfgtest_root/Makefile, and pivot_root/Makefile. Also make sure that the program is on your PATH!
  13. The build process creates a file /usr/local/bin/ez-ipupdate. That's right! It installs a MIPS cross-compiled binary onto the host system. This is the sort of thing that leads me to do my builds as a non-root user. Modify ez-ipupdate/Makefile so that the commands in the install and install-am targets start with echo.

At this point, the make rebuild and make image-WL700gE commands completed for us without error. Give it a try. You should find yourself with a mipsel/WL700gE_1.0.4.6.nas when it completes.

If you get a segmentation fault when running generate_igpayatinlay -- this has happened to me from time to time, and I do not understand why -- you can work around it:

  1. pushd translation_database
  2. run ./generate_igpayatinlay ../www/translate_EN.txt ../www/translate_JP.txt_utf8 "Japanese" > igpayatinlay_sources_jp.c until that succeeds
  3. run a similar command for Taiwanese (TW) if necessary
  4. Save the generated igpayatinlay_sources_??.c files by renaming them
  5. Modify the Makefile so that it copies the files back to the expected igpayatinlay_sources_??.c names rather than re-running generate_igpayatinlay
  6. popd
halle:~ eric$ cat dload/ez-ipupdate_Makefile.patch 
--- ez-ipupdate/Makefile.orig   2006-11-22 18:07:12.000000000 +0100
+++ ez-ipupdate/Makefile        2006-11-22 18:07:53.000000000 +0100
@@ -300,9 +300,9 @@
 install-data-am:
 install-data: install-data-am
 
 install-am: all-am
-       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+       echo @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 install: install-am
 uninstall-am: uninstall-binPROGRAMS
 uninstall: uninstall-am
 all-am: $(PROGRAMS)
@@ -312,10 +312,10 @@
 installdirs:
        $(mkinstalldirs)  $(DESTDIR)$(bindir)
 
 install: $(PROGRAMS)
-       install -D ez-ipupdate $(INSTALLDIR)/usr/sbin/ez-ipupdate
-       $(STRIP) $(INSTALLDIR)/usr/sbin/ez-ipupdate
+       echo install -D ez-ipupdate $(INSTALLDIR)/usr/sbin/ez-ipupdate
+       echo $(STRIP) $(INSTALLDIR)/usr/sbin/ez-ipupdate
 
 romfs:
        $(ROMFSINST) /bin/ez-ipupdate
 
halle:~ eric$