diff --git a/build/config/arm/ixp4xx/netboot.cfg b/build/config/arm/ixp4xx/netboot.cfg index ba27e7ffe..a90770d2b 100644 --- a/build/config/arm/ixp4xx/netboot.cfg +++ b/build/config/arm/ixp4xx/netboot.cfg @@ -9,13 +9,20 @@ MANIFEST-INITRD = "netboot initrd" MANIFEST-KERNEL = "kernel image to netboot" # byteswap boot loader, initrd and kernel for NSLU2 -nslu2_initrd: $(INITRD) $(KERNEL) - devio "<<"/boot/apex.flash > $(TEMP)/apex.flash.swapped \ +nslu2_swap: $(INITRD) $(KERNEL) + cp /boot/apex.flash $(TEMP)/apex.flash + util/arm/nslu2/pad $(TEMP)/apex.flash 131072 # 1 block + devio "<<"$(TEMP)/apex.flash > $(TEMP)/apex.flash.swapped \ 'xp $$,4' - util/arm/nslu2/pad-initrd $(TEMP) - devio "<<"$(TEMP)/initrd.gz > $(TEMP)/initrd.gz.swapped + cp $(TEMP)/initrd.gz $(TEMP)/initrd.gz.nslu2 + util/arm/nslu2/pad $(TEMP)/initrd.gz.nslu2 4194304 # 4 MB, taken randomly + devio "<<"$(TEMP)/initrd.gz.nslu2 > $(TEMP)/initrd.gz.swapped.nslu2 'xp $$,4' - devio "<<"$(TEMP)/$(KERNELNAME) > $(TEMP)/$(KERNELNAME).swapped \ + cp $(TEMP)/$(KERNELNAME) $(TEMP)/$(KERNELNAME).nslu2 + # Let's pad the kernel to 131072 * 10 + 1 so it will be rounded up + # by slugimage to 131072 * 11, i.e. 11 blocks. + util/arm/nslu2/pad $(TEMP)/$(KERNELNAME).nslu2 1310724 + devio "<<"$(TEMP)/$(KERNELNAME).nslu2 > $(TEMP)/$(KERNELNAME).nslu2.swapped \ 'xp $$,4' # Generate an image for Linksys NSLU2 which can be flashed diff --git a/build/util/arm/nslu2/pad b/build/util/arm/nslu2/pad index c3b0978c2..8e0030106 100755 --- a/build/util/arm/nslu2/pad +++ b/build/util/arm/nslu2/pad @@ -1,22 +1,16 @@ #!/bin/sh -TEMP=$1 +FILE=$1 +SIZE=$2 -if [ -z "$TEMP" ]; then - echo "Usage: "pad-initrd PATH"" +if [ -z "$FILE" ]; then + echo "Usage: "pad-initrd FILE SIZE"" exit 1 fi -if [ ! -e $TEMP/initrd.gz ]; then - echo "initrd.gz does not exist at $TEMP" - exit 1 -fi -size=$(wc -c $TEMP/initrd.gz | cut -d " " -f 1) -mod=$(($size % 4)) -pad=$((4 - $mod)) +fsize=$(wc -c $FILE | cut -d " " -f 1) +pad=$(expr $SIZE - $fsize) if [ $pad -gt 0 ]; then - tmp=$TEMP/initrd.padding - dd if=/dev/zero of=$tmp bs=1 count=$pad - cat $tmp >> $TEMP/initrd.gz + dd if=/dev/zero bs=1 count=$pad 2>/dev/null >> $FILE fi