Lost Password? No account yet? Sign up! Why bother?
  • Narrow screen resolution
  • Wide screen resolution
  • Auto width resolution
  • Increase font size
  • Decrease font size
  • Default font size

SmallNetBuilder - Small Network Help

  
Home arrow NAS arrow NAS How To arrow How To: Hacking the Linksys NSLU2 - Part 2 - Adding NFS
How To: Hacking the Linksys NSLU2 - Part 2 - Adding NFS Print E-mail
Jim Buzbee   
August 10, 2004

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/



Tags: BYOD, Hacking, How To, Linksys, NAS, NSLU2,

Related Articles:

How To:Hacking the Linksys NSLU2 - Part 3 - Adding an iTunes server
How To: Hacking the Linksys NSLU2 - Part 4- Customizing the Flash
How To: Hacking the Linksys NSLU2 - Part 5- Moving to Unslung
Hacking the Linksys NSLU2 Part VI - Installing a Media Server
How To: Hacking the Linksys NSLU2 - Part 1
 

Most Read

 
 

Over At The Forums

Need advice which Router/AP I should use (newbe)
I am completely new to WLAN and would appreciate some help. I would like to expand my pure wire-LAN for the use with some WLAN-devices. This...

Problem with RDP over VPN
New to the SmallNetBuilder world but I like what I see. I was looking to get some suggestions to a current problem I am having...

Fios Router P2P issue? Or throttling?
Hi everyone. I am new here and have a nagging issue I hope to get resolved. I am very happy with the new 10mbps/2mbps Fios...

TP-LINK TL-WR941ND (review request)
Tim, This router is starting to make news, I was wondering if you could do a review on it. Newegg http://www.newegg.com/Product/Produc...82E16833704030 sells them for $60 bucks....

Improving Linksys WRT610N Range
Just thought that i would update, as I received the Linksys WRT610N today, yay; So far so good, I'm more than happy with it, I can...

Slideshows

QNAP TS-509 Pro D-Link DNS-343 4-Bay Network Storage Enclosure Thecus N3200 RAID 5 NAS D-Link DIR-628 RangeBooster N Dual Band Router Adtran NetVanta 3120 Buffalo LinkStation Mini More

Win This!

Enter to Win!

You could win a Trendnet TE100-MP2U 2-Port Multi-Function Print Server and IOGEAR GUIP201 USB Net ShareStation

Learn How!

 

Ldr:0.00157594680786, Rct:0.00551700592041, Sky:0.00759482383728, Tlink:0.377295970917, TopPG:0.377393960953, GQV:0.377574920654 seconds to load.