NSLU2-Linux
view · edit · print · history

OpenWrt is an open source project to create a free embedded operating system for network devices. Users wanting to use only internal flash memory to install the system should try OpenWrt. It has a large user community and is actively developped. SVN version (November 2008) for example uses linux-2.6.26.7.

OpenWrt Kamikaze supports the NSLU2. It has some advantages over SlugOS or other NSLU OS:

  • Since at its beginnings it targeted wireless embedded hardware, OpenWrt has full support of wireless hardware and software. For example, it ships the rt73 driver which can be sometimes complicated to install on other OS.
  • It uses µClibc by default, and the squashfs compressed read-only filesystem, giving a lot of free space on the internal flash. For example, a minimal image, with dropbear, busybox µClibc and wireless tools can take 832kB. Since this image is read-only, OpenWrt uses a JFFS2 for writeable space (still 5632kB in my case), allowing users to install software after the main image configuration.
  • With SlugOS, you basically spend time to remove what's unneeded, with OpenWrt, you spend time adding what you need.
  • Configuration and building the image is user-friendly, with make menuconfig. Including software in the firmware image or building it for packages is explicit and easy.

See the KnownProblems page for known problems with the Kamikaze 7.07 release.

You can either build kamikaze, download the kamikaze-7.09 image from http://www.slug-firmware.net, or install the updated default image (version 8.09) from the OpenWrt project at http://downloads.openwrt.org/kamikaze/8.09/ixp4xx/openwrt-nslu2-squashfs.bin, or install 10.03.1-rc3 (aka Backfire) from http://downloads.openwrt.org/backfire/10.03.1-rc3/ixp4xx/openwrt-nslu2-squashfs.bin (or later). Installation is the same in all cases.

To build, follow the OpenWrt BuildInstructions for the Intel XScale IXP4xx [2.6] target system (you can use the "Image configuration" section to set up your initial network configuration), and then flash the openwrt-nslu2-2.6-squashfs.bin 8MB image in the normal way. You can also use the "make openwrt-image" target in the Master Makefile.

There is some good documentation at http://nbd.name/openwrt.html. See also the OpenWrt wiki entry for the NSLU2 at OpenWrt wiki, which contains more information.

After installation, OpenWrt will take a few minutes to initialize the JFFS2 partition. It took about five minutes for me. You should wait at least ten minutes before rebooting. It will have an IP address of 192.168.1.77 (or 192.168.1.1 for version 8.09 and later, some people also encountered a DHCP assigned address) to which you need to telnet to get access for the first time.

Note that the Ready/Status LED may remain dark in Backfire, even if the system is up and running. Change in Administration -> System -> LED Configuration.

Here is the BootLog (Kamikaze 7.06).

For assistance, look in the #nslu2-linux (for nslu2-specific installation problems, be aware there will be very few openwrt users in this channel) or #openwrt (for general OpenWrt questions - this is where all the openwrt users hang out) IRC channels on Freenode.

A tip flashing the Kamikaze 7.09 binary firmware:

  • DHCP is enabled by default, (this was learned after what appeared several failed attempts to first connect to the NSLU2 at IP address of 192.168.1.77 which had been set using the stock Linksys firmware)

Other notes and references for Openwrt/NSLU2 Kamikaze 7.09:

Some user tips!

  • By default, the slug uses 192.168.1.77 as the IP address, but you can change that in the network configuration when building. 8.09 and later use 192.168.1.1 as the default.
  • By default, both telnet and ssh are installed, but only telnet is enabled. To enable ssh and disable telnet (a very good choice, security-wise), telnet to the slug and then use the 'passwd' command to change your root password. The rest seems to be automatic.
  • To change the banner that displays when you log in, edit /etc/banner
  • ipkg.sh is not in the webif/web directory so you have to login to a terminal to update/install packages.
  • Binary: Mounting is a little off standard, kernel will mount sda1 as ext2 to /mnt/usbdrive. Other partitions can be mounted by creating /etc/fstab and a script (http://www.pug.org/index.php/OpenWRT - Automount for example) that executes it - but does a "sleep 5" (or so) before, so usb wil be available. I consider this pretty dirty, so replace with a better way, if known.
  • Make sure you use the ehci driver (kmod-usb2) and not the ohci driver! You can test it with "hdparm -Tt /dev/sda" (or what you have instead of /dev/sda).
  • The package management program is now called "opkg"
  • Remember that you require "opkg update" after each restart, because openwrt stores the package descriptions in the /tmp directory and it gets deleted after every restart.

Adding Optware packages to OpenWrt

Optware packages use their own ipkg-opt packaging system that is independent of firmware. This also means that when upgrading OpenWrt theb Optware package list is not erased as it is stored in the /opt partition where also all Optware packages are installed.

Note: For OpenWrt 8.09, the command is called opkg, not ipkg

For USB disk preparation one must first prepare disk partitions with

ipkg update
ipkg install e2fsprogs cfdisk fdisk swap-utils

Partitioning disk into /opt swap and /home partition can be done with cfdisk /dev/sda or fdisk /dev/sda. Allocate at least 2GB for /opt and 512MB for swap (AdamB - 512MB seems excessive, I stuck to the unslung size of 120MB).

Prepare partitions:

root@OpenWrt:/# mkswap /dev/sda2
root@OpenWrt:/# mke2fs -j /dev/sda1
root@OpenWrt:/# swapon /dev/sda2
root@OpenWrt:/# mke2fs -j /dev/sda1

Mount partitions:

root@OpenWrt:/# mkdir /opt
root@OpenWrt:/# mount /dev/sda1 /opt/

To ensure partitions are remounted after a reboot you need to add the mount and swapon commands to a startup script, I recommend /etc/init.d/custom-user-startup until new kamikaze builds (after 7.09) supporting /etc/config/fstab are released

For initial installation of Optware package we need to install ipkg-opt package using /usr/bin/ipkg. This can be done by adding

 src optware http://ipkg.nslu2-linux.org/feeds/optware/openwrt-ixp4xx/cross/unstable

to /etc/ipkg.conf using vi editor. Then we proceed with ipkg update and ipkg install ipkg-opt. This will install required /opt/bin/ipkg-opt. I recommend removing the Optware package feed from /etc/ipkg.conf and add the same line to /opt/etc/ipkg.conf.

Some Optware packages rely on libraries that are optional OpenWRT packages. Because these come from different repositories they can't easily be configured as dependencies. Either install the OpenWRT packages libssp, libpthread and libstdc++ now or be ready to install them if something breaks.

Optware also has a few other assumptions that aren't met by OpenWRT, it assumes that users called mail and lp exist in the password file so make sure you create them before installing email or printer spooler software. Another assumption is that /etc/services contains a sensible list of ports - I copied the file from another machine.

It is recommended that default search path is extended to /opt/bin:/opt/bin:$PATH in /etc/profile before issuing /opt/etc/ipkg-opt update and installing additional Optware packages. Depending upon how you use the slug you may prefer to include /opt/bin either before or after the default path. If you install packages like coreutils which replace commands provided by OpenWRT with better ones then you probably want /opt/bin first, otherwise it is probably best if it is last. If you put it first you will need to give the full path if you need to use the openWRT version of ipkg /etc/profile line should look like

 export PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin

or

 export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin

If you install any packages that include startup scripts then you'll discover that OpenWRT doesn't call them. To fix this you need to create /etc/init.d/optware that looks like

#!/bin/sh /etc/rc.common

START=80

start() {
        echo "Starting Optware."
        [ -x /opt/etc/rc.optware ] && /opt/etc/rc.optware start
        }

stop() {
        echo "Shutting down Optware."
        [ -x /opt/etc/rc.optware ] && /opt/etc/rc.optware stop
       }

and then a file /opt/etc/rc.optware that contains

#!/bin/sh

# Start all init scripts in /opt/etc/init.d
# executing them in numerical order.
#
if [ x$1 == xstop ] ; then
        progs="/opt/etc/init.d/K??*"
        rc=stop
else
        progs="/opt/etc/init.d/S??*"
        rc=start
fi

for i in $progs ;do

        # Ignore dangling symlinks (if any).
        [ ! -f "$i" ] && continue

        echo starting $i
        case "$i" in
           *.sh)
                # Source shell script for speed.
                (
                        trap - INT QUIT TSTP
                        set $rc
                        . $i
                )
                ;;
           *)
                # No sh extension, so fork subprocess.
                $i $rc
                ;;
        esac
done

and then as for other OpenWRT services you enable it with /etc/init.d/optware enable

Configuring DHCP and USB ports in OpenWRT Kamikaze 8.09 and Backfire 10.03.

The current (April 2009) OpenWRT bin image is hard coded to 192.168.1.1 and does not include USB port support by default. After upslugging the new 8.09 image to your NSLU2, you will need to telnet to it and make some minor reconfigurations. The 10.03 image also works the same way.

The following instructions are if you're using a linux system. Adapt to suit other environments.

  • Reconfigure the IP address of your host system's ethernet port so that its in the same subnet as the freshly imaged NSLU2. ifconfig eth0 192.168.1.254 or sudo ifconfig eth0:1 inet 192.168.1.254 broadcast 192.168.1.255 netmask 255.255.255.0
  • Telnet to the freshly imaged NSLU2. telnet 192.168.1.1
  • Disable the dnsmasq and firewall services that are on by default. /etc/init.d/dnsmasq disable and /etc/init.d/firewall disable
  • Rewrite the /etc/config/network file as follows:
cat > /etc/config/network
config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface lan
        option ifname   eth0
        option proto    dhcp
(press CTRL-D to close the file)
  • If you want to keep eth0 static, you can just add "option gateway xxx.xxx.xxx.xxx" and "option dns xxx.xxx.xxx.xxx" to "option ipaddr xxx.xxx.xxx.xxx", "option netmask xxx.xxx.xxx.xxx", and "option proto static".
  • You can now reboot your NSLU2 by typing the command reboot. When it comes back up, it will fetch its IP address using your local DHCP server. You can now telnet to it directly from your local subnet without having to reconfigure your host terminal's ethernet port into the 192.168.1.0 subnet. Note that you'll need to query your DHCP server to find out what address its given the NSLU2!
  • Install whatever opkg packages you require as follows (example)
opkg update
opkg install e2fsprogs cfdisk fdisk swap-utils usbutils
opkg install kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-scsi-core kmod-usb-storage kmod-usb-serial
opkg install kmod-fs-msdos kmod-fs-nfs kmod-fs-nfsd kmod-fs-ntfs kmod-fs-vfat kmod-fs-ext2 kmod-fs-ext3
opkg install kmod-nls-base kmod-nls-cp437 kmod-nls-cp850 kmod-nls-utf8 kmod-nls-iso8859-1 kmod-nls-iso8859-2
(Note. You must run opkg update each time you reboot the NSLU2)
  • You can also remove packages which may not be useful for your NSLU2 configuration
opkg remove -recursive ppp-mod-pppoe wireless-tools
(as examples)
  • After booting or rebooting your system and if you want to add a package, do not forget to opkg update, since the package repository list is written to /tmp.
  • Backfire 10.03 has most of the lights turned off (except for Ethernet) so use the either the web management (Administration->System->LED Configuration) feature (works quite well) or edit the /etc/config/system. GPIO Connections has some information to help with the setup. Sample /etc/config/system entry:
config 'led'
      option 'name' 'GPIO2'
      option 'sysfs' 'nslu2:green:disk-2'
      option 'default' '1'
      option 'trigger' 'default-on'
Where additional choices for sysfs are 'nslu2:green:disk-1', 'nslu2:green:ready', and 'nslu2:red:status'.

HowTo's for OpenWRT

[global]
        netbios name = Openwrt
        workgroup = WORKGROUP
        server string = NSLU2 OpenWrt Samba Server
        syslog = 10
        encrypt passwords = true
        passdb backend = smbpasswd
        obey pam restrictions = yes
        socket options = TCP_NODELAY
        unix charset = ISO-8859-1
        preferred master = yes
        os level = 20
        security = share
        guest account = root
        invalid users = guest
        smb passwd file = /etc/samba/smbpasswd

[HDD_1_1_1]
        comment = NSLU2 OpenWRT HD 1
        available = yes
        browseable = yes
        public = yes
        writeable = yes
        create mask = 0777
        path = /mnt/drive1
        read only = no
        guest ok = yes

Page last modified on February 01, 2011, at 12:32 AM