view · edit · print · history

SlugImage is a Perl script for manipulating NSLU2 firmware images.

The proposed feature set is:

  • replicate all current slugtool functionality (pack and unpack firmware images)
  • write a RedBoot partition table into the last block of flash
  • have the facility to insert a MAC address at the end of the RedBoot partition.

Usage: slugimage <options>

  [-d|--debug]                  Turn on debugging output
  [-q|--quiet]                  Turn off status messages
  [-u|--unpack]                 Unpack a firmware image
  [-p|--pack]                   Pack a firmware image
  [-l|--little]                 Convert Kernel and Ramdisk to little-endian
  [-F|--fatflash]                       Generate an image for 16MB flash
  [-i|--input]     <file>               Input firmware image filename
  [-o|--output]    <file>               Output firmware image filename
  [-b|--redboot]   <file>               Input/Output RedBoot filename
  [-s|--sysconf]   <file>               Input/Output SysConf filename
  [-L|--loader]    <file>               Second stage boot loader filename
  [-k|--kernel]    <file>               Input/Ouptut Kernel filename
  [-r|--ramdisk]   <file>               Input/Output Ramdisk filename(s) if using jffs2 Ramdisk (i.e., Debian Installer), or
  [-r|--ramdisk] Flashdisk:<file>       Input/Output Flashdisk filename(s) if not using jffs2 (i.e., SlugOS BE/LE)
  [-f|--fisdir]    <file>               Input/Output FIS directory filename
  [-m|--microcode] <file>               Input/Output Microcode filename
  [-t|--trailer]   <file>               Input/Output Trailer filename
  [-e|--ethaddr]   <AABBCCDDEEFF>       Set the Ethernet address

old version information left below: command line:

 --pack (-p), --unpack (-u), --input (-i) = <8mb-image.bin>, --output (-o) = <8mb-image.bin>,
 --redboot (-b) = <redboot.bin>, --sysconf (-s) = <sysconf.bin>, --kernel (-k) = <vmlinuz>,
 --ramdisk (-r) =<ramdisk.gz> (don't write partition table in this case) or
 --ramdisk (-r) =Ramdisk:<ramdisk.squashfs>,Rootdisk:<root.jffs2>,Userdisk:<user.jffs2>,... (write the partition table with the names given),
 --trailer (-t) = <trailer.bin>,
 --macaddr (-m) = 00:00:00:00:00:00

You can download SlugImage from the unslung CVS.

Here is an example that I used for extracting all the separate parts out of an 8MB binary image, using Debian 4.0 Installer from the D-I howto page. Note that I did this all from within cygwin. I wanted to use cygwin because my work laptop had a parallel port, TFTP server, TeraTerm (supported), etc. (needed for NSLU2 hacking). Note here that I used the -i option (for input file). Also note that Debian images have a Ramdisk not Flashdisk (as in slugosbe/slugosle).

  $ ./slugimage.pl -u -i di-nslu2.bin
   Read 2 blocks into <RedBoot>
   Read 0x00006 bytes into <EthAddr>
   Read 1 blocks into <SysConf>
   Read 0x1FFE0 bytes into <Loader>
   Read 11 blocks into <Kernel>
   Read 32 blocks into <Ramdisk>
   Read 1 blocks into <FIS directory>
   Read 0x00010 bytes into <Trailer>
   Wrote 0x00040000 bytes from <RedBoot> into "RedBoot"
   Wrote 0x00020000 bytes from <SysConf> into "SysConf"
   Wrote 0x0001FFE0 bytes from <Loader> into "apex.bin"
   Wrote 0x00140004 bytes from <Kernel> into "vmlinuz"
   Wrote 0x00400000 bytes from <Ramdisk> into "ramdisk.gz"
   Wrote 0x00000010 bytes from <Trailer> into "Trailer" 

Note that the files shown above have (with "Wrote..") been extracted into the directory where di-nslu2.bin was located.

If you want to replace something (i.e., let's say Apex 2nd stage boot loader with newer version), then use the -o option (output) parameter.

Now, I just have to replace the apex.bin with the one made for Apex 1.5.13 (called "apex-debian-nslu2-arm-1.5.13.bin").

 $ slugimage.pl -p -o di-nslu2-newapex.bin -b RedBoot -s SysConf 
       -L apex-debian-nslu2-arm-1.5.13.bin -k vmlinuz -r ramdisk.gz 
       -t Trailer


  1. Here is a log of a boot you don't want to see: BadSlugImageBad
  2. You should be able to get slugimage to work using cygwin if you don't have a linux system handy. Just be sure to
    chmod 755 it (set exec bits) and put it in your path.
  3. You need to use -r Flashdisk:Flashdisk if disassembling/re-assembling a SlugOS image (NOT Debian as in di-nslu2.bin). That's because SlugOS uses a Flashdisk. A Ramdisk uses a length header (as it's using jffs2), wherein a Flashdisk does not. The two are NOT interchangeable.
Page last modified on May 10, 2008, at 05:51 PM