NSLU2-Linux
view · edit · print · history

Introduction

This short howto explains howto to build a linux 2.6 kernel and the Angstrom distribution, and how to run this setup on the DS-101 specifically, without erasing the built-in flash. This way you can test different kernels and softwares without fearing to brick your device. In case something goes wrong, simply reboot the device and try again.

This is not a HOWTO on how to build Angstrom and Linux (instructions on the topic may be found elsewhere), but it tries to gather required steps in order to use an open distribution instead of the original firmware.

Although the overall process is quite easy, it is not yet ready for end user as it requires some unusual hardware to access the serial console of the device (see Prerequisites).

In short, the step involved are :

  • build angstrom using OpenEmbedded
  • put the Angstrom root filesystem on a IDE hard disk, or on a USB storage device
  • plug the IDE HD or the usb stick on the DS-101
  • build the kernel using a vanilla 2.6 kernel, DS-101 patches, and the Angstrom toolchain
  • connect to the ds101 bootloader
  • load the kernel into RAM
  • run !

You may use another distribution like Unslung or SlugOS, or other. One of the most important thing is to have a working ARM big-endian toolchain, and that is not easy. Fortunately such a toolchain is built as part of the OpenEmbedded build process.

Softwares version used in this howto may not be up to date. You may check for newer versions before to begin. However this actual setup is known to be good for DS-101 rev3.0.

Things described here are somewhat experimental, so be careful.

This howto is possibly incomplete and/or incorrect. Feel free to improve it.

Prerequisites

A 3.3V TTL serial cable is required to access the device serial console. See SerialConsole. A free hard disk or a usb stick is needed to store the root filesystem. Before to begin experimentations remove the current hard disk from the DS-101, so that your data are kept in a safe way. Internal flash won't be overwritten, so in case you would like to come back to the original DS101 firmware, just reboot your device with the current hard disk.

Build the Angstrom distribution

From http://www.slug-firmware.net/, download Angstrom soure code (http://ftp.osuosl.org/pub/nslu2/releases/Angstrom-2007.12-source.tar.gz). Building Angstrom is pretty straightforward, for example :

 
tar xzf Angstrom-2007.12-source.tar.gz
export ANGSTROM_ROOT=$PWD/angstrom-2007.12
cd $ANGSTROM_ROOT
make

This should be enough. If everything goes well you will obtain (among other nice things) :

  • a working toolchain, with prefix armeb-angstrom-linux-gnueabi-, located in $ANGSTROM_ROOT/tmp/cross/bin
  • a ready to use root filesystem : $ANGSTROM_ROOT/tmp/deploy/glibc/images/ixp4xxbe/base-image-ixp4xxbe.tar.gz
  • ipk packages feeds in $ANGSTROM_ROOT/tmp/deploy/glibc/ipk/

Preparing the root fs for the DS-101

The easiest way is probably to put the root fs on a USB storage device, so that it can be plugged directly into one of the DS-101 USB port. It will preserve the IDE connector which is rather flimsy. Assuming your disk is /dev/sda, a possible procedure on your host computer could be :

 
fdisk /dev/sda (create a primary partition, eventually some swap space)
mkfs.ext3 /dev/sda1
mount /dev/sda1 /mnt/tmp
cd /mnt/tmp 
tar xzf $ANGSTROM_ROOT/tmp/deploy/glibc/images/ixp4xxbe/base-image-ixp4xxbe.tar.gz
cd /
umount /mnt/tmp
sync

You may adjust system files like /etc/fstab, or do it later if needed. Plug your disk in the DS-101, the root filesystem is then ready to be used on the device.

Build the kernel

You need

The proposed patch is an all-in-one patch, gathering essential things. Broken out series can be found here : http://www.pierrox.net/ds101/20080122/sources/patches/. It is not the official repository. It merges code found on nslu2-linux and mikpe patches.

Add the cross-compiler to your PATH, and ensure it is working :

 
PATH=$PATH:$ANGSTROM_ROOT/tmp/cross/bin
armeb-angstrom-linux-gnueabi-gcc --version

Unpack the Linux kernel and apply DS-101 patches :

 
tar xjf linux-2.6.23.12.tar.bz2
cd linux-2.6.23.12
patch -p1 < ../linux-2.6.23.12-ds101-full.patch

Important : adjust manually the MAC address of the ethernet port in arch/arm/mach-ixp4xx/ds101-setup.c. This MAC address should be stored somewhere in flash, but as we don't want to access flash it is currently hardcoded...

Finally adjust the proposed configuration and build the kernel. The kernel .config file shipped in the ds101 patch should be considered as a starting point only.

 
make ARCH=arm CROSS_COMPILE=armeb-angstrom-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=armeb-angstrom-linux-gnueabi-
ls -l arch/arm/boot/zImage

Modules can be installed on the target root filesystem this way :

 
make ARCH=arm CROSS_COMPILE=armeb-angstrom-linux-gnueabi- INSTALL_MOD_PATH=/path/to/rootfs modules_install

Connect to the bootloader

Follow the instructions on SerialConsole to establish the serial link, then power-up the DS-101.

Taking control

Soon after powering-up the DS-101 RedBoot bootloader ask whether to enable ethernet or not. Type "1" for yes. You must be ready and type "1" as soon as possible because you won't get more than 1 second to answer. Some few seconds later the bootloader ask whether to execute the automatic boot script : type ^C to abort it. Once again answer delay is short, so be careful. If all goes well RedBoot will now wait for your commands. You can now interact with the bootloader, and especially load the kernel zImage. Typing "help" will provide some explanation about available commands.

Loading Linux

RedBoot offers several methods to download the kernel. Fastest is tftp or http over ethernet but needs a server, slowest is x/ymodem but does not need special setup (only lrzsz package). The tftp or http method is strongly recommended as it really speeds up the transfert. Setting up a tftp or http server is out of scope According to your setup, load the kernel with one of the following command:

  • using xmodem :
 
load -m xmodem -b 0x11600000 -r

  • using http (example) :
 
load -r -v -h 192.168.1.8 -m http -b 0x11600000 /zImage 

The default DS-101 IP address is 192.168.1.75, netmask 255.255.255.0. Your tftp or http server must be on a 192.168.1.0 network. The previous http load command suppose a web server is running on host 192.168.1.8 and that the linux kernel can be found at the /zImage path. Data are fetched and stored into memory at location 0x11600000 in physical RAM.

Booting Linux

It is time to cross fingers and have a pray. The "exec" command is designed to boot a linux kernel. In our case a good invocation is :

 
exec -c "console=ttyS0,115200 mem=64M@0x00000000 root=/dev/sda1 rootdelay=10" 0x11600000

You may modify the root device "/dev/sda1" according to your setup. The rootdelay option can be removed if /dev/sda1 refers the internal hard disk. In case you mount root on a USB mass storage device, the rootdelay option will instruct the kernel to wait a bit before to mount root, so that USB devices can be detected before.

And after ?

If all goes well, the boot process ends on a login prompt. Log in as root (no password), and start enjoying your new and powerful machine. Some things you will probably want to do :

  • eventually configure the network interface eth0 (see /etc/network/interfaces). default is DHCP, so it may just work
  • ipkg update, so that "ipkg install some_package" works just great

The rest is up to you.

Pre-built binaries

They are provided as is, for convenience only. You may just start with these files if you are really eager to start. Use at your own risks.

view · edit · print · history · Last edited by fcarolo.
Originally by pierrox.
Page last modified on February 04, 2008, at 09:54 PM