Running Debian on ASUS WL-500G deluxe
From WPKG | Open Source Software Deployment and Distribution
You can run Debian (mipsel port) on ASUS WL-500g Deluxe, ASUS WL-500g Premium, ASUS WL-700gE, Linksys WRTSL54GS (and probably on similar, mipsel-based routers). See also a separate page for running Debian on ASUS WL-500W.
ASUS WL-500g Deluxe is a small router with 200 MHz CPU, 32 MB RAM, 5 ethernet ports, wireless.
Its newer version, ASUS WL-500g Premium has a 266 MHz CPU. With these specs, they are easily capable to run a small web or mail server. Being totally silent (no fan, no hard disk) is a clear advantage.
There is also a model with a HDD, and 64 MB RAM - ASUS WL-700gE. It will run Debian as well, however, a custom OpenWrt build is required since it has only 2MB Flash, and a small userspace is required to partition and format the HDD before Debian is installed. It has also only been tested with a hand created Debian image created by debootstrap.
A nice thing about this is that you don't need to open your device (and connect via serial cable etc.), but also that you can run "pure" Debian (not in a chroot jail as suggested on some other pages).
Note that you will need an external storage, like a USB-stick or a USB hard disk.
Contents |
[edit] Installation for impatient
Basic Debian installation (SSH server, cron, dhcp/DNS server, ADSL/ppp, several kernel modules loaded etc., no optimizations) takes below 10 MB RAM. This leaves about 20 MB free for your favourite applications, and even more if you use swap.
To make Debian run on your ASUS WL-500g Deluxe or Premium, you need to do three things:
- flash the kernel,
- write Debian base system on your USB device,
- configure the network.
You can download the kernel and the base system below.
[edit] Flashing the kernel
The kernel image was built using OpenWRT buildroot (kamikaze, revision 6580 from 2007-Apr-03). It is 2.6.19.2, and has built-in SCSI, USB and ext3 support (to be able to boot from USB devices).
To flash the image, use tftp. Start tftp program, and point it to the IP of your ASUS device. Press the "restore" (WL-500gP), or "reset" (WL-500gD) button, and power on your device. Then, upload the image.
For ASUS WL-500g Deluxe, use "openwrt-brcm-2.6-jffs2-64k.trx" image. For ASUS WL-500g Premium, use "openwrt-brcm-2.6-jffs2-128k.trx" image.
For ASUS WL-700gE a stripped down image will need to be used, build unnecessary packages as modules including fdisk, e2fsprogs, tune2fs. This has been tested using the squashfs image.
# tftp 192.168.1.1 tftp> binary tftp> trace Packet tracing on. tftp> put openwrt-brcm-2.6-jffs2-64k.trx (...)
[edit] Writing Debian on your USB device
Download Debian base system (below), and uncompress it to the /dev/sda1, ext3-formatted partition, (so that you have /bin, /etc and all other directories at the top-dir of this partition). Make sure to use tune2fs on /dev/sda1 partition:
# tune2fs -c0 -i0 /dev/sda1
so that USB stick is not checked by e2fsck - otherwise, the device might not boot at all!
WARNING!
When I said use tune2fs, I meant it:
Will now check root file system:fsck 1.40-WIP (14-Nov-2006) [/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a -C0 /dev/sda1 /dev/sda1: Superblock last mount time is in the future. FIXED. /dev/sda1: Superblock last write time is in the future. FIXED. /dev/sda1 has gone 49710 days without being checked, check forced. /dev/sda1: ***** REBOOT LINUX ***** /dev/sda1: 9030/56224 files (0.6% non-contiguous), 167947/224876 blocks fsck died with exit status 3 failed! * The file system check corrected errors on the root partition but requested that the system be restarted. * The system will be restarted in 5 seconds.
This means, your system will loop endlessly after checking the filesystem. This is because these devices don't have a battery-backed clock/rtc.
Make a small swap partition on /dev/sda2. Don't forget to run mkswap on it, otherwise, the system will not use it.
You can also create your own base system from scratch using Debian's debootstrap utility on your PC.
On the ASUS WL-700gE this can be done on the internal hard disk. use net cat to pipe the tarball across the network and uncompress it onto the hard disk.
[edit] Configuring network
You will have to configure your network in the following files:
- /etc/network/interfaces - configure your network
- NOTE! By default, SSH listens on 192.168.10.55 and 192.168.11.178, so make sure to change the network settings appropriately.
- /etc/resolv.conf - configure DNS
- /etc/hostname - the hostname of your machine
[edit] Booting
After you flash the kernel, write Debian to your USB device and configure the network, you can boot your ASUS to a fully-working Debian.
It doesn't matter which USB port you choose (unless you connect more devices).
You can log in via SSH, or consoles: USB or serial (check /etc/inittab to see console settings). If you didn't change the network settings, SSH listens on 192.168.10.55 and 192.168.11.178 (available via LAN or WAN interfaces, so check both before reporting problems).
The default password for the "root" user is "toor", and of course you are encouraged to change it.
[edit] More information
The base system is about 170 MB (it contains some other tools like ssh-server, mc or iptraf, and that's why it's slightly bigger than the minimal system).
Kernel has ext3 support compiled, to be able to boot from ext3-formatted devices.
If you want to gain some memory, you may comment out these lines in /etc/inittab:
T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100 T1:23:respawn:/sbin/getty -L ttyUSB0 115200 vt100
It's only necessary if you connect using a serial cable (first line; router's serial port), or a USB-serial cable (second line; router's USB port), and normally that's not needed after you configured your system.
Moreover, if you want to connect as root using a USB-serial cable, add ttyUSB0 line to /etc/securetty file:
echo ttyUSB0 >> /etc/securetty
If you want to ensure that your USB-stick will live longer:
- make all logs to be written into tmpfs, like /tmp/log
- make sure the system will use swap as little as possible (echo "0" > /proc/sys/vm/swappiness)
You can move swapfile periodically. This way you ensure that you won't over-use the swap part of your USB-stick.
NOTE: all USB-sticks do wear-leveling transparently, so normally, it's not needed to move swapfiles around. On the other hand, you never know how good/bad the wear-leveling in your USB-stick is.
1. create new swapfile (16MB in example)- dd if=/dev/zero of=newfile bs=1024 count=16384; mkswap newfile;
2. swapon newfile;
3. swapoff oldfile
4. ... edit fstab accordingly
Swap is not too large usually, so you can create several 16-32MB swapfiles at once and activate next of them according to your need (e.g. once a month/season). Keep the old swap-files; if you create new ones only when needed, you could create new swapfile where some of the previous files used to be...
[edit] How it works
The trx image was made with OpenWRT buildroot, contains the kernel only.
When you power on your device, it boots the kernel.
Then the kernel executes, and starts the system from /dev/sda1 (usually, your USB-stick, or USB-HDD), which would be Debian in this case, but you can also start any other Linux distribution capable of running on mipsel (like Gentoo).
[edit] Building your own kernel
If you want to build your own MIPS kernel compatible with ASUS, follow these steps:
1. Download openwrt build environment (revision 6850 is stable, later ones may not be stable):
svn checkout --revision 6850 https://svn.openwrt.org/openwrt/trunk/
At the time I built the kernel image available for download here, I used revision 6850 from 2007-Apr-03.
2. Go to trunk/ directory, and select all the required tools:
make menuconfig
Make sure "Target System (Broadcom BCM947xx/953xx [2.6])" is selected and "Target Images" is set to "jffs2". Also, deselect almost all packages. As we want to use Debian, we don't need any OpenWRT packages. This will make our .trx image build faster; it'll be also smaller.
Leave one package, "Base system -> base-files", as it will be needed to build the .trx firmware (otherwise, .trx image will be "empty", and won't build).
3. Now, build all the tools needed for cross-compilation, and a (not yet configured) kernel:
make V=99
4. When all the tools are made, copy the .config file (download below) to trunk/build_mipsel/linux/.
5. Configure the kernel as you want - in trunk/build_mipsel/linux/:
make ARCH=mips menuconfig
6. Go back to trunk/ directory, run make menuconfig again, exit, and save the changes (yes, although nothing was changed, this step is needed to update some stamp files).
7. Make a new image - start this command in trunk/:
make V=99
8. You will have new images in trunk/bin/
Now we have to build modules for our new kernel:
9. Remove .image and .modules in build_mipsel/linux/
cd build_mipsel/linux/ rm .image .modules
10. Go back to trunk/ directory and run make again (now it compiles also the modules we want)
cd ../.. make
11. Put modules temporary somewhere (INSTALL_MOD_PATH is where we want to temporary put modules)
cd build_mipsel/linux/ INSTALL_MOD_PATH=/temporary/path/ make modules_install
12. Now we have in /temporary/path/lib/modules/$our_kernel_version our modules and we have to copy them on the router in /usr/lib/
# ls /temporary/path/lib/modules/2.6.19.2/ kernel modules.ccwmap modules.ieee1394map modules.isapnpmap modules.pcimap modules.symbols modules.alias modules.dep modules.inputmap modules.ofmap modules.seriomap modules.usbmap # scp -r /temporary/path/lib/modules/2.6.19.2/ router_ip:/lib/modules/
13. Log as root on the router and adjust permissions
# chown -R root:root /lib/modules/2.6.19.2/
14. Flash the image as explained before and that's it
For a more detailed explanation of what the above steps are doing, see http://wiki.openwrt.org/BuildRoot (in particular, the "Building openwrt" section)
[edit] ASUS WL-500g Deluxe notes
By default, only four LAN ports are enabled. WAN port is disabled.
To enable WAN port, add this command to your startup scripts:
robocfg port 0 stp none
You need to have robocfg command, you can get it in the download section.
[edit] ASUS WL-500g Premium notes
By default, only the WAN port is enabled. The four LAN ports are disabled (note: it may differ on different models).
To enable the LAN ports, add these commands to your startup scripts:
robocfg switch disable robocfg vlans enable reset robocfg vlan 0 ports "0 5u" robocfg vlan 1 ports "1 2 3 4 5t" robocfg switch enable
If it doesn't work, try:
robocfg switch disable robocfg vlans enable reset robocfg vlan 0 ports "0 1 2 3 4 5u" robocfg switch enable
For these configuration steps to work, you must have the robocfg command, which is available in the download section.
See architecture description: http://wiki.openwrt.org/OpenWrtDocs/NetworkInterfaces
[edit] ASUS WL-700gE notes
Once debian starts it uses the fourth LAN port, robocfg hasn't been tested.
A custom OpenWrt build must be used initially. This is required to partition and format the hard disk. Partitioning and formatting tools will probably not fit in the 2MB of flash memory, These can be build as packages by the OpenWrt make script and copied over using netcat which is built into busybox. Similarly the Debian base system can be copied over using netcat and extracted in place. Remember to set a root password in Debian, (use chroot). To complete installation create a directory such as /hdd where the hard disk can be mounted, create a directory such as /hdd/flash_root where the OpenWrt / can be pivot'ed to and use a custom /sbin/init inside OpenWrt to mount the hdd, pivot and exec /sbin/init.
#!/bin/sh
boot_dev="/dev/ide/host0/bus0/target0/lun0/part1"
for module in ide-core aec62xx ide-detect ide-disk jbd ext3 switch-core switch-robo switch-adm diag; do {
insmod $module
}; done
sleep 5s
mount -o ro "$boot_dev" /hdd
if [ -x /hdd/sbin/init ]; then
. /bin/firstboot
pivot /hdd /flash_root
exec /sbin/init
else
exec /bin/busybox init
fi
[edit] More detailed robocfg/vlan settings
Please see http://lists.wpkg.org/pipermail/debian-non-standard/2008q1/000045.html for more detailed robocfg/vlan settings.
[edit] Resetting NVRAM from Debian
After flashing with 2.6.19.2 my router is no longer reachable when in the "recovery state" (i.e., ping 192.168.1.1 times out); however, debian still boots fine. I have to reset nvram from the working debian system in order to flash a new image. Keep in mind that although it worked for me, it could nonetheless brick your router.
In order to reset nvram you have to:
1. Boot your router with debian and log as root.
2. Check where nvram is
# cat /proc/mtd dev: size erasesize name mtd0: 00040000 00010000 "cfe" mtd1: 007b0000 00010000 "linux" mtd2: 006d0000 00010000 "rootfs" mtd3: 00010000 00010000 "nvram"
3. Install "mtd-tools"
# apt-get install mtd-tools
4. Reset nvram
# flash_erase /dev/mtd3 Erase Total 1 Units Performing Flash Erase of length 65536 at offset 0x0 done
Nvram is clear now and you can flash your new image.
[edit] Linksys WRTSL54GS notes
Download "all kernel images" archive (from the "Downloads" section).
Inside, you will find the image for Linksys WRTSL54GS: openwrt-wrtsl54gs-2.6-jffs2.bin.
[edit] Wireless
Currently, wireless doesn't work for boards with Broadcom mini-PCI. An updated kernel will be uploaded once the wireless is working in Kamikaze/OpenWRT.
[edit] Additional hardware
Go to additional hardware to see the list of additional hardware these routers were running with.
[edit] Downloads
Go to downloads page.
[edit] Troubleshooting
- openwrt-brcm-2.6-jffs2-64k.trx and openwrt-brcm-2.6-jffs2-128k.trx are not the same images as available on openwrt.org or other sites. It's a custom build, needed to boot Debian from /dev/sda1. If you download openwrt-brcm-2.6-jffs2-64k.trx or openwrt-brcm-2.6-jffs2-128k.trx from somewhere else, it will not boot Debian...
- Can't connect... Network problems etc.
Add a startup script *after* the network is initialized.
In it, start some simple commands like:
ifconfig eth0 &>/eth0.txt ifconfig -a &> /ifconfig.txt
You will see if the device has an IP address at all - just see those files on another machine. Also, check the logs etc.
You might want to add something like ping, too:
ping -I eth0 -c 100 192.168.5.5
and see with a network sniffer (like tcpdump or ethereal/wireshark) on another machine if you see any packets.
- Try to connect the network cable to a WAN port, and if it doesn't work (i.e., you still can't connect), to any of LAN ports.
- Are you sure you're connecting from the same subnet?
- Did you run tune2fs with proper options?
- Did you really create an ext3-formatted partition, and not some other filesystem? The device won't boot from a USB stick with ext2, or any other filesystem.
- A serial cable is the best way to troubleshoot all problems. If you don't feel like opening your device and using a serial cable, you can use a USB-serial cable to connect to your device (it will only have any use if the device actually boots; you won't see any kernel messages while it boots).
- Wireless is currently not supported.
[edit] Contact and support
If you have any questions or want to be notified about news, please subscribe to the mailing list on http://lists.wpkg.org/mailman/listinfo/debian-non-standard. This is a list with very low traffic.
For general debian-mipsel info, please ask at debian-mips mailing list.
I only have ASUS WL-500g Deluxe, but I received emails from other people who confirmed they run Debian on other models, like WL-500g Premium. On the other hand, from time to time, I receive emails from people who have problems running Debian on ASUS WL-500g Premium.
If you want Debian supported on your favourite device, you could either:
- donate me some hardware
- borrow me hardware for a couple of weeks
I would be very happy to accept ASUS WL-500g Premium.
To make sure Debian is well supported on mipsel architecture, please participate in Debian Popularity Contest. To do it, install popularity-contest package:
# apt-get install popularity-contest