Like every other website on the planet, SmallNetBuilder uses cookies. Our cookies track login status, but we only allow admins to log in anyway, so those don't apply to you. Any other cookies you pick up during your visit come from advertisers, which we don't control.
If you continue to use the site, you agree to tolerate our use of cookies. Thank you!

Router Charts

Click for Router Charts

Router Ranker

Click for Router Ranker

NAS Charts

Click for NAS Charts

NAS Ranker

Click for NAS Ranker

More Tools

Click for More Tools

NAS How To

A Toolchain Shortcut

The thought of installing a cross-compilation toolchain instills fear in the hearts of many developers. The idea of compiling a compiler and C library and linker, plus support libraries and utilities is just too much. Fortunately in the age of the Internet, there has to be someone out there who has already gone through the pain and is sharing their effort.

For gcc cross-compilers that someone is Dan Kegel. Dan has a terrific script that starts from scratch. It downloads the required sources, patches them as necessary and builds a complete toolchain - and can do it for many different processors. I've used Dan's scripts to build a cross-compilation toolchain for the MIPS based Linksys WRT54G and it was a breeze. I've heard from at least one person that Dan's scripts will build a toolchain that produces NSLU2 compatible binaries. I highly recommend Dan's tools, but for the purposes of this article I 'm going to take a short cut.

Linksys appears to be struggling a bit with the release of source code as required under the GPL license. Many of their devices run Linux internally, but their GPL releases differ greatly. Some include a complete build environment while others like the NSLU2 have a less than complete release.

The CD that accompanies the NSLU2 has a great deal of source, but no toolchain. Fortunately, Linksys has another Linux-based device - their WRV54G Wireless-G VPN Broadband Router - that appears to be based on the same Intel IXP425 development board. Since they have released a toolchain for that product, we'll use it. Download the 125 MB (!) file and untar it in your home directory.

For me, the top of the tree looks like :

/home/jbuzbee/gpl_code_2.03

Inside this directory you'll find a file called toolchain.tgz. It looks like this was designed to be untarred from the root directory but I choose to untar it in place so as to keep all of my build environment in my home directory. After untarring it, you'll find the required compilers, linkers, include files, etc.

The binaries reside in the usr/local/openrg/armsaeb/bin directory and all have a prefix of armv4b-hardhat-linux-. I put that directory in my $PATH so I don't have to type out the full directory tree each time I compile.

Testing the Compiler

Let's try out the compiler to make sure it generates a good binary. The first thing any self-respecting C programmer writes is "Hello World", so I created a file called hello.c:

#include <stdio.h> main( int argc char *argv[] ) { printf("Hello world!n"); }

then compiled it :

# export PATH=home/jbuzbee/gpl_code_2.03/usr/local/openrg/armsaeb/bin/:$PATH # armv4b-hardhat-linux-gcc hello.c -o hello

and checked the resulting file type :

# file hello hello: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not stripped

Looks good. Now move the file over to your NSLU2 by ftp'ing it starting from your NSLU2 box. Remember to do a binary transfer and to mark the file as executable. Once it's there, try it out :

# ./hello Hello World!

It works! Now we have the ability to create and run arbitrary programs on our NSLU2. Make sure that anything you want to keep gets put on your NSLU2 hard drive. By default, the home directory for the root account is on a ram disk. Create a new directory in the normal Linux way and then put your new binary in it. For me it's :

# mkdir /share/hdd/data/jim/nslu2 # mv hello /share/hdd/data/jim/nslu2/

More NAS

Wi-Fi System Tools
Check out our Wi-Fi System Charts, Ranker and Finder!

Support Us!

If you like what we do and want to thank us, just buy something on Amazon. We'll get a small commission on anything you buy. Thanks!

Over In The Forums

Hello all......just bought an RT - AX88U from micro center......I wanted to upgrade from my technicolor Tg1862g.....and use my own router......I must ...
Main goal of this release: additional boost of the router performance as I hope (slight boost ). I succeed to change GCC compiler from the version 9....
I have been using AiMesh on over many AiMesh models for the past year and I would like to share some thoughts on AiMesh. Opinions are my own. Discussi...
Asuswrt-Merlin 384.19 beta is now available (except for the RT-AX56U which won't be available for this release, due to outdated GPL code).Aug 9th: Bet...
There was a thread here by another poster. There were some disagreements and that thread was deleted. I found the script by @Martineau on Pastebin, bu...

Don't Miss These

  • 1
  • 2
  • 3