NSLU2

From Wiki
Jump to navigationJump to search

slugimage - manipulate NSLU2 firmware images
flash-kernel - write kernel and ramdisk images
mkinitramfs - make initramfs images
apex-env - manipulate bootloader command line
upslug2 - update slug flash image (run from host system)

----

cat /proc/mtd 			-- list flash partitions
cat /dev/mtdblock* > image 	-- Make backup of flash image
slugimage -u -i image 		-- unpack flash image into separate files

apex-env setenv cmdline "console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug root=/dev/nfs nfsroot=172.16.0.1:/tftpboot/slug1/disk ip=bootp"

slugimage -p -b RedBoot -s SysConf -L apex.bin -k vmlinuz -r ramdisk.gz -t Trailer -o repack.bin


Code: Fix for slugimage
--- slugimage   2010-06-27 16:51:01.000000000 -0400
+++ /usr/bin/slugimage  2010-06-27 16:36:32.000000000 -0400
@@ -71,10 +71,10 @@
 
 # Take $data, and pad it out to $total_len bytes, appending 0xff's.
 sub padBytes {
-    my($data,$total_len) = @_;
+    my($data,$total_len,$pad_char) = @_;
 
     # 0xFF is used to pad, as it's the erase value of the flash.
-    my($pad_char) = pack("C",0xff);
+    $pad_char = pack("C",0xff) unless (defined ($pad_char));
     my($pad_len) = $total_len - length($data);
 
     # A request for negative padding is indicative of a logic error ...
@@ -803,7 +803,7 @@
            # Splice the data into the image at the appropriate place, padding as required.
            substr($image_buf, $_->{'offset'}, $_->{'size'},
                   $_->{'header'} ?
-                  padBytes(pack("N4",length($_->{'data'})).$_->{'data'}, $_->{'size'}) :
+                  padBytes(pack("N4",length($_->{'data'})).$_->{'data'}, $_->{'size'}, pack ("C", ($_->{'name'} eq 'Ramdisk') ? 0x00 : 0xff)) :
                   padBytes($_->{'data'}, $_->{'size'}));
            
            # Keep the user appraised ...


  • Get image from http://www.slug-firmware.net/d-dls.php
  • Unzip image on host machine
  • Disconnect any attached USB devices from NSLU2
  • Make sure NSLU2 is powered off
  • Pressing 'reset' button inside small hole on back, press power button.
  • Continue pressing 'reset' until the top LED turns red; immediately release reset button
  • Upgrade using upslug2 --image di-nslu2.bin
  • When upslug2 completes, attach 2GB+ disk or memory stick
  • After NSLU2 finishes booting (3 pathetic beeps), ssh to installer@<slug_ip_address>
  • Answer questions installer will ask
  • After installer completes and NSLU2 reboots, ssh as root to NSLU2
  • apt-get update
  • apt-get upgrade
  • apt-get install gcc libncurses5-dev linux-image-2.6.26-2-ixp4xx initramfs-tools
  • cd /root
  • cat /dev/mtdblock* > flash_backup.bin
  • Move 'flash_backup.bin' to host machine
  • cd /root/linux-2.6-2.6.26
  • make menuconfig
  • Goto Networking->Networking options->IP: kernel level autoconfiguration and press 'Y'
  • Goto File systems->Network File Systems->NFS file system support and press 'Y'
  • Goto File systems->Network File Systems->Root file system on NFS and press 'Y'
  • Enable IP: DHCP support and IP:BOOTP support
  • Exit menuconfig, saving new configuration
  • make
  • make modules_install
  • cd
  • mkdir temp
  • cd temp
  • mkinitramfs -k -o initramfs-2.6.26.gz 2.6.26
  • mkdir initramfs
  • cd initramfs
  • zcat ../initramfs-2.6.26.gz | cpio -i
  • mkdir -p lib/firmware
  • cp -a /lib/firmware/* lib/firmware
  • find . | cpio --quiet -o -H newc | gzip -9 > ../initramfs-2.6.26.gz
  • cd ..
  • rm -rf initramfs
  • dd if=initramfs-2.6.26.gz of=initramfs-2.6.26-pad.gz ibs=6291440 conv=sync
  • devio '<< initramfs-2.6.26-pad.gz; xp $ 4' >initramfs-2.6.26-new.gz
  • rm -rf initramfs initramfs-2.6.26-pad.gz
  • cp ~/linux/arch/arm/boot/zImage .
  • devio '<< zImage; xp $ 4' > zImage-swap
  • apex-env setenv cmdline "console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug root=/dev/nfs nfsroot=172.16.0.1:/tftpboot/slug1/disk ip=bootp"
  • cat /dev/mtdblock* > flash.bin
  • apex-env setenv cmdline "console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug"
  • slugimage -u -i flash.bin
  • slugimage -l -L apex.bin -r initramfs-2.6.26.gz -k zImage -p -o di-nslu2-new.bin
  • Move the di-nslu2-new.bin file to the host machine