User Tools

Site Tools


RB1xx goes OpenWRT

Here you may find relative information for getting OpenWRT on a RB1xx box.

A relative thread at the openwrt forum.

Status: It has been done !! Directions follow:

Quick HowTo

Credits go to: Andrea Conti, David Goodenough and the friendly and helpful yaffs2 development community.

* flash a recent version of RouterBoot booter if you have an older version. Version 2.7 was used in this case, flashed with xmodem.

* format the nand from the RootBoot menu

* get the netboot image and place it on the bootp directory. You may use dnsmasq for dhcp/bootp server

* select boot from ethernet from the bootloader

* after boot, get your network going. You need to have access to a web server

* mount /dev/mtdblock2 /mnt; cd /mnt; wget kernel

* cd /; umount /mnt; mount /dev/mtdblock3 /mnt; cd /mnt; wget openwrt-adm5120-2.6-rootfs.tgz

* gzip -d openwrt-adm5120-2.6-rootfs.tgz; tar xvf openwrt-adm5120-2.6-rootfs.tar; rm openwrt-adm5120-2.6-rootfs.tar; cd /; umount /mnt; sync; reboot

* select boot from nand from the bootloader and boot

* openwrt now gives life & power to your rb133 device !!

* you may find some additional packages here and here

Quick HowTo from Source [obsolete - historical purposes only]

svn co -r 7406
From: Alexandros C. Couloumbis <alex <at>>
Subject: Re: Problem with Yaffs on Routerboard RB112 and kernel 2.6.19
Newsgroups: gmane.linux.file-systems.yaffs
Date: 2007-05-17 17:56:11 GMT (10 weeks, 3 days, 20 hours and 42 minutes ago)

I am happy to announce that I finally have a RB133 booting from nand a latest
kamikaze system.  Kernel is with latest yaffs2 cvs and Andreas last
patch. A quick howto is here: 

Kernel config options follow:


# NAND Flash Device Drivers
# OneNAND Flash Device Drivers

# Memory Technology Devices (MTD)
# CONFIG_MTD_DEBUG is not set
# CONFIG_MTD_CONCAT is not set
# CONFIG_MTD_CFI_I4 is not set
# CONFIG_MTD_CFI_I8 is not set
# CONFIG_MTD_CFI_STAA is not set
# CONFIG_MTD_RAM is not set
# CONFIG_MTD_ROM is not set
# CONFIG_MTD_ABSENT is not set
# CONFIG_MTD_PCI is not set
# Self-contained MTD device drivers
# CONFIG_MTD_PMC551 is not set
# CONFIG_MTD_SLRAM is not set
# CONFIG_MTD_PHRAM is not set
# CONFIG_MTD_MTDRAM is not set
# CONFIG_MTD_DOC2000 is not set
# CONFIG_MTD_DOC2001 is not set
# CONFIG_MTD_DOC2001PLUS is not set

The Quest

Old Status: So far we are only able to netboot OpenWRT. Efforts are focussed on debuging the way RootBOOT loader reads & writes from & to the nand/yaffs combo, a quite fun quest I have to admit !!

You can get mtd-utils package here or mtd-utils source here.

scp usage

scp local_file user@host:/tmp/copy_of_lacal_file

Some good reading

NAND, YAFFS, MTD pointers & reading

Open Source ADM5120 Linux Projects & Works

Mailing Lists



RouterBoard Specifics

RouterBoard 5xx & 1xx Nand

There are 2 versions of the board. The latest version of the board has 128 meg NAND memory instead of 64. You can tell this by looking at the chip or running:

 "dmesg | grep NAND"
CHIP: HY27US08121M
DMESG: NAND device: Manufacturer ID: 0xad, Chip ID: 0x76 (Hynix NAND 64MiB 3,3V 8-bit)
DMESG: NAND device: Manufacturer ID: 0xad, Chip ID: 0xf1 (Hynix NAND 128MiB 3,3V 8-bit)

Your sytem may show “Unknown” as the manufacturer. If you have a 128 meg chip you need to have YAFFS2 support which only became available 3 days ago. You need it because it supports the new devices that have larger page sizes.

The older 64 meg device had 512 byte pages with a 16 byte OOB area per page. The new device has pages 4 times the size 2048b size - 64b OOB.

YAFFS1 only support 512b page devices.. ie the older chip.

RouterBoard RootBOOT

There is no bootloader on the RB. The bios is the bootloader.

Basically the bios treats the first 4 megs of disk as a 4 meg YAFFS partition. YAFFS is a very simplistic FS that does not really support partitioning. The partition paramaters are usually hard coded into the driver or the loader. Basically a YAFFS partition can consist of just a bunch of sequential sectors.

What happens on boot is that the bios scans the first YAFFS partition (ie the first 4 megs of your device) and runs the first ELF (linux binary) header that it finds.

You could concievably get lilo or grub or whatever to run instead of the kernel and then have it choose a kernel to boot but the issue is that neither lilo nor grub have support for MTD type file structures such as YAFFS or JFFS2. You could run ext2 on the CF card and this would make them plausable but you have to run YAFFS or JFFS2 on the NAND. It is NOT an option.

The best way to select which rootfs to boot from is to create a kernel with the appropriate settings already in it, and replace the kernel on the 4 meg boot “partition”
(to use your compact flash)

#echo root=/dev/cfa2 > kernel-parameters

(to use your onboard YAFFS NAND device )

#echo root=/dev/mtdblock1 > kernel-parameter

(now inject the paramater into the kernel binary)

#mipsel-linux-objcopy --add-section kernparm=kernel-parameters vmlinux

You can only objcopy before you strip, after you strip the kernel you cant objcopy it, the symbols to do that are gone. (Stripping is a way to reduce your kernel size by removing debug symbols. Check “man strip” for more info).

Like I mentioned, the first partitonm on the disk HAS to be a 4 meg YAFFS partition. so that the bios can handle it properly. To update the kernel on a CF or the NAND is a tricky bit of work.

To update the onboard NAND its best you have a CF OS image with YAFFS support (the one available from the routerboard site should do) and then you mount /dev/mtdblock0 on /mnt (or wherever and then overwrite the kernel thats there with

#rm /mnt/kernel
#cp vmlinux /mnt/kernel

The compact flash issue is a bit trickier. I normally use the 128 meg image and use Hexworkshop for windows to open the compact flash as a physical disk and then dump the kernel to sector 32 onwards. You can also do this with the linux utility dd with something like

#dd if=vmlinux of=/dev/sda bs=512 seek=32

Note that this method does NOT work for the NAND device as the NAND device may contain physical errors (this is normal) that need to be skipped by the YAFFS driver. NB: using dd on your nand is VERY BAD.

Recovering routerOS back to NAND flash

Download the netinstall & routeros-xx.npk
unzip the netinstall file
run netinstall.exe wine works also quite well
on the routerboard select boot from ethernet & bootp protocol
on the netinstall application select the routeros-rb500 package
press net booting & select boot server enable, put a free IP from the subnet of your LAN
press ok
on the routerboard press letter "x" in order to proceed with net boot
you should get the IP you gave above & the net boot will start
after the net boot yoy will see a mac address on the window
select the mac address and press install
when installation is finished, exit the netinstall application
and press enter on the routerboard in order to reboot the new routerOS

NetBoot HowTo

1. Hardware

The board comes with a MIPS32 4Kc based 175MHz embedded processor, Infineon ADM5120.

There are currently 5 boards in this range:-

 1. 112 The original 1xx board, two mini-pci, 16MB RAM, 64MB NAND Flash, one ethernet, no CF
 2. 133 Three mini-pci, 32/16MB RAM, 128/64MB NAND Flash, three ethernet, no CF
 3. 133c One mini-pci, 32/16MB RAM, 128/64MB NAND Flash, one ethernet, no CF
 4. 150 No mini-pci, 32MB RAM, 64MB NAND Flash, five ethernet, no CF
 5. 153 Three mini-pci, 32MB RAM, 64MB NAND Flash, give ethernet, one CF 

2. Installation

Installing OpenWrt on these boards (apart from the 153) is only possible by using the NetBoot facility. For this you will need a serial connection as console, and an ethernet connection to load the kernel and then download the flash image. You will also need to have BOOTP and TFTPD servers on your machine. This can be done either using independent packages or using DnsMasq. You will also need a Web server.

The minicom settings for a connection using a USB serial port would be:-

# Machine-generated file - use setup menu in minicom to change parameters.
pu port             /dev/ttyUSB0
pu backspace        BS
pu baudrate         115200
pu bits             8
pu parity           N
pu stopbits         1
pu scriptprog       /usr/bin/runscript
pu minit
pu mreset
pu mdialpre
pu mdialsuf
pu mdialpre2
pu mdialsuf2
pu mdialpre3
pu mdialsuf3

Unfortunately you need to build two kernels in order to install this system. The first has a RAMDISK built into it so that you can download it using the Netboot facility and have a working system without a disk, and the second is the one that is going to be installed on the flash and will be your running kernel.

All the building happens under the ADM5120-2.6 target, so the first thing you need to do is to download an SVN copy of OpenWrt Kamikaze, and then run make menuconfig.

As the ADM5120 support is currently under development you need to tell menuconfig that you wish to work with broken targets, you do this in the Advanced Options for Developers section.

Now select the ADM5120-2.6 target. Then in the Target Images section select RAMDISK. This will disable all the other image options.

There is no need to make package selections at this stage as all the packages you will need to install the system are there by default.

Save the configuration and run make (this will take a while).

You should now have a file in the bin directory called openwrt-adm5120-2.6-vmlinux.elf, and this should be copied to your TFTPD directory.

Now you need to build the running image, and for this you will need to run make clean (to get rid of the old settings) and then run make menuconfig again. This time select TAR as the Image type. Once you have completed the configuration you can run make (and once again wait a while).

You can at this stage go through and select the packages that you are actually going to want (although you can always add them later with ipkg).

This time you will find a file in the bin directory called openwrt-adm5120-2.6-rootfs.tgz, and the kernel will be in build_mipsel/linux-2.6.19-adm5120 (or whatever the current kernel is) and will be called vmlinux.elf. Copy these two files into a directory which can be reached by your web server as openwrt-adm5120-2.6-rootfs.tgz and openwrt-adm5120-2.6-vmlinux.

Now you can power up your RB1xx and download the kernel. At this stage you are using the first kernel you produced above.

When you boot the RB1xx, go into the BIOS settings and say that you want to use Netboot rather than using the NAND as the boot source.

When the kernel is booted hardly any of the normal OpenWrt initialisation occurs - you will not find that modules have been loaded or the network configured.

In /sbin however you will find a script called wget2nand which will do the installation for you, using the second kernel and the flash image.

wget2nand takes a single parameter, the URL of the directory into which the tgx and vmlinux files were stored. wget2nand assumes you are still running DnsMasq (or whatever was your Bootp server) and that it will also serve addresses using DHCP.

When you reboot you need to change the BIOS settings back to booting from the NAND.

Once the installation is complete then you can reboot your RouterBoard 1xx card and you should have a running system.


NAND is a certain type of flash chip types. It differs in some points to the somewhat older NOR flash commonly used in all Broadcom devices. See here for more information.

YAFFS was written to satisfy the special needs of NAND flash. Originally JFFS2 was taken as basis, which itself improved (not least in form of JFFS3) to better support NAND flash, too.

The second release of YAFFS especially points to supporting newer NAND flash chips with 2k page size and up to 128MB capacity.

Installing FreeWRT Into RouterBoard's NAND Flash

Installation is done nearly the same way as with CompactFlash. So to get direct access to the NAND flash (to be able to mount it e.g.), there needs to be an already running version of FreeWRT somewhere. It's up to your choice if that's a CompactFlash disk or a NFSRoot for netbooting. You just have to make sure there is enough free space on either medium to hold the RootFS tarball.

After booting into the existing Operating System, just mount the second (i.e. root) partition:

mount /dev/mtdblock1 /mnt

The filesystem type should be selected automatically, in doubt you can also use -t yaffs2. If you're getting errors about unerased or retired blocks, you must erase the flash before use, as the data on it is somehow corrupted.

Then you need to unpack the tarball into the mounted partition. It's your choice if you like to specify the target as parameter to tar, or if you just cd into the dir first. Following is the first method:

tar xvzfp /rootfs-2.6-rb-yaffs2.tar.gz -C /mnt

After unpacking, all there is left to do is executing the script called '' in the newly created RootFS's topdir. In our example this is as follows:


This script will do a few things at once:

  • copies over the necessary device nodes from /dev (there is no 'mknod' in the default installation)
  • recursively changes the owner of all entries to root
  • mounts the first flash partition, copies the kernel into it and unmounts it again

After this is done, you can unmount the partition and reboot. After giving 'boot from NAND' as default boot medium inside RouterBOOT, FreeWRT should come up from flash.

Erasing The NAND Flash

Probably the most simple way of doing this is via RouterBOOT. Besides for version 1.5 (which you can't download anyway), there is a menu option 'format nand' doing the job. Alternatively the binaries 'flash_erase' and 'flash_eraseall', contained in the mtd-utils project work fine, too.


Here are some things you can check if your device disagrees with you about how it should behave.

You can simply mount the first partition and check if there is a file named “kernel” (yes, actually it is your kernel). RouterBOOT searches for it with exactly this name in the first partition's filesystem's root directory.

Mount the second flash partition and check the RootFS. E.g. check if there are device nodes in /dev.

If you have a bare RootFS and don't know whether it is for use with NFS, CompactFlash? or YAFFS2, just open the script '' in the filesystem's topdir. The variable 'MYTARGET' holds the filesystem type the RootFS (and especially it's kernel) is ment for. (The value is written into it at install time.)

YAFFS2 And NAND Quirks

Both memory type and filesystem have some special properties one should be aware of to not getting surprised someday.

Page and erase size: as already mentioned above, page sizes can vary from 512Bytes to 2kBytes. The erase size for large page devices though is 128kBytes. To prevent excessive wear, if less than a full erase block is written to flash and deleted after, the block is not erased immediately. This not done until the whole block is full of invalid data. This gets visible when writing a few small files to disk. Used space (as reported by 'df') increases a lot with the first file (more than it's size), and doesn't increase at all when all other files are written.

Checkpoints: To improve mount time, yaffs2 has a feature called 'checkpoints'. These Checkpoints are blocks of meta information held in the filesystem itself. You could statically reserve a count of blocks for this meta information (by editing the source code ;), but FreeWRT let's this count in/decrease dynamically. So if you write lot's of data to your partition, the overhead increases reasonably (only viewable after remounting, as Checkpoints get written at unmount time). But as more data gets written to disk, these Checkpoints are one after another forgotten, and the space covered by them gets available for normal data.


RouterBoard linux install sdk

This guide will describe procedures needed to install Debian GNU/Linux distribution on RouterBOARD 500 series computers over network, as well as provide some information needed to use RouterBOARD 500 boards on that GNU/Linux system.

Note that these instruction were tested with Debian 3.0 “Woody” release and might not apply to other releases

Making Debian installer

Kernel image and drivers.tgz

Every architecture has its own rescue.bin floppy image and drivers.tgz. Both of them are used to get kernel with drivers on a system. rescue.bin is a simple ext2 image that contains linux kernel. It is also used as a rescue floppy. drivers.tgz is a tar archive with driver modules. Our MIPS system is not recognised, so it is named “unknown”.

Original files are located at: r3k-kn02 architecture was used as an sample.

  • rescue.bin contains “/” that is executed during installation. It should copy kernel to the directory provided as its first argument. It contains “type.txt” file (that has word “rescue” in it). It also creates a simple script “/sbin/delo”, to emulate DEC loader, that simply copies “/vmlinux” to “/dev/cfa1”.
  • drivers.tgz also contains “/” that is executed during installation. It should copy all the kernel modules (the current one doesn't have any modules). Currently it also creates “/dev/cfa” and “/dev/cfa{1,2,3,4}”, since regular Debian /dev system does not have them.

To upgrade kernel, rescue.bin should be mounted and the new kernel should be copied over. Note that “root_fs” kernel parameter should be “/dev/cfa2”.

Debian Installer (boot-floppies)

We are using the old woody installer known as boot-floppies. It is contained in root.tgz located at: All of its contents should be copied in to initrd image. initrd should be at least 8Mb (otherwise it won't have enough space).

To create initrd:

dd if=/dev/zero of=initrd bs=1024 count=8192
/sbin/mke2fs -F -b 1024 initrd

Copy all stuff into initrd:

mkdir mnt
mount initrd -o loop=/dev/loop0 mnt
cd mnt
unpack root.tar.gz
mv debian-mipsel-root/* .
rm -rf debian-mipsel-root

Remove unneeded file:

rm linuxrc

Add /dev/cfa:

mknod dev/cfa b 13 0
mknod dev/cfa1 b 13 1
mknod dev/cfa2 b 13 2
mknod dev/cfa3 b 13 3
mknod dev/cfa4 b 13 4

Remove installation of delo:

sed -i s/delo// usr/lib/debootstrap/scripts/woody

Make initrd.gz

cd ..
umount mnt
gzip initrd

Compile kernel patched with the provided patch. A congifuration file “.config” should be present in the kernel directory. The kernel patch may have created it under different name, so you might need to rename it.

make ARCH=mips oldconfig vmlinux

take vmlinux and rename it to linuxrc. Then make a boot TFTP image:

echo "root=/dev/ram0" >kernel.params
mipsel-linux-uclibc-objcopy --add-section kernparm=kernel.params linuxrc
mipsel-linux-uclibc-objcopy --add-section initrd=initrd.gz linuxrc

To make regular boot kernel, take another copy of vmlinux

echo "root=/dev/cfa2" >kernel.params
mipsel-linux-uclibc-objcopy --add-section kernparm=kernel.params vmlinux

Then use DHCP & TFTP to make board boot with etherboot into linuxrc and Debian installation can start.

Setting up the Installation Server

First to install the RouterBOARD system, you need to prepare installation server which will provide initial boot image for the device. A BOOTP/DHCP server and a TFTP server must be installed on the installation server. The RouterBOARD should also receive an IP address which will allow it to use DNS and HTTP protocols to access the Internet.

We used the ATFTPd TFTP server, which does not require configuration (except, perhaps, the TFTP root directory), and ISC DHCPd version 3 DHCP server.

The DHCP configuration used to boot up the RouterBOARD computer that has 00:09:22:22:22:00 MAC address on the Ethernet port, which is connected to the network:

default-lease-time 21600;
max-lease-time 2100;
host rb500 {
  hardware ethernet 00:09:22:22:22:00;
  filename "/linuxrc";
subnet netmask {
  option subnet-mask;
  option broadcast-address;
  option routers;

Note that the DHCP and TFTP server itself has the IP address of, and the default gateway for the network is

You should place the linuxrc file (which you can get at in the TFTP root directory, so that the RouterBOARD would be able to download it.

Preparing the RouterBOARD

The board has to be properly powered. We will use the first Ethernet port for booting the device. Serial console cable must be connected, and you will need some kind of terminal emulator program to interact with the RouterBOARD (like HyperTerminal for Windows or minicom for GNU/Linux). The GNU/Linux will be installed on a CompactFlash drive that you should insert in the appropriate connector on the RouterBOARD. Please note that minimal size of the CompactFlash device for a normal GNU/Linux installation is 128MB

You should also configure its BIOS so it could boot from network:

What do you want to configure?

 d - boot delay
 k - boot key
 s - serial console
 o - boot device
 m - memory test
 u - cpu mode
 f - try cpu frequency
 c - keep cpu frequency
 r - reset configuration
 g - bios upgrade
 a - mac addresses
 p - boot protocol
 t - do memory testing
 x - exit setup

your choice: p - boot protocol

Press 'p' and select the booting protocol:

Choose which boot protocol to use: * 1 - bootp protocol

 2 - dhcp protocol

your choice: 2 - dhcp protocol

Select '2' for DHCP

Then press 'o' to select boot device:

Select boot device:

 e - boot over Ethernet
 n - boot from NAND

* c - boot from CF

 b - boot chosen device

your choice: e - boot over Ethernet

You need to select 'e' here.

Initial installation (first stage)

Now, if the installation server was configured correctly, the “Release Notes” screen should appear on your terminal console. If you do not see the “Release Notes” screen, please check your server configuration (perhaps, log files will be of a help), the linuxrc file and the serial console settings.

Please follow this step-by-step instruction to install the base system on the CompactFlash drive:

  • On the “Release Notes” screen press “<Continue>”
  • Select “Partition a Hard Disk”
  • <ENTER> on “/dev/cfa”
  • Configure partitions. The first partition should be 4Mb big with type 27. The second partition will be the root partition, and if you will not have any other data partitions, it should be at least 120MB big, or the installation procedure will fail. You can configure additional partitions (like separate /usr or a swap partition) as required. After you create the partitions, choose “Write”, then type “yes” and choose “Quit”
  • If no SWAP partition was created, select the alternative “Do Without a Swap Partition” step, and answer “<Yes>” on “Do Without a Swap Partition” question
  • Select “Initialize a Linux Partition”
  • Select ext2 or ext3. Note: on a 128MB medium there is not enough space for making ext3 filesystem
  • On “Scan for Bad Blocks?” it is safe to just say “<No>”
  • On “Are You Sure?” say “<Yes>”
  • On “Mount as the Root Filesystem?” say “<Yes>”
  • Select “Install Kernel and Driver Modules”
  • On “Select Installation Medium” say “network”
  • On “Network Not Yet Configured” say “<Continue>”
  • On “Choose the Hostname” you can leave “debian” (press <Enter>)
  • On “Choose Network Interface” select “eth2”
  • On “Confirmation” about whether the “eth2” is a PCMCIA card, say “<No>” as it is not a PCMCIA card
  • On “Automatic Network Configuration” say “<Yes>” if DHCP server should be used to assign IP address automatically, or “<No>” for static IP address configuration; If DHCP failed or “<No>” was selected, follow the instructions on screen to configure the IP address andmake sure to type correct IP address of the DNS server.
  • On “Fetching installation files over the network” select “<Continue>”
  • On “Select Installation Server” type “” in “Download URL” field. DO NOT LEAVE IT AS DEFAULT. Type in Proxy address if you have one.
  • Select “Configure Device Driver Modules”
  • On “Note about loaded drivers” select “<Continue>”
  • Ignore errors and select “Exit Finished. Return to previous menu.”
  • Select “Install the Base System”
  • On “Select Installation Medium” select “network”
  • On “Select Installation Server” type “” (or some other Debian mirror) in “Download URL”. DO NOT LEAVE IT AS DEFAULT. Type in Proxy address if you have one. NOTE that some mirrors do not have mipsel architecture (for example, in Latvia you would have to use Estonian mirror:
  • Select “Make System Bootable”
  • Select “Reboot the System”
  • On “Reboot the system?” say “<Yes>”

Now the first-stage installation ir completed, and you will need to switch the BIOS settings to boot from the newly installed CompactFlash:

What do you want to configure?

 d - boot delay
 k - boot key
 s - serial console
 o - boot device
 m - memory test
 u - cpu mode
 f - try cpu frequency
 c - keep cpu frequency
 r - reset configuration
 g - bios upgrade
 a - mac addresses
 p - boot protocol
 t - do memory testing
 x - exit setup

your choice: o - boot device

Select baud rate for serial console: * e - boot over Ethernet

 n - boot from NAND
 c - boot from CF
 b - boot chosen device

your choice: c - boot from CF

Configuring base system (second stage)

Now when the packages are installed, some configuration is needed. As the configuration questions depend on the versions of software that will be current when you will be installing it, and also as you might want not to agree to the proposed configuration, there is no step-by-step instructions given for this stage, just some recommendations:

  • It is very unlikely you will need to answer “<Yes>” to the “Do you want to use a PPP connection to install the system?” question, so we suggest to answer “<No>” there
  • In “Apt Configuration” question about apt method to access the Debian archive you will need to answer either “http” or “ftp” and later select the correct installation mirror from the list
  • For the next questions in case you are installing the system on a small storage device (like 128MB), it is recommended that you do not choose to use non-US and non-free software and not allow security updates from, as you may not have enough space to use them
  • It is highly recommended also not to use tasksel and dselect even if you have a storage device as large as 256MB - it is better to install everything later on manually using apt utility
  • When prompted to configure exim, you may answer “5” to leave the package unconfigured if you do not plan to use exim. You can complete the configuration or remove the exim later on

Now you have a working system. Some useful recommendations on how to free up some space and how to install something on this system are given in the next section of this manual

Fine-tuning the system (third stage)

This section describe some steps to get more of your system. These steps are most useful when installing on a small medium (like 128MB CompactFlash).

 1. First of all, lets remove some unneeded packages. Run "apt-get remove ppp pppconfig tasksel setserial info nvi pppoe pppoeconf ed fdutils bsdmainutils adduser man-db console-common gettext-base groff-base manpages modconf libreadline4 libgdbmg1". If you do not need telnet, you can also remove "telnet" package.
 2. Use "nano /etc/apt/sources.list" to comment out all unneeded apt sources. Lines starting with "deb-src" may probably be commented if you do not want to recompile Debian packages yourself. Also change "stable" to "testing" in this file so that more packages would be available for you (the current stable release does not have many useful packages for the mipsel architecture)
 3. Run "apt-get update" for apt to update its package cache (and free up some space). On a 128MB module you should now have about 25 to 30 MB free (check with "df"). If not, try doing "apt-get clean; rm -rf /var/lib/dpkg/*-old".
 4. Install debconf-english to get rid of Debian configuratio internationalization ant then install localepurge program which will clean up some more by removing unneeded locales and translated man pages. You can do this with "apt-get install debconf-english; apt-get install localepurge debconf-english". This will upgrade some existing packages as well as install some new ones. Do not select any locales, and choose to remove localized man pages. Run "apt-get clean; rm -rf /var/lib/dpkg/*-old" after installation.
 5. Previous update may have left one legacy package, so let's remove it: "apt-get remove libnewt0"
 6. You may also want to replace a somehow bloated version of nano with a smaller one: "apt-get remove nano; apt-get install nano-tiny"
 7. Now you can install other packages you need (like ftp, ssh, mc, ...). For example, we used the additional "apt-get install ftp ssh mc" command before generating our ready-to-use GNU/Linux images. Do not forget doing "apt-get clean; rm -rf /var/lib/dpkg/*-old" each time after installing packages to free up space used by temporary files and package archives
 8. If you have more than 60MB left free (i.e., if you are not using 128MB medium, which will still have only 25MB left after all these magic tricks), you are advised to complete upgrade to the testing release by issuing the "apt-get dist-upgrade" command. Also there is a good apt frontend called aptitude, which you can use to further manage the packages.

If you need to configure network later, please edit file called “/etc/network/interfaces”. The syntax is selfexplanatory, and you will also be able to find many manuals on how to configure it.

Now you have a standard Debian GNU/Linux system with almost maximum free space it is possible to get. Please note that we do not provide support service or training of any kind for this system - you will just have to find all necessary information how to work with this system by yourself.

Using RouterBOARD 500 specific functions

Boot image

The RouterBOOT boot loader can load and execute an ELF image from the selected medium (either onboard NAND, or CompactFlash device). This image must be compiled for “mipsel” (little-endian MIPS) architecture. If you are compiling it on a non-mipsel computer (for example, on an Intel IA-32 PC), you will need a crosscompiler, which you will have to make by yourself (see, and Google for more information).

In case the ELF image you want to boot is Linux kernel, you should remember the following:

  • the boot loader supports ELF images, not compressed with zip, 9-zip, gzip, bzip2 or any other compression algorithm, which does not provide ELF image as its output format
  • you might need to set some kernel parameters, so that it knows at least what root file system it should boot from. Use “kernparm” ELF section to embed kernel parameters into the kernel, for example to boot the kernel from a CompactFlash device, try:
echo root=/dev/cfa2 > kernel-parameters
mipsel-linux-objcopy --add-section kernparm=kernel-parameters vmlinux
  • You might also want to have the kernel to use an initial RAM disk. To do this, make a gzipped archive of a supported filesystem (like ext2) image, and add it just like kernel parameters in the previus example, but in this case ELF section name would be “initrd”

Loading ELF image from CompactFlash device

RouterBOOT loads contents of first partition with type 39 (0x27). If there is no such partition, it displays message “CF BOOT FAILURE: kernel partition missing!”. There is no filesystem on this partition, it contains raw ELF image, so it can be copied using the “dd” utility. The partition may have any size if it is correctly stated in the partition table.

Loading ELF image from NAND device

RouterBOOT treats first 0x400000 bytes (4 megabytes) of the onboard NAND chip as a partition with yaffs filesystem. No partition table is stored on NAND, so location and size of this first partition is hardcoded in the RouterBOOT loader. It searches for a regular file in the root directory, named “kernel”. If it is not found, RouterBOOT displays message “kernel not found”, otherwise it prints “loading kernel from nand”. If there is error loading this file, it displays “data is corrupted”.

To access partition that contains kernel:

mount -t yaffs /dev/mtdblock0 /mnt

To access the second NAND partition, that is used by kernel as root filesystem when booting from nand:

mount -t yaffs /dev/mtdblock1 /mnt

Safest way to access NAND is through filesystem. It is not supposed to be accessed by the standard utilities such as “dd” to write directly to /dev/mtd0 and /dev/mtd1, because these utilities do not update ECC, do not check for bad blocks and do not perform other NAND-specific operations. For direct access use “flash_eraseall”, “nanddump” and other utilities from linux-mtd toolkit (

The kernel is in a separate partition because to access files on yaffs partition, you need to scan the whole partition. Yaffs is very fast in this respect, but it still takes time and memory (~32 k for every megabyte). Bigger partition means slower booting. Note that if you compile your own yaffs code (not from the linux kernel patch provided on, you must use the same yaffs compilation flags, especially those related to ECC.

What paremeters does RouterBOOT pass to kernel

RouterBOOT appends some kernel parameters that contain information about board and startup configuration. Here is the meaning of some of them:

  • gpio - contains value of GPIO register that is read by RouterBOOT during bootup with disabled serial port. It can be used to determine state of S1 button and JP1 jumper. Bit 1 (mask 0x0002) is the state of the S1 button, bit 3 (mask 0x0008) is the state of the JP1 jumper. 1 means open, 0 means closed/pressed. Example: gpio=16383 (neither JP1 nor S1 is closed)
  • console - used to pass serial port settings to kernel. This is standard kernel parameter. Example: console=ttyS0,115200
  • mem - used to pass amount of on-board RAM. This is a standard kernel parameter. Example: mem=32M

Accessing the User LED

There is a “changeLatchU5” function in the patched kernel, which is defined in “linux/arch/mips/rc32434/rb500/rb.c” and declared in “linux/include/asm-mips/rc32434/rb.h”

  • to turn led on: changeLatchU5(LO_ULED, 0);
  • to turn led off: changeLatchU5(0, LO_ULED);

Accessing the GPIOs

JP1 is connected to GPIO pin 3, S1 to GPIO pin 1. These are also used for serial port, so it should be disabled before reading GPIO state at runtime. For details on GPIO access consult the IDT manual. The same function of the patched kernel used for changing LED states, can be used to disable serial port:

  • To disable serial port: changeLatchU5(0, LO_FOFF);
  • to enable serial port: changeLatchU5(LO_FOFF, 0);

Creating a netboot image

Keywords: mknbi, objcopy, kernparm

1.      Build a custom kernel vmlinuz for the unit under test.
2.      Create an empty file initrd, the size of the initial RAM disk.
3.      Make a Linux file system on initrd.
4.      Mount initrd on a temporary directory initrd.d using the loopback device option –o loop.
5.      Populate the file system mounted on initrd.d.
6.      Unmount initrd, leaving behind the initial RAM disk file initrd.
7.      Compress initrd with gzip.
8.      Merge the kernel and initial RAM disk into a tagged image file.

Embedding rootfs for a 2.4.x kernel

dd if=/dev/zero of=/boot/initrd bs=1M count=16
mke2fs -F -m 0 -b 1024 /boot/initrd
mkdir /mnt/initrd
mount -t ext2 -o loop /boot/initrd /mnt/initrd
cp -a /rootfs/* /mnt/initrd/
pushd .
cd /mnt/initrd/
mknod dev/null c 1 3
mknod dev/tty c 5 0
mknod dev/console c 5 1
mknod dev/cfa b 13 0
mknod dev/cfa1 b 13 1
mknod dev/cfa2 b 13 2

mknod dev/mtd0 c 90 0

mknod dev/mtd1 c 90 2
mknod dev/mtdblock0 c 31 0
mknod dev/mtdblock1 c 31 1
mknod dev/ram0 b 1 0
mknod dev/ram1 b 1 1
mknod dev/mem c 1 1
mknod dev/kmem c 1 2
mknod dev/zero c 1 5
cd dev
ln -s ram0 ramdisk
ln -s ../proc/kcore kcore
cd ..
chown -R 0:0 *
chmod 1777 tmp/
chmod u+s bin/busybox
popd .
umount /boot/initrd
gzip /boot/initrd
mkelf-linux build_mipsel/linux-2.4-rb/vmlinux --output=kernel --rootdir=/dev/ram0 /boot/initrd.gz
rdev zImage /dev/ram0
mknbi-linux zImage --output=kernel --rootdir=/dev/ram0 /tmp/initrd

mkelf-linux is not working for me, so here is another way:

Kernel compilation and setup

Now we have an initial ramdisk that can be directly linked with our kernel. I am not going to go into great detail here on how to build a kernel for the BE (there is plenty of information on this elsewhere). First cd into the root of your kernel sources and copy the gzipped ramdisk, initrd.gz, to arch/mips/ramdisk/ramdisk.gz.

cp ../initrd.gz arch/mips/ramdisk/ramdisk.gz

Now build the kernel as you would normally and make sure you include the options ramdisk, initial ramdisk, and embed root filesystem ramdisk into the kernel. If you plan on following the PicoGUI tutorial you will also need to add TCP/IP Networking support. You should also make sure that the default ramdisk size is equal to the size of you ramdisk in 1k blocks.

Once you have built the kernel copy the kernel to your BE or compact flash card with the bootloader and bootloader config (cyacecfg.txt) , and make sure your bootloader config has the proper append line (append=console=tty0 console=ttyS0,9600 root=/dev/ram). At this point you may want to hook your BE up to your serial port (if you have the serial cable) and start up minicom or some other terminal program. Start up the bootloader and be amazed!

echo "Making '$1-cfa2' from '$1' for CF"
objcopy --add-section kernparm="root=/dev/cfa2" $1 $1-cfa2

echo "Making '$1-nfs' from '$1' for NFS"
objcopy --add-section kernparm="root=/dev/nfs nfsroot= ip=dhcp" $1 $1-nfs

Embedding rootfs in the kernel

echo root=/dev/ram0 rw gpio=16375 console=ttyS0,115200 >kernel.params
mipsel-linux-uclibc-objcopy --add-section kernparm=kernel.params vmlinux
mipsel-linux-uclibc-objcopy --add-section initrd=rootfs.gz vmlinux

strip vmlinux

mipsel-linux-strip vmlinux

Embedding rootfs for a 2.6.x kernel

find /rootfs | cpio -o -H newc | gzip > initramfs.gz
mkimage -n 'Linux 2.6 and initramfs' -A mips -O linux -T multi -C gzip -a 0x00000000 \
-e 0x00000000 -d $(OUTPUT_DIR)/kernel/vmlinux.gz:$(OUTPUT_DIR)/images/initramfs.gz \

The kamikaze way

make[5]: Leaving directory `build_mipsel/linux-2.6-rb532/linux-'
mipsel-linux-uclibc-objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S \
build_mipsel/linux-2.6-rb532/linux- build_mipsel/linux-2.6-rb532/vmlinux                                                                                                                                                          
mipsel-linux-uclibc-objcopy -R .reginfo -R .note -R .comment -R .mdebug -S \
build_mipsel/linux-2.6-rb532/linux- build_mipsel/linux-2.6-rb532/vmlinux.elf                                                                                                                                                                   
touch build_mipsel/linux-2.6-rb532/linux-                                                                                                             
make[4]: Leaving directory `target/linux/rb532-2.6'                                                                                                                  
make[3]: Leaving directory `target/linux'                                                                                                                            
make -C linux/rb532-2.6/image compile                                                                                                                                
make[3]: Entering directory `target/linux/rb532-2.6/image'                                                                                                           
cc -o staging_dir_mipsel/bin/patch-cmdline target/linux/rb532-2.6/src/patch-cmdline.c                                                                                
make[3]: Leaving directory `target/linux/rb532-2.6/image'                                                                                                            
make -C linux/rb532-2.6/image install                                                                                                                                
make[3]: Entering directory `target/linux/rb532-2.6/image'                                                                                                           
cc -o staging_dir_mipsel/bin/patch-cmdline target/linux/rb532-2.6/src/patch-cmdline.c                                                                                
cat build_mipsel/linux-2.6-rb532/vmlinux | staging_dir_mipsel/bin/lzma e -si -so -eos -lc1 \
-lp2 -pb2 > build_mipsel/linux-2.6-rb532/vmlinux.lzma                                                                                                                                                                                          
LZMA 4.32 Copyright (c) 1999-2005 Igor Pavlov  2005-12-09                                                                                                            
make -C target/linux/generic-2.6/image/lzma-loader KDIR=build_mipsel/linux-2.6-rb532 \
LOADADDR=0x81000000 KERNEL_ENTRY=0x80101000 RAMSIZE=0x00100000 IMAGE_COPY=1 clean compile                                                                                                             
make[4]: Entering directory `target/linux/generic-2.6/image/lzma-loader'                                                                                             
rm -rf build_mipsel/linux-2.6-rb532/loader-0.05                                                                                                                      
rm -f build_mipsel/linux-2.6-rb532/loader.elf                                                                                                                        
mkdir build_mipsel/linux-2.6-rb532/loader-0.05                                                                                                                       
cp -fpR ./src/* build_mipsel/linux-2.6-rb532/loader-0.05/                                                                                                            
touch build_mipsel/linux-2.6-rb532/loader-0.05/.prepared                                                                                                             
cp -fpR build_mipsel/linux-2.6-rb532/vmlinux.lzma \
make -C build_mipsel/linux-2.6-rb532/loader-0.05 \                                                                                                                                                    
CC="mipsel-linux-uclibc-gcc" CROSS_COMPILE="mipsel-linux-uclibc-" \                                                                                                  
RAMSIZE=0x00100000 \                                                                                                                                                 
LOADADDR=0x81000000 \                                                                                                                                                
KERNEL_ENTRY=0x80101000 \                                                                                                                                            
make[5]: Entering directory `build_mipsel/linux-2.6-rb532/loader-0.05'                                                                                               
mipsel-linux-uclibc-gcc -fno-builtin -Os -G 0 -ffunction-sections -mno-abicalls -fno-pic \
-mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -Wall \
-DRAMSTART=0x80000000 -DRAMSIZE=0x00100000 -DKERNEL_ENTRY=0x80101000 -D_LZMA_IN_CB \
-DLOADADDR=0x81000000 -DIMAGE_COPY=1 -c start.S -o start.o
mipsel-linux-uclibc-gcc -fno-builtin -Os -G 0 \
-ffunction-sections -mno-abicalls -fno-pic -mabi=32 -march=mips32 -Wa,-32 -Wa, \
-march=mips32 -Wa,-mips32 -Wa,--trap -Wall -DRAMSTART=0x80000000 -DRAMSIZE=0x00100000 \
-c decompress.c -o decompress.o 
mipsel-linux-uclibc-gcc -fno-builtin -Os -G 0 -ffunction-sections -mno-abicalls -fno-pic \
-mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -Wall \
-DRAMSTART=0x80000000 -DRAMSIZE=0x00100000 -DKERNEL_ENTRY=0x80101000 -D_LZMA_IN_CB \
-DLOADADDR=0x81000000 -DIMAGE_COPY=1 -c LzmaDecode.c -o LzmaDecode.o
sed -e 's,@LOADADDR@,0x81000000,g' -e 's,@ENTRY@,_start,g' >                                                                                    
mipsel-linux-uclibc-ld -r -b binary --oformat elf32-tradlittlemips -o kernel.o vmlinux.lzma
sed -e 's,@LOADADDR@,0x81000000,g' -e 's,@ENTRY@,entry,g' >                                                                               
mipsel-linux-uclibc-ld -static --no-warn-mismatch -e entry -o temp-lzma.o \
decompress.o LzmaDecode.o kernel.o ipsel-linux-uclibc-objcopy -O binary -R .reginfo \
-R .note -R .comment -R .mdebug -S temp-lzma.o lzma.tmp 
mipsel-linux-uclibc-ld -no-warn-mismatch -T -r -o lzma.o -b binary lzma.tmp \
--oformat elf32-tradlittlemips sed -e 's,@LOADADDR@,0x80101000,g' \
mipsel-linux-uclibc-ld -s -o lzma.elf start.o lzma.o
make[5]: Leaving directory `build_mipsel/linux-2.6-rb532/loader-0.05'
cp -fpR build_mipsel/linux-2.6-rb532/loader-0.05/lzma.elf \
make[4]: Leaving directory `target/linux/generic-2.6/image/lzma-loader'
find build_mipsel/root -type f -not -perm +0100 -not -name 'ssh_host*' | xargs -r chmod 0644
find build_mipsel/root -type f -perm +0100 | xargs -r chmod 0755
find build_mipsel/root -type d | xargs -r chmod 0755
mkdir -p build_mipsel/root/tmp
chmod 0777 build_mipsel/root/tmp
cp -fpR build_mipsel/linux-2.6-rb532/loader.elf bin/openwrt-rb532-2.6-vmlinux
make[3]: Leaving directory `target/linux/rb532-2.6/image'
welcome.txt · Last modified: 2010/01/27 14:03 (external edit)