NSLU2-Linux
view · edit · print · history

This build provides independend uClibc feed for many firmwares based on buildroot toolchain and uClibc library.

The main feature of this packages is that it installs all required files under /opt with 1000+ ported applications. With buildroot toolchain and patched uClibc search paths feed also added system library indenpendence. This means that packages now depends on /opt/lib/uClibc.so and dynamic loader also in /opt/lib with separate /opt/etc/ld-opt.so.conf for custom .so cache.

At present the following target firmwares are supported:

  1. oleg - http://wl500g.dyndns.org
  2. ddwrt - http://www.dd-wrt.com and dd-wrt wiki on Optware
  3. OpenWrt whiterussian - http://www.openwrt.org/ using ddwrt package feed
  4. Xwrt - http://xwrt.berlios.de/xwrt.asp using ddwrt package feed
  5. Asus WL-700gE custom firmware using oleg package feed -PDF install guide

Prerequisite for all packages is that uclibc-opt package is installed before any other.

With latest DD-WRT v23 firmware it is also possible to install optware packages. See http://www.dd-wrt.com/wiki/index.php/Optware for details. Full feature ipkg package is also included in feeds for use where required (eg. ddwrt)

Difference between feeds is mostly in firmware kernel headers. ddwrt, whiterussian, Xwrt all use the same kernel version and thus the same kernel headers. For this reason all three firmwares use the same "package feed" - ddwrt.

Complete system library indenpendence makes it possible for porting Optware-uClibcBuild into other architectures/firmwares like dreambox. Mostly Asus routers provide

Building from sources

 make OPTWARE_TARGET=ddwrt

will build directories toolchain and packages. If anything goes wrong the following pit stops are recomended:

 export OPTWARE_TARGET=ddwrt
 make directories
 make toolchain
 make packages

Buildroot toolchain consist of the following targets:

 make buildroot-toolchain
 make libuclibc++-toolchain

When changing target firmware buils one should issue

 make buildroot-dirclean

to completely remove toolchain/mipsel-linux-uclibc and toolchain/buildroot subdirectories.

The following utilities are recommended when rebuilding fom sources:

  • tar 1.14
  • bash 2.05
  • autoconf-1.9
  • gcc 4.1.1

buildroot target will also create complete toolchain for native compilation.

Native compilation on router itself

There is also possibility for native compilation with optware-devel metapackage.

 ipkg-opt install optware-devel

will install the following packages: autoconf, automake, bash, bison, buildroot, bzip2, coreutils, diffutils, file, findutils, flex, gawk, libuclibc++, groff, libtool, make, m4, ncurses, openssl, patch, pkgconfig, perl, python, rsync, sed, svn, tar, wget-ssl.

But basic compiler set comes with buildroot package. To compile hello.c just enter gcc -o hello hello.c

For optware development just check-out repository with

  cd /tmp/harddisk
  svn co http://svn.nslu2-linux.org/svnroot/optware/trunk optware
  cd optware
  export OPTWARE_TARGET=oleg
  make directories
  make toolchain

then issue individual package make eg. make bc or just make for the whole repository.

Installing and using the updated uClibc library on your Asus WL-500g router

This end user Question/Answer description of uClibc build was privided by ptnemont. Although it is described for WL500G? all this tinfo can also be applied to other firmwares providing /opt mount point .

What is uClibc?

From the GNU C Library homepage: "Any Unix-like operating system (including Linux) needs a C library: the library which defines the 'system' calls and other basic facilities such as open, malloc, printf, exit... The GNU C library is used as the C library in the GNU system and most systems with the Linux kernel."

Now the standard GNU C Library contains a lot of functionality, but it's also quite big. Embedded Linux systems (such as the Asus WL500g? router) have - in a lot of cases - very limited space avaiable. That's why some clever guys came up with the idea to create uClibc, a new C library that would eat up a lot less space while still providing the most used functionality of the GNU C Library (meaning the most programs that compile with the standard GNU C library also should compile with the uClib library).

As you have probably guessed already this uClibc library is the C library that is used in the Asus WL-500g firmware provided by Oleg.

Why would I need another version of uClibc?

The current version of uClibc that is included in the firmware provided by Oleg has some issues. First of all it is a rather old version, next to that there are a number of programs which do not compile with it. The program that got me interested in this issue was actually "unrar", but there are many other examples.

I can't tell you exactly why these programs don't compile against the uClibc (whether it is a problem with the older version of uClibc, or whether it is something specific to the WL-500g - if you know feel free to inform me). What I do know however is that on the WL500g?.info forums (you first stop for any info on the WL500g? series!) a helpful guy Oleo indicated that he succeeded in using a newer version of uClibc (we'll call this v0.9.28) which solves a lot of the issues that were found with the original one (v0.9.19).

This means that you can actually use a lot more packages on your WL-500g than before, and it also gives a you a bigger chance that whatever package you want to create yourself (because it's missing today) will compile without any issues. Great news I hear you say, and it is - however as the information on how to do this is rather spread on different forums and Wiki's I tried to sum it all up here. In a next section I will explain how you can get the new uClibc (v0.9.28) working on your WL-500g, and after that I will show how you can start creating packages yourself.

So what do I have to do to start using this new version of the uClibc library?

Using the new version of the uClibc library is actually quite easy - just install it using ipkg. However, one important point to take into account before you start: you don't only need to get the library installed, you should also make sure that you get programs that use this new library (and not the v0.9.19 one from the firmware). This is achieved by using the ipk package feed specific for use with the uClibc v0.9.28 library, as explained below: (for oleg firmware see next section)

  • Open the file /opt/etc/ipkg.conf in your favourite editor
  • Remove or comment out the line that specifies the current source for unslung packages (should start with "src unslung")
  • Define the new source for Unslung package by adding the line src unslung http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable
  • Make sure the destination is specified as follows:
      dest root /

This will make sure that all new packages which you install wil be using the correct library. As a last step you will also have to reinstall all packages that you had already installed previously (to make sure that they too use the correct library). This is how you can go about it:

  • Install the new version of the uClibc library with "ipkg install uclibc"
  • Get a list of all packages you have currently installed with the command "ipkg list_installed"
  • For each of these packages reinstall the package with the command "ipkg install -force-reinstall package_name" (except for the uClibc package itself off course because you installed the correct version in the previous steps)

That's it! With these few steps you have opened up the way to a whole range of exciting new packages for that magical WL-500g box. If you really would like to have a package which is not available yet from the current feed the next section will show you a way how you could achieve this (with some luck...)

What do I have to do to get this better uClibc on OLEG firmware?

On a freshly formatted external filesystem, mounted on /opt, take the following steps...

First create the directory:

 mkdir /opt/tmp
 mkdir /opt/tmp/ipkg

Now get the beter ipkg an uClibc. The ipkg.sh below will complaining about missing /opt/lib/ipkg/lists/wl500g, but that is no problem since we are installing straight from the ipk files.

 # get the better ipkg
 wget http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/ipkg-opt_0.99.163-9_mipsel.ipk 
 #install it (ignore tne missing lists/wl500g error)
 ipkg.sh install ipkg-opt_0.99.163-9_mipsel.ipk

 # get the better uclibc
 wget http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/uclibc-opt_0.9.28-13_mipsel.ipk
 # install it (ignore tne missing lists/wl500g error)
 ipkg.sh install uclibc-opt_0.9.28-13_mipsel.ipk 

 # update the list using the improved ipkg
 ipkg update 

That's all, enjoy your packages!

Alternative method for installing basic packages for Oleg firmware

Recommended way for installing basic two packages (uclibc-opt and ipkg-opt) is with installation script that will also check for possible network problems and /opt directory availability. /opt directory could be empty for this script.

To install (or reinstall) issue the following two commands:

 wget http://www.wlan-sat.com/boleo/optware/optware-install-oleg.sh -O - | tr -d '\r' > /tmp/optware-install.sh
 sh /tmp/optware-install.sh

This will update to latest uClibc version and allow installing other packages.

And what if the program I need is not available in the existing packages?

Bad luck, off course. But the situation is not totally hopeless, you could create your own package! Now normally this requires quite a lot of in-depth knowledge on setting up the right environment and creating packages, however the good people that brought us Unslung have put quite some effort in ensuring there is an easy way for anyone of us to create packages. Now a lot of the info I write below is available on the Unslung WIKI, so that should be your starting point to understanding how to create packages. However I will give a step-by-step tutorial below on how to create a package for the WL-500g using the new v0.9.28 uClibc library specifically.

It is important for you to understand the steps required when creating a package.

  1. Set up the environemt where you will compile your package (I will be using an Ubuntu 6 installation running in VMWare? player on my Windows XP PC - but any Debian based distro will do, and you should be able to get it to work on non Debian based setups)
  2. Define your package (in the best case only consists of creating one file!)
  3. Test you package (try to compile, install and run it)
  4. Check-in your package so that other people can test and use it

Setting up your environment is real easy. First define the directory you want to work in (I will be using "/opt/slug" as directory - you are free to choose yours):

    mkdir /opt/slug
    cd /opt/slug

Next you will have to download the SVN tree for the build environment:

    svn co http://svn.nslu2-linux.org/svnroot/optware/trunk optware

The next steps are specific for the WL-500g with updated uClibc (and are needed to make sure you use the right libraries):

    cd optware
    export OPTWARE_TARGET=oleg
    make directories
    make toolchain

Now you have your environment setup and you can start working on your package. For this you create a new ".mk" file. This file will contain all information about your package (including the name, version, dependenices, where to get the source code, and any other specifics that are needed). This is the only real hard part - the best thing you can do is to use an existing file for a (preferable simple) package and adapt it to your needs. Once this is done you can try to get your package created using "make make/package_name.mk". You'll probably bump into some issues you need to solve to get to a working .mk file, but once that is done and the make succeeds you will find yourself with a brand new package in the "build" directory.

Now it's time to put your package to the test. Get it onto your WL-500g (using SAMBA, USB stick, FTP or whatever means you want) and install the package with "ipkg install package_name.ipk". If that works you can check whether all files from your package have been installed, and actually test your program - hopefully it does what it is supposed to do!

If you have tested your package and are convinced it is working OK then it's time to get your ".mk" file included in the official feed. Instructions on this are available on the Unslung WIKI, as it does not contain anything specific for the WL-500g I won't detail these here.

Upgrading from old wl500g package feed

When changing package feed from "wl500g" to "oleg" change /opt/etc/ipkg.conf to the following content:

src/gz optware http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable
dest /opt/ /

then issuse

ipkg update
ipkg install -force-overwrite ipkg-opt

This will install uclibc-opt and ipkg-opt.

The following awk one line awk script will reinstall all installed packages:

/usr/bin/awk '/^Package:/{system("/opt/bin/ipkg install -force-reinstall -force-defaults " $2)}' /opt/lib/ipkg/status

Preparing Xwrt or OpenWrt whiterussian for external USB disk

Optware with whiterussian OpenWrt and Xwrt is fully operational.I recommend to create disk partitions (opt, swap and data) with some linux system as the OpenWrt lacks some fdisk and busybox (mkswap, swapon, swapof) packages.

What do you need ?

-WL500g? with an usb port. -USB HDD Drive. -Non-firewalled connection or an admin that will forward the ports. (65524-torrent, optional 22 and 8008 for WAN side access)

Install the following USB and ext2/3 packages:

  • kmod-usb-core - 2.4.30-brcm-5 - Kernel Support for USB
  • kmod-usb-storage - 2.4.30-brcm-5 - Kernel modules for USB storage support
  • kmod-usb2 - 2.4.30-brcm-5 - Kernel driver for USB2? controllers
  • kmod-ext2 - 2.4.30-brcm-5 - Kernel modules for EXT2? filesystem support
  • kmod-ext3 - 2.4.30-brcm-5 - Kernel modules for EXT3? filesystem support
  • kmod-vfat - fat systems used on most USB stuff

Example:
>ipkg install kmod-usb-storage
After you install everything you want
>reboot
Hint: If youre going for torrents ext2 filesystem is the thing you need.
But after that you will be able to mount disk partitions. Then manually install packages from http://ipkg.nslu2-linux.org/feeds/op.../cross/stable/ with Openwrt ipkg system. (uclibc-opt, transmission, busybox-core for swapon, ...)
Missing packages swap-utils and fdisk can be installed from rc5-backports http://downloads.openwrt.org/backports/rc5

Mounting and preparing for Optware packages

 $ mount /dev/scsi/host0/bus0/target0/lun0/part1 /opt

Inexperienced vi users can use Xwrt Webif2 file editor. Contents of /opt/etc/ipkg.conf file:

 src optware http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable
 lists_dir ext /opt/var/lib/ipkg
 dest opt /

We could also use

 $ mkdir /opt/etc
 $ echo "src/gz optware http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable" > /opt/etc/ipkg.conf
 $ echo "lists_dir ext /opt/var/lib/ipkg" >> /opt/etc/ipkg.conf
 $ echo "dest /opt/ /" >> /opt/etc/ipkg.conf
 $ cat  /opt/etc/ipkg.conf 
  src/gz optware http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable
  lists_dir ext /opt/var/lib/ipkg
  dest /opt/ /

We will use OpenWrt ipkg to install ipkg-opt and uclibc-opt packages

 $ export IPKG_CONF_DIR=/opt/etc
 $ ipkg -V 2 update
 Downloading http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/Packages.gz
 Inflating http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/Packages.gz
 Updated list of available packages in /opt/var/lib/ipkg/optware
 Successfully terminated.


 $ ipkg install ipkg-opt
 Installing ipkg-opt (0.99.163-9) to /opt/...
 Downloading http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/ipkg-opt_0.99.163-9_mipsel.ipk
 package uclibc-opt suggests installing ipkg-opt
 Installing uclibc-opt (0.9.28-11) to /opt/...
 Downloading http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/uclibc-opt_0.9.28-11_mipsel.ipk
    Configuration file '/opt/etc/ipkg.conf'
    ==> File on system created by you or by a script.
    ==> File also in package provided by package maintainer.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
     The default action is to keep your current version.
    *** ipkg.conf (Y/I/N/O) [default=N] ?N
 Configuring ipkg-opt
 Configuring uclibc-opt
 Updating /opt/etc/ld.so.cache
 Successfully terminated.

We could also answer Y to install mainainers version as from now one it is recommended to use /opt/bin/ipkg-opt command for installing optware packages.

Install packages with /opt/bin/ipkg-opt like 
>/opt/bin/ipkg-opt install transmission 
>/opt/bin/ipkg-opt install uclibc-opt 
>/opt/bin/ipkg-opt install busybox-core

Now you are able to start swap with 
/opt/bin/busybox swapon /dev/scsi/host0/bus0/target0/lun0/part2 

Note that on OpenWRt? there will be two ipkg commands. System one /usr/bin/ipkg and Optware one /opt/bin/ipkg. Both commands comands maintain their own packages list. They are separated intentionaly.Do not add ddwrt package feed to OpenWrt system packages. Name clash of similar packages could occur.

USB stick

USB stick can also be used instead of hard disk for packages not requiring many writes to key. Due to flash wear out it is not recommended to create swap. Default format for USB stick is FAT and stick is recognised at boot time and mounted in directory /mnt/disc0_1 .With disk dump we will create 240MB file on a stick to accomodate ext2 filesystem without repartitioning/reformating stick.

 dd if=/dev/zero of=/mnt/disc0_1/optware.ext2 bs=1k count=240000
 240000+0 records in
 240000+0 records out

This file can be later used to backup the whole optware packages installed. Now we will create ext2 filesystem in /mnt/disc0_1/optware.ext2 file with mke2fs from e2fsprogs package:

 $ mke2fs -L optware -M /opt /mnt/disc0_1/optware.ext2
 mke2fs 1.38 (30-Jun-2005)
 /mnt/disc0_1/optware.ext2 is not a block special device.
 Proceed anyway? (y,n) y
 ext2fs_check_if_mount: No such file or directory while determining whether /mnt/disc0_1/optware.ext2 is mounted.
 Filesystem label=optware
 OS type: Linux
 Block size=1024 (log=0)
 Fragment size=1024 (log=0)
 60000 inodes, 240000 blocks
 12000 blocks (5.00%) reserved for the super user
 First data block=1
 30 block groups
 8192 blocks per group, 8192 fragments per group
 2000 inodes per group
 Superblock backups stored on blocks: 
         8193, 24577, 40961, 57345, 73729, 204801, 221185 

 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done

 This filesystem will be automatically checked every 32 mounts or
 180 days, whichever comes first.  Use tune2fs -c or -i to override.

For mounting files as filesystem you need to install kernel module for mount loopback support - kmod-loop.

We now just need to mount file into /opt directory:

 $ mkdir /opt
 $ mount -o loop /mnt/disc0_1/optware.ext2 /opt

Stick is now prepared for installing optware software.

mounting partitions on boot

Create /opt mount point with

 mkdir -p /opt

Edit startup scripts to allow mounting at reboot

 >vi /etc/init.d/S11mount
 #!/bin/sh
 #
 # macsat.com mount script
 #

 # Which device needs to be mounted?
 MOUNT_DEVICE0=/dev/scsi/host0/bus0/target0/lun0/part1

 i=0
 # Wait 15 secs, mount when ready, and continue if it dosnt get ready within 15 secs.
 while [ $i -le 15 ]
 do

 if [ -e $MOUNT_DEVICE0 ]
 then
 mount $MOUNT_DEVICE0 /opt/
 echo "Success: $MOUNT_DEVICE0"
 exit 0
 fi

 sleep 1
 i=`expr $i + 1`
 done 

swap

 vi /etc/init.d/S12swap

 #!/bin/sh
 /opt/bin/busybox swapon /dev/scsi/host0/bus0/target0/lun0/part2

Let it execute them with :

 >chmod +x /etc/init.d/S11mount
 >chmod +x /etc/init.d/S12swap

Legend:

 * part1 = your partition for optware
 * part2 = your partition for swap

Optionally one can use custom startup script provided by X-Wrt

writing in console

Hint:vi usage : pressing some letter on keyboard enables editing mode indicated by "I" in the bottom left corner to save and exit after editing press "ESC" (the "I" should be gone) and type "wq!"(Wanna know more about vi ? google!)

/etc/profile

Setting default search path to /opt/bin and /opt/sbin is done by editing /etc/profile

oleo

view · edit · print · history · Last edited by oleo.
Based on work by oleo, logue, Jelle Alten, cal, and BrianZhou.
Originally by oleo.
Page last modified on June 22, 2008, at 06:14 PM