Daniel Fišer, 2007-02-19

NB: This documentation is not updated anymore. It's shown for archive purpose only. See http://www.drakeworld.net/blogs/drakeblog for Drake's follow-up.

This article describes my hacking of ASUS WL-600g All-in-1 Wireless ADSL2/2 + Home Gateway. All the information are provided without any warranty. Make sure you know what you are doing before commiting any changes to your ASUS WL-600g.


Contents


Prerequisites

You need a Unix machine to cross-compile firmware for ASUS WL-600g. Root access is required by ASUS make script.

This guide describes custom cross compilation based on GPL source code for ASUS WL-600g firmware version 1.0.2.8B for German, Czech, and Nordic. The firmware was compiled on the following machine:

>$ name -privs
Linux 2.6.19-1.2911.fc6 #1 SMP Sat Feb 10 15:51:47 EST 2007 i686 i386

>$ cat /etc/fedora-release
Fedora Core release 6 (Zod)

Standard GPL firmware build

  1. Install compatibility compiler and libraries for gcc 2.96 and 3.3.4 – see below for installed libs.

    >$ rpm -qa | grep compat
    compat-libgcc-296-2.96-138
    compat-libstdc++-296-2.96-138
    compat-libstdc++-33-3.2.3-61
    
  2. Download GPL source code for ASUS WL-600g's firmware.[1] Unzip the GPL_WL600g_1028B.zip archive, unzip the GPL_WL600g_1028B.tar.gz tarball and run consumer_install.

    Install uclibc-based cross compilation RPMs:

    >$ sudo rpm -Uvh uclibc-crosstools-*rpm

    You need to create symlink for every file in /opt/toolchains/uclibc-crosstools/bin:

    >$ cd /opt/toolchains/uclibc-crosstools/bin
    >$ for A in mips-linux-uclibc-* ; do
    > sudo ln -s ${A} mipsel-uclibc-${A#mips-linux-uclibc-}
    > done
  3. Apply the cur_menu.patch:[2]

    >$ cd /opt/bcm963xx
    >$ patch -p0 <cur_menu.patch
  4. Make the firmware:

    >$ make PROFILE=96348GW

Kernel customization

The kernel is preconfigured: the /opt/bcm963xx/kernel/linux/.config file is copied upon every build from /opt/bcm963xx/kernel/linux/arch/mips/usb_defconfig. Edit the latter file to customize kernel.

I have managed to compile kernel with ext2 support; ReiserFS support was reported to work too.[2]


Custom program build

You must prepare your environment prior to any additional software compilation. Create an environment setting script, for example in /opt/bcm963xx:

>$ cat /opt/bcm963xx/environment
TOOLCHAINS_HOME=/opt/toolchains/uclibc-crosstools

export LIBS="-L${TOOLCHAINS_HOME}/lib/gcc/mips-linux/3.4.2"
export INCLUDES="-I${TOOLCHAINS_HOME}/include/c++/3.4.2 \
	-I${TOOLCHAINS_HOME}/mips-linux/sys-include \
	-I/opt/bcm963xx/kernel/linux/include"
export CFLAGS="${INCLUDES} ${LIBS} -static"
export LDFLAGS="-static"
export CC="${TOOLCHAINS_HOME}/bin/mipsel-uclibc-gcc"

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${TOOLCHAINS_HOME}/lib
export PATH="${PATH}:${TOOLCHAINS_HOME}/bin"

Set the environment before you execute any configure or make command.

>$ . /opt/bcm963xx/environment

Samba compilation

My goal is to run samba and share externally attached harddisk. I have not tried to include samba into firmware, but prefer to run it from external harddisk.

  1. Download samba source code, unpack and patch it (I used samba 3.0.24):

    >$ wget ftp://mirrors.dotsrc.org/samba/samba-3.0.24.tar.gz
    >$ tar zxvf samba-3.0.24.tar.gz -C /opt/bcm963xx/userapps/opensource/samba-3.0.24
    >$ rm -f samba-3.0.24.tar.gz
    >$ cd /opt/bcm963xx/userapps/opensource/samba-3.0.24
    >$ wget http://www.samba.org/samba/patches/fetch-patches
    >$ sh ./fetch-patches 3.0.24
    >$ for PATCH in patches/*.diff; do patch -p1 <${PATCH}; done
    >$ cd ..
    >$ mv samba-3.0.24/source ./samba
    >$ rm -rf samba-3.0.24
  2. Apply the samba-cross_compile.patch patch to samba:[3]

    >$ patch -p1 <samba-cross_compile.patch
  3. Configure samba:

    >$ ./configure --host=mipsel-linux --target=mipsel-linux \
    	--without-automount --without-sendfile-support --with-included-popt \
    	--with-included-iniparser --disable-cups --without-sys-quotas --without-ads \
    	--enable-statis=yes --enable-shared=no \
    	--prefix=/var/harddisk/asus/samba
  4. Patch config.h:[4]

    >$ CFG="include/config.h"
    >$ echo "#define SIZEOF_INT 4"              >> ${CFG}
    >$ echo "#define SIZEOF_LONG 4"             >> ${CFG}
    >$ echo "#define SIZEOF_SHORT 2"            >> ${CFG}
    >$ echo "#define HAVE_GETTIMEOFDAY_TZ 1"    >> ${CFG}
    >$ echo "#define USE_SETEUID 1"             >> ${CFG}
    >$ echo "#define HAVE_IFACE_IFCONF 1"       >> ${CFG}
  5. Make samba:

    >$ make
  6. Install samba:

    >$ sudo make install
  7. Strip binaries:

    >$ cd /var/harddisk/asus/samba/bin
    >$ sudo /opt/toolchains/uclibc-crosstools/bin/mipsel-uclibc-strip *
    >$ cd /var/harddisk/asus/samba/sbin
    >$ sudo /opt/toolchains/uclibc-crosstools/bin/mipsel-uclibc-strip *
  8. Copy samba to an USB disk:

    >$ cp -prL /var/harddisk/asus/samba/* /media/USB/asus/samba/
  9. Do not forget to create /var/harddisk/asus/samba/var/smb.conf file.

Now it's time to mount your USB disk to ASUS WL-600g, login to the box and start nmbd and smbd daemons.

TODO: The ultimate goal is either to include samba in the firmware or, unless possible, to tweak the firmware to start custom program upon inserting an external USB disk. Any suggestions are welcome.


Links

[1] ASUS WL-600g support page
http://support.asus.com/download/download.aspx?model=WL-600g
[2] OpenWrt ASUS forum: WL-600g
http://forum.openwrt.org/viewtopic.php?id=7355
[3] "configure cannot test when cross-compiling" should be ok
http://www.mail-archive.com/bug-guile@gnu.org/msg03794.html
[4] Samba list: How to cross compile samba source
http://lists.samba.org/archive/samba/2004-May/085334.html
[5] SLUG Mailing List Archives: statically linked versions of samba and cups
http://lists.slug.org.au/archives/slug/2004/06/msg00507.html
[6] OpenWrt forum: compiling on OpenWRT router natively
http://forum.openwrt.org/viewtopic.php?id=4411
copyright © 2000–2016 Daniel Fišer (XHTML 1.1 & CSS)