Bug#580714: debian-installer: build installer image for Buffalo Linkstation Pro/Live
On Thu, 2010-05-20 at 14:34 -0700, Ryan Tandy wrote:
> There definitely needs to be some kind of check in the script then to
> prevent people from accidentally bricking their boxes. It looks like
> the Buffalo u-boot exposes a version in the BOOTVER environment
> variable: 1.01 for the original firmware, 1.10 for the updated (1.15
> or LSProV2) firmware. We can easily check that in the script. I'm
> going to flash a few different bootloaders into my Linkstation to
> verify that the BOOTVER does change.
The BOOTVER (which gets tacked on to the kernel command line,
incidentally) does seem to indicate the bootloader revision. I verified
the 1.01 and 1.10 versions on my Linkstation for the original and
updated firmwares respectively. Some other values are found at [1] and
are of interest for other boxes.
I've attached an updated patch, including a check for a minimum BOOTVER
of 1.10. I don't know precisely which versions exist in the wild but
that is the lowest version I've encountered that is known to work.
Thanks,
Ryan
[1]
http://buffalo.nas-central.org/wiki/U-boot_Default_Environmental_Variables_and_Values
Index: installer/build/boot/arm/lspro-config-debian
===================================================================
--- installer/build/boot/arm/lspro-config-debian (revision 0)
+++ installer/build/boot/arm/lspro-config-debian (revision 0)
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# This code is covered by the GNU General Public License (GPLv2 or higher)
+
+NVRAM=$(which nvram)
+FW_PRINTENV=$(which fw_printenv)
+
+path=$(mount | grep ext2 | sed -n '/sda1/ {s/\/dev\/sda1 on \(.*\) type.*/\1/; p}')
+if [ -z "$path" ]; then
+ echo "You have to create an ext2 filesystem on /dev/sda1"
+ exit 1
+fi
+
+if [ ! -e $path/uImage.buffalo ]; then
+ echo "You have to download the uImage.buffalo file from the debian-installer for Linkstation Pro/Live, and put it in $path"
+ exit 1
+fi
+
+if [ ! -e $path/initrd.buffalo ]; then
+ echo "You have to download the initrd.buffalo file from the debian-installer for Linkstation Pro/Live, and put it in $path"
+ exit 1
+fi
+
+if [ -n "$NVRAM" ]; then
+ PRINTENV="$NVRAM -c printenv"
+ SETENV="$NVRAM -c set"
+ GETENV="$NVRAM -c get"
+elif [ -n "$FW_PRINTENV" ]; then
+ if [ -z "$(which fw_setenv)" ]; then
+ echo "Program fw_setenv not found, cannot modify U-Boot environment..."
+ exit 1
+ elif [ ! -f /etc/fw_env.config ]; then
+ echo "Configuration file for fw_printenv not found."
+ exit 1
+ else
+ PRINTENV=$FW_PRINTENV
+ SETENV=$(which fw_setenv)
+ GETENV="$FW_PRINTENV -n"
+ fi
+else
+ echo "No tool found for modifying U-Boot environment..."
+ exit 1
+fi
+
+BOOTVER=$($GETENV buffalo_ver | sed 's/^.*=//')
+if [ -z "$BOOTVER" ]; then
+ echo "Unable to detect Buffalo bootloader version. Please ensure that your bootloader supports automatic initrd position/size detection."
+else
+ BOOTVER_MAJOR=${BOOTVER%.*}
+ BOOTVER_MINOR=${BOOTVER#*.}
+ if [ $BOOTVER_MAJOR -eq 1 -a $BOOTVER_MINOR -lt 10 ]; then
+ echo "Incompatible bootloader version detected. Please update to the latest firmware version."
+ exit 1
+ fi
+fi
+
+printf "Saving U-Boot environment to ubootenv.bak... "
+$PRINTENV > ubootenv.bak
+echo "done."
+
+echo "Changing U-Boot environment... "
+$SETENV bootargs_root "root=/dev/sda2 rw panic=5"
+echo "done."
+
+echo "Please reboot your Linkstation."
Index: installer/build/config/armel/orion5x/netboot.cfg
===================================================================
--- installer/build/config/armel/orion5x/netboot.cfg (revision 63243)
+++ installer/build/config/armel/orion5x/netboot.cfg (working copy)
@@ -1,6 +1,6 @@
MEDIA_TYPE = netboot image
-TARGET = $(TEMP_INITRD) $(TEMP_KERNEL) dns-323 kuroboxpro mv2120 ts209 ts409
+TARGET = $(TEMP_INITRD) $(TEMP_KERNEL) dns-323 kuroboxpro lspro mv2120 ts209 ts409
EXTRANAME = $(MEDIUM)
TYPE = netboot/network-console
@@ -35,6 +35,22 @@
update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/uImage.buffalo "Linux kernel for Kurobox Pro"
update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/kuroboxpro/initrd.buffalo "initrd for Kurobox Pro"
+# Buffalo Linkstation Pro/Live
+lspro:
+ mkdir -p $(SOME_DEST)/$(EXTRANAME)/buffalo/lspro
+ mkdir -p $(TEMP)/lspro
+ # Set machine id 1585 (0x0631)
+ devio > $(TEMP)/lspro/kernel 'wl 0xe3a01c06,4' 'wl 0xe3811031,4'
+ cat $(TEMP_KERNEL) >> $(TEMP)/lspro/kernel
+ mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Debian kernel" -d $(TEMP)/lspro/kernel $(TEMP)/lspro/kernel.uboot
+ cp $(TEMP)/lspro/kernel.uboot $(SOME_DEST)/$(EXTRANAME)/buffalo/lspro/uImage.buffalo
+ mkimage -A arm -O linux -T ramdisk -C gzip -a 0x02000000 -e 0x02000000 -n "debian-installer ramdisk" -d $(TEMP_INITRD) $(TEMP)/lspro/initrd.uboot
+ cp $(TEMP)/lspro/initrd.uboot $(SOME_DEST)/$(EXTRANAME)/buffalo/lspro/initrd.buffalo
+ install -m 744 boot/arm/lspro-config-debian $(SOME_DEST)/$(EXTRANAME)/buffalo/lspro/config-debian
+ update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/lspro/config-debian "Script to run debian-installer"
+ update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/lspro/uImage.buffalo "Linux kernel for Linkstation Pro/Live"
+ update-manifest $(SOME_DEST)/$(EXTRANAME)/buffalo/lspro/initrd.buffalo "initrd for Linkstation Pro/Live"
+
# HP Media Vault mv2120
mv2120:
mkdir -p $(SOME_DEST)/$(EXTRANAME)/hp/mv2120
Reply to: