The WG302 Prosafe is a Netgear router (mostly used as a simple access point) based on the Intel IXP425 XScale SoC This old router can very well run the latest Linux kernels. The resident flash is a bit small (just 8MB) but the RAM is 32MB on the WG302 v1 which makes the kernel work fine. The ethernet is just 100Mbit so your router socket LED will be yellow and it's no speed monster.
Installing a recent OpenWrt
The flash memory on this device is too small to fit both the kernel and the root filesystem for OpenWrt. What we need to do is to just have the root filesystem on the device, and load the kernel over TFTP. It's pretty straight forward to set up an environment like this, provided you know how to operate a TFTP server on your network which is stable.
- These images are from OpenWrt trunk and not yet stable upstream.
- Download openwrt-ixp4xx-generic-netgear_wg302v1-squashfs-kernel.bin and place it in the root of your TFTP server
- Download openwrt-ixp4xx-generic-netgear_wg302v1-squashfs-rootfs.bin and place it in the root of your TFTP server
- The router has an accessible RS232 connector, connect it using a zeromodem cable and set the terminal to 9600n8 (9600 baud, no stopbit, 8 bit)
- Plug in the power cable
- When you see text on the terminal, hit CTRL+C to get into RedBoot
- fis list - you should see a big image named ixp425, which is what we want to replace with an OpenWrt rootfs
- Make sure ixp425 starts at 0x50060000 and the size is 0x00600000!
- Before we move to the next step: where we load the image, RedBoot will say how big the file is.
Notice this, and use it for the -l argument to fis write below!
For example if reading the command says:
Raw file loaded 0x00080000-0x0043ffff, assumed entry at 0x00080000
then the length is 0x440000-0x00080000 = 0x003c0000. This is important so the remaining flash blocks can be used for other stuff. - Download the rootfs image, delete the ixp425 partition and create a new partition named rootfs
in its place, then flash the new rootfs into it (obviously use IP addresses appropriate for your
network):
ip_address -l 192.168.1.35 -h 192.168.1.2 load -r -v -b 0x00080000 -h 192.168.1.2 openwrt-ixp4xx-generic-netgear_wg302v1-squashfs-rootfs.bin fis unlock ixp425 fis delete ixp425 fis create -b 0x50060000 -l 0x00600000 -s 0x00400000 -f 0x50060000 -e 0x01600000 -r 0x50060000 -n rootfs fis list fis write -f 0x50060000 -b 0x00080000 -l 0x003c0000 fis lock rootfs
- The rootfs is now flashed into the device!
- You can test to boot the kernel and mount the new rootfs (the kernel literally looks for a
FIS image named rootfs):
load -r -v -b 0x00080000 -h 192.168.1.2 openwrt-ixp4xx-generic-netgear_wg302v1-squashfs-kernel.bin exec 0x00080000
- On subsequent re-flashes of the rootfs you do not need to recreate the FIS image, but again
make sure to check the length of the rootfs image:
ip_address -l 192.168.1.35 -h 192.168.1.2 load -r -v -b 0x00080000 -h 192.168.1.2 openwrt-ixp4xx-generic-netgear_wg302v1-squashfs-rootfs.bin fis unlock rootfs fis erase -f 0x50060000 -l 0x00600000 fis write -f 0x50060000 -b 0x00080000 -l 0x003c0000 fis lock rootfs
- Wait until the JFFS2 filesystem if fully initialized, the console will say something
like
[ 160.488142] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0 [ 160.605605] jffs2_build_filesystem(): unlocking the mtd device... [ 166.379199] done. [ 166.438285] jffs2_build_filesystem(): erasing all blocks after the end marker... [ 208.824658] done. [ 208.844284] jffs2: notice: (2258) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) [ 209.273407] overlayfs: upper fs does not support tmpfile.
- We want to use the WG302 as a bridge AP over ethernet (see below) as obviously it has
just one ethernet port and no routing capabilities.
For now, jist disable pointless, unused or harmful services, particularly
odhcpd is important to disable lest
it will interfere with your existing DHCP server and make your network behave
bad:
service dnsmasq disable service dnsmasq stop service odhcpd disable service odhcpd stop service firewall disable service firewall stop
- Once we have booted successfully once we can set up a boot script to always
download a kernel using TFTP and boot it:
fc -l fc (type in the following) ENTER (set Run script at boot: true) Enter script, terminate with empty line >> load -r -v -b 0x00080000 openwrt-ixp4xx-generic-netgear_wg302v1-squashfs-kernel.bin >> exec 0x00080000 >> oot script timeout (1000ms resolution): 2 Use BOOTP for network configuration: false Gateway IP address: 192.168.1.1 Local IP address: 192.168.1.35 Local IP address mask: 255.255.255.0 Default server IP address: 192.168.1.2 Configuration File Name: config.bin Console baud rate: 9600 DNS server IP address: GDB connection port: 9000 Force console for special debug messages: false Main FW File Length: 0x600000 Main FW File Name: wg302.rmt Network debug at boot time: false Default network device: npe_eth0 Product Name: 0000
The IP addresses and so on are just what I use, you have to set this up of course. You can use BOOTP if you have a BOOTP server etc. - I then configure the device as a "bridged AP over ethernet" for use in addition to the main router etc.
- The wireless config is important to get right, the following should for example work,
then you can work your way to what you want:
config wifi-device 'radio0' option type 'mac80211' option path 'soc/c0000000.pci/pci0000:00/0000:00:02.0' option band '2g' option channel '5' option htmode 'NOHT' # option disabled '1' config wifi-iface 'default_radio0' option device 'radio0' option network 'lan' option mode 'ap' option ssid 'My New AP' option encryption 'psk2' option key 'mypassword'
- It's easy to test the wireless by issuing e.g. iwinfo phy0-ap0 scan and some local AP:s should show up.
EXPERIMENTAL STUFF
EXPERIMENTS: initially I tried to do things the other way around: boot the kernel from the flash and have to rootfs on NFS. This never worked, and that's when it finally dawned on me that I have to do things the other way around: boot from TFTP (which is usually simpler to set up than NFS anyway) and have just the rootfs on the flash. This was a bad idea but the notes are kept here anyway.
Booting from command prompt
- The router has an accessible RS232 connector, connect it using a zeromodem cable and set the terminal to 9600n8 (9600 baud, no stopbit, 8 bit)
- Plug in the power cable
- When you see text on the terminal, hit CTRL+C to get into RedBoot
- Set up a TFTP server for downloading the kernel image
- Make sure that you have a bootable zImage on your TFTP server
- Boot the kernel using the interactive command prompt (the local 192.168.1.x IP addresses
are just examples from my network):
ip_address -l 192.168.1.35 -h 192.168.1.2 load -r -v -b 0x00080000 -h 192.168.1.2 zImage exec 0x00080000
Pre-cooked Bootable Image
These images are pre-configured for the WG302 ATH5k wireless etc.
NFS mounted root
The way I imagined this to be used is that we augment RedBoot to use TFTP to boot a kernel with initramfs on power-on, then mount root on NFS. The flash could fit the XZ-compressed kernel with initramfs though: it is just ~3MB.
First I set up NFS on my server. I use an /etc/exports file like this:
/var/lib/tftpboot/ixp4xx-root 192.168.1.0/255.255.255.0(rw,sync,no_root_squash,no_subtree_check,no_acl,nohide)
I unpack a rootfs to /var/lib/tftpboot/ixp4xx-root and change the permissions:
cd /var/lib/tftpboot mkdir ixp4xx-root cd ixp4xx-root tar xvfz /tmp/ixp4xx-rootfs.tar.gz
My rootfs has been modified to handle NFS mounts, it is not a vanilla OpenWrt. Also building for IXP4xx BE is not currently possibly other than on custom branches. This is achieved using this script.
I have tried to get NFS root mount to work but didn't get it finished. I added a patch like this to the WG302v1 device tree:
--- a/arch/arm/boot/dts/intel-ixp42x-netgear-wg302v1.dts +++ b/arch/arm/boot/dts/intel-ixp42x-netgear-wg302v1.dts @@ -23,7 +23,7 @@ memory@0 { chosen { /* The RedBoot comes up in 9600 baud so let's keep this */ - bootargs = "console=ttyS0,9600n8"; + bootargs = "console=ttyS0,9600n8 root=/dev/nfs rw nfsroot=192.168.1.144:/var/lib/tftpboot/ixp4xx-root,tcp,v3 ip=dhcp"; stdout-path = "uart1:9600n8"; };
Compiling the kernel
I use a special ixp4.mak makefile that I put in the root of the kernel directory, edit the makefile to select the right DTB then I type:
make -f ixp4.mak config && make -f ixp4.mak buildAnd this will build the whole kernel, attaching an initramfs and a DTB file, and put the resulting zImage in $HOME as well as in /var/lib/tftpboot if it is writeable. You will need the rootfs-ixp4x.cpio rootfs and ixp4xx-firmware.tar.gz for this to succeed.
The special config options used to mount from NFS:
# This target has 64MB RAM and no space for initramfs, use NFS root! config-wg302: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable PHYLIB \ --enable NFS_FS \ --disable NFS_V2 \ --enable ROOT_NFS \ --disable BLK_DEV_INITRD