Tcl on the Slug

TP The Slug is the affectionate name for the Linksys NSLU2 [L1 ]:

http://www.linuxdevices.com/files/misc/linksys_nslu2-thm.jpg http://www.linuxdevices.com/files/misc/linksys_nslu2_board-sm.jpg

Out of the box, the NSLU2 is a network attached storage appliance utilizing USB 2.0 disk storage (2 ports), connecting via 10/100 mb ethernet. Its primary function is to offer a simple SMB network storage device for Windows or Samba users. The device runs a version of Linux, and all administration is done via a web interface. An ARM 5 (Intel IXP420) running at 133 Mhz powers the box, with 8mb flash and 32mb ram. Any USB 2.0 mass storage device can be plugged in, e.g., a flash thumb keychain drive or a disk drive mounted in a USB enclosure.

What's cool is that the Slug is entirely hackable, made possible by the NSLU2-Linux group [L2 ]. By reflashing the firmware with Unslung [L3 ] or OpenSlug [L4 ], the box is capable of serving as an ordinary Linux server. The primary difference between the Unslung and OpenSlug firmware is that the Unslung firmware retains the stock functionality and web administration interface, OpenSlug removes that capability.

After reflashing with either firmware, telnet and/or ssh access can be enabled. Once logged into the Slug, a package tool ipkg can be used to install additional software onto a connected USB drive. A large number of software packages are available for easy installation [L5 ] Many of the packages have been cross-compiled on a host Linux box, but native development is also possible [L6 ]. Be sure to read all of the installation procedures before you reflash with Unslung (or OpenSlug).

There is an existing Tcl package, but I had problems running it with the current release of the Unslung firmware (5.5beta). After installation, ipkg install tcl , running the tclsh8.4 binary results in:

 # tclsh8.4
 application-specific initialization failed: can't upvar from variable to itself

However, Tcl can be built using the native development toolchain [L7 ] just as on any other machine by downloading Tcl (8.4.11) from SourceForge, unpacking, and:

 cd tcl8.4.11/unix
 ./configure --prefix=/opt
 make
 make install

As I have more time, I'll try to submit the appropriate Tcl package fixes back to the NSLU2-Linux project. I am also planning to port additional Tcl software to the Slug. Note that /opt is the conventional directory tree to install packages and other software.

One of the first things you can do with your Slug is to allow it to run at full speed, 266 mHz. Linksys (for some reason) decided to under-clock the processor. A fairly simple hardware mod, removing one easily acccessed resistor, allows the Slug to run at full speed [L8 ]. I used an X-Acto knife to carefully cut the solder traces around the resistor. WARNING!! you should only attempt this procedure if you feel comfortable with hardware hacking, and are prepared to have your Slug turn into a brick.

The Slug is fully capable of serving up web pages, SMTP server, or other chores that don't require large amounts of cpu, memory, or bandwidth. Here are a few compelling reasons to do so:

  • Cheap - the street price of the Slug is $70 US at the time of writing (Sep 1, 2005) [L9 ]. A USB 2.0 IDE drive enclosure can also be found for $30-35, and add an IDE disk drive (80 gb is under $50). Total for a simple server is less than $150 US.
  • Low power - even when over clocked, the combined Slug + USB IDE disk doesn't draw much power.
  • QUIET! - no fans, just the IDE drive spinning away.
  • Cool - for the hackiness, geek cool factor.

The best source of info is the NSLU2-Linux project at http://www.nslu2-linux.org/ A mailing list is also available at http://groups.yahoo.com/group/nslu2-linux/

A few other notes:

  • The low-level boot code in the Slug runs the ARM cpu in big-endian mode, most other ARM Debian packages are built for the ARM running in little-endian mode, and are thus unusable. Another project, DebianSlug [L10 ] runs normal little-endian Debian packages by installing a word-swapped kernel and special loader to kick the ARM into little-endian mode. Since native development is easy and many package already exists, I haven't had any need to try this approach.
  • More ideas for what to run on your Slug [L11 ] and [L12 ]
  • The ARM 5 doesn't have a FPU, so be mindful of running floating point intensive apps.

01sep05 jcw - Since it's Linux on ARM, a standard tclkit might also work on it, see [L13 ].

02sep05 TP - No, the tclkit-linux-arm is built for little-endian, but the Slug runs in big-endian mode (when running natively and under the Unslung or OpenSlug firmware.) Yes, the ARM processor can run in either bytesex, depending on flags set in a control register.

Here is what file(1) says for tclkit-linux-arm:

 -bash-2.05b$ file tclkit-linux-arm
 tclkit-linux-arm: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), stripped

and for my natively built tclsh:

 -bash-2.05b$ file tcl8.4.11/unix/tclsh
 tcl8.4.11/unix/tclsh: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped

It should be possible to build Tclkit (I've already tried once but ran into path issues). Looks like I'll need to write a genkit.local to pass --prefix=/opt to find the proper includes for X (/opt/include/X11) for Tk and C++ libs (/opt/lib/libstdc++.so) for Mk.


05sep05 sbron - A very similar device is the Buffalo LinkStation [L14 ]. As that device runs a version of Linux too and has been hacked as well, it's also possible to run Tcl on the LinkStation.


16May2006 SRIV I picked up a slug, overclocked it & installed OpenSlug. Stay tuned.

jcw - There's now a 8.4.13 binary for the Slug at [L15 ], see Linux / ARM BE.


slebetman: I've been running Tcl on my Slug for a little over a year now for my web site at http://slebetman.homeip.net (Check out my Slug status at [L16 ]). I have however found that the Tcl handling of the serial port (TTL level RS232) on the Slug is broken. I can easily transmit bytes out but reading bytes in doesn't work no matter what I do. I've tried blocking & non blocking, translation and encoding to binary etc. but nothing seems to work. I'm wondering if this is a specific bug related to the Slug or is Tcl's handling of Unix serial TTYs inherently broken.


TP 3 May 2007 - Debian 4.0 is now fully supported on the Slug! [L17 ] [L18 ]. I have reflashed my Slug to run Debian. This version runs the kernel in little-endian mode. I did run into some low-memory problems during the install, while the root and home filesystems were being created. There is a work-around, ssh in from another term and start swapping early [L19 ].

Debian supports Tcl as an installable package, along with several popular extensions (Itcl, Tclx, Tk, expect, Swig, tdom, tcllib, etc.)


[Category Distribution|Category Porting|Category Embedded]