![]() |
IntroductionAs the Linksys WAG354G wireless ADSL router uses the same CPU core, endianess, kernel version and uClibc version as the WL500G it occured to me that it might be possible to run the executables from the WL500G optware feed on it. The minor fly in the ointment was the lack of any form of remote login capability hence the first step had to be creating a modified version of the firmware. I decided I wanted to take a similar approach to Unslung, modifying the original functionality as little as possible while adding the new function I wanted. How to get Optware on WAG354GThe WAG354G doesn't have any way of adding a local disk so /opt has to be on some form of remote disk (I've chosen NFS, Samba is probably possible but the lack of true unix permissions might cause some problems). If you only want one or two programs you could just copy them to the RAM disk.
1. Using an already-built firmwareNeptune354 is a firmware for WAG354G and HG200 routers, that contains all the needed stuff required by Optware. InstallationOnce you have flashed Neptune354 firmware on your router, you can automatically mount a NFS folder at boot, using the web interface (Administration->Utility). Known IssuesThe command
2.Build your own firmware from sources.The ToolchainLinksys included a minimal tool chain in the old UK firmware version ( One huge gotcha with the Linksys supplied toolchain is that the copy of linux/atm.h in the toolchain doesn't match the one in the kernel which prevents PPPoA from working. Copy Modifying the firmwareI used the EU 1.01.05 release as the basis for my modified firmware. My firmware changes fall into 6 categories:
Adding NFS support to the kernelIn the kernel directory (
TODO: see if there is room to add NBD support as well to allow for a remote host to be used to provide swap space - swapping over NFS requires extensive kernel patching. Adding facilities to uClibc that Linksys chose to omitunpack the uClibc archive in
and change the kernel source directory to point at where you have unpacked the kernel source. Build uClibc and copy the resulting Warning: I'm still running a firmware version where I failed to include the floating point support before doing this and I've got the FP capable uClibc in Adding a remote login capabilityLinksys did include most of what you need for remote login but then disabled it. To turn what they did back on you need to edit 2 files in src/cy_conf.h 25,26c25,26 < #define CLI_SUPPORT 1 < #define CONFIG_CLI y --- > //#define CLI_SUPPORT 0 <remove the line> > //#define CONFIG_CLI n <remove the line> src/cy_conf.mak 26,27c26,27 < CLI_SUPPORT=1 < CONFIG_CLI=y --- > #CLI_SUPPORT is not set <remove the line> > # CONFIG_CLI is not set <remove the line> You then need to comment out the bit around line 211 in
15c15
< fprintf(passwd,"%s:0:0::/tmp:/bin/sh\n",crypt(nvram_safe_get("http_passwd"),"Zi"));
---
> fprintf(passwd,"%s:0:0::/tmp:/bin/configurator\n",crypt(nvram_safe_get("http_passwd"),"Zi"));
17c17
< fprintf(passwd,"%s:0:0::/tmp:/bin/sh\n",crypt(nvram_safe_get("http_remote_passwd"),"Zi"));
---
> fprintf(passwd,"%s:0:0::/tmp:/bin/configurator\n",crypt(nvram_safe_get("http_remote_passwd"),"Zi"));
Adding an ability to specify a command to run at rebootIn order to automate starting up with Optware available you need to be able to specify an action to run at boot. The normal Linux startup script is actually a binary in the read only file system so we need to change this binary to grab a command to run from NVRAM.
--- rc/rc.c 2006-03-02 23:06:03.000000000 +0000
+++ ../../../clean/WAG354G-EU-v1_01_05-004/src/router/rc/rc.c 2005-08-25 10:04:16.000000000 +0100
@@ -85,20 +85,4 @@
extern unsigned int firstsetlanip;
-static void doScript(void)
-{
- if (fork() == 0)
- {
- char * cmd;
- sleep(5);
- cmd=nvram_get("boot_command");
- if ((cmd != NULL) && (strcmp(cmd,"boot_command") != 0))
- {
- system(cmd);
- }
- exit(0);
- }
-
-}
-
static void restore_all_pvc_defaults(void)
{
@@ -599,5 +583,4 @@
cprintf("now insmod tiatm\n");
eval("insmod", "tiatm");
- doScript();
for (;;) {
Making busybox support mounting NFS sharesNFS support is useless if we can't run a mount command so we need to change the busybox command to support mount src/router/busybox/Config.h 86c86 < #define BB_MOUNT --- > //#define BB_MOUNT 257c257 < #define BB_FEATURE_NFSMOUNT --- > //#define BB_FEATURE_NFSMOUNT Creating a /opt directory (The root file system uses squashfs which is readonly)Add the line "mkdir -p opt" to the end of src/router/misc/rootprep.sh Build the firmwareJust follow Linksys's instructions. Note that the symlink to cy_codepattern.h in the kernel includes directory sometimes ends up broken after multiple rebuilds, just create a new one. Install the firmwareIf anything goes wrong with your new firmware you'll need to use the bootloaders upgrade capabilty. It isn't as easy to prove this works for you as it is with unslung but at least make sure you've got the rigth programs installed. To do an upgrade via the bootloader instead of using the web interface do
Mount your /opt directoryLog in to your upgraded router and type
and then reboot. host needs to be specified in dotted decimal form as DNS may not be usable when this command runs. Set up ipkg on /optYou need to build ipkg itself and also a couple of busybox utilities that you are likely to need. The version of wget in busybox 0.60 which is what is in the firmware doesn't support http redirect which is needed by the Optware feeds mirror system so rather than upgrade the stock busybox I chose to put a new busybox in /opt. In order to make ipkg live in /opt, keep all its data in /opt and use /opt/tmp as its temp directory (necessary otherwise large packages can fill the RAM disk) you need to make some patches to ipkg. I used ipkg V0-99-148 as a base version with the diffs below..
Index: ipkg_cmd.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_cmd.c,v
retrieving revision 1.103
diff -r1.103 ipkg_cmd.c
238c238
< tmp = strdup ("/tmp/ipkg.XXXXXX");
---
> tmp = strdup ("/opt/tmp/ipkg.XXXXXX");
Index: ipkg_conf.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_conf.c,v
retrieving revision 1.78
diff -r1.78 ipkg_conf.c
106c106
< char *etc_ipkg_conf_pattern = "/etc/ipkg/*.conf";
---
> char *etc_ipkg_conf_pattern = "/opt/etc/ipkg/*.conf";
Index: ipkg_conf.h
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_conf.h,v
retrieving revision 1.34
diff -r1.34 ipkg_conf.h
32c32
< #define IPKG_CONF_DEFAULT_TMP_DIR_BASE "/tmp"
---
> #define IPKG_CONF_DEFAULT_TMP_DIR_BASE "/opt/tmp"
Index: update-alternatives
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/update-alternatives,v
retrieving revision 1.4
diff -r1.4 update-alternatives
24c24
< ad="$IPKG_OFFLINE_ROOT/usr/lib/ipkg/alternatives"
---
> ad="$IPKG_OFFLINE_ROOT/opt/lib/ipkg/alternatives"
Then to actually configure and build ipkg type ./configure CC=mipsel-uclibc-gcc --host=mipsel-*-linux --prefix=/opt LD_FLAGS=-Wl,-rpath,/opt/lib@@ make make install DESTDIR=/tmp/ipkg cd /tmp/ipkg/opt tar cf ../ipkg.tar . and unpack the tar file in /opt (generally it is easier to do this on the NFS host) To build busybox I used version 1.1.0 which now uses make menuconfig. Edit the configuration to cross compile with a compiler prefix of mipsel-uclibc- and disable all of the commands and shells except wget, sed and umount. Type Finally you need to configure feeds so create /opt/etc/ipkg/wl500g.conf with the contents
view ·
edit ·
print ·
history ·
Last edited by fcarolo.
Based on work by fcarolo, cyberstorm, and Adam Baker. Originally by Adam Baker. Page last modified on February 05, 2008, at 08:07 PM
|