Commit 0a793309 authored by Alessandro Rubini's avatar Alessandro Rubini

flashing: new procedure

This changes the flashing procedure, because the previous one did not
work any more now that the default filesystem size is bigger.

With this commit no jffs2 images is generated any more, and the
filesystem image is not included as a payload in the initramfs booted
using the USB tools.

Rather, the initramfs downloads wrs-image.tar.gz using TFTP, from the
IP address that replied to DHCP, and untars it to the NAND partitions.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 0197a976
......@@ -126,9 +126,6 @@ if $fake; then
FLASHER="fake_flasher $FLASHER"
fi
# add /usr/sbin for mkfs.jffs2
export PATH="$PATH:/usr/sbin"
# Default MAC address for the switch board ethernet
MAC1_DEF="02:34:56:78:9A:BC"
MAC1=$MAC1_DEF
......@@ -153,8 +150,6 @@ kernel=""
rootfsgz=""
# full path to the cpio image
rootfscpio=""
# full path to the jffs2 image
rootfsjffs2=""
# full path to the file system directory
TMPFS=""
......@@ -309,7 +304,6 @@ fi
if $nf; then
TMPFS=$WRSTMPDIR/wrsfs-tgz; mkdir $TMPFS
rootfsjffs2=$WRSTMPDIR/wrs-image.jffs2
# The TMPCPIO is used for the NAND flashing procedure. It
# contains the magic string "paperino" (0x61706570 0x69726f6e)
......@@ -326,21 +320,22 @@ tar --directory $TMPFS -xzf $rootfsgz
# (There is not enough place in DDR to extract 4 HDLs, be carefull if you add custom files)
find $TMPFS/wr/lib/firmware/ -type f \( ! -name ''${gateware}'' \) -a \( ! -name '*rt_cpu.bin' \) -exec rm -f {} \;
mkfs.jffs2 --little-endian --eraseblock=0x20000 -n --pad -d $TMPFS -o $rootfsjffs2
# Remove heavy and useless stuff to make a light file system to
# load in RAM
rm -rf $TMPFS/etc/init.d/S*
rm -rf $TMPFS/wr
rm -rf $TMPFS/usr/bin
rm -rf $TMPFS/usr/lib
for n in top ltrace gdbserver strace rsync screen php php-cgi gdb; do
rm -f $TMPFS/usr/bin/\$n
done
for n in python2.7 lighttpd rsyslog; do
rm -rf $TMPFS/usr/lib/\$n
done
rm -rf $TMPFS/usr/share
rm -rf $TMPFS/var/www
mkdir $TMPFS/flashing/
cp -a /dev/kmsg $TMPFS/dev/kmsg
cp ${rootfsjffs2} $TMPFS/flashing/wrs-image.jffs2.img
cp ${kernel} $TMPFS/flashing/zImage
cp ${WRS_BASE_DIR}/usb-loader/S99flash-from-kernel.sh $TMPFS/etc/init.d/
cd ..
echo -n "paperino" > $TMPCPIO
(cd "$TMPFS" && find . | cpio -o -H newc | gzip) >> $TMPCPIO
......@@ -358,34 +353,29 @@ EOF
rm $TMPSCRIPT
rm -rf $TMPFS
rm -rf $TMPCPIO
rm -rf $rootfsjffs2
else
echo "Keeping temporaries"
echo " script is $TMPSCRIPT"
echo " filesystem image (no attributes) is $TMPFS"
echo " jffs2 image is in $rootfsjffs2"
echo " cpio file is in $TMPCPIO at offset 8 bytes"
fi
# Now, flashing proceeds by booting a kernel, get its messages
# Wait for the device to disappear
while [ -e /dev/ttyACM0 ]; do sleep 0.1; done
# Wait for the device to appear again
while [ ! -e /dev/ttyACM0 ]; do sleep 0.1; done
# Report install messages until the device disappears again
cat /dev/ttyACM0
fi
## Loading in DDR
if $ddr; then
TMPFS=$(mktemp -d $TMPDIR/wrsfs-tgz.XXXXXX)
rootfsjffs2=$TMPDIR/wrs-image.jffs2.img
# make cpio and jffs2 image
TMPSCRIPT=$(mktemp $TMPDIR/wrsrootfs-script.XXXXXX)
cat > $TMPSCRIPT << EOF
tar --directory $TMPFS -xzf $rootfsgz
mkfs.jffs2 --little-endian --eraseblock=0x20000 -n --pad -d $TMPFS -o $rootfsjffs2
EOF
fakeroot bash $TMPSCRIPT
if $remove_temps; then
rm $TMPSCRIPT
rm $TMPFS
fi
$FLASHER -m ddr $FLAGS $DEV ${Tbarebox} 0x0 ${kernel} 0x1000000 ${rootfsjffs2} 0x2000000
echo ""
echo "DDR loading (the test procedure) is currently not supported"
echo ""
fi
if $remove_temps; then
......
......@@ -5,11 +5,15 @@
memcmp -s /dev/mem -d /env/magicstr 0x71FFFFF8 0x0 8
if [ $? -eq 0 ]; then
echo "Booting kernel for NAND flashing procedure"
dhcp 5
bootargs="console=ttyS0,115200 panic=10 mem=64M"
bootargs="$bootargs initrd=0x72000000,25M"
bootargs="$bootargs initrd=0x72000000,10M"
bootargs="$bootargs root=/dev/ram0"
addpart /dev/ram0 0x1000000@0x1000000(kernel)
addpart /dev/ram0 0x1000000@0x2000000(initrd)
bootargs="$bootargs SERVERIP=$eth0.serverip WRS_IMAGE=wrs-image.tar.gz"
bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:wrs:eth0"
addpart /dev/ram0 0x400000@0x1000000(kernel)
addpart /dev/ram0 0xa00000@0x2000000(initrd)
bootm /dev/ram0.kernel
fi
......
#!/bin/bash
# Write kernel and filesystem to NAND memory
echo "FLASHING: flashing kernel to /dev/mtd0 ..."
nandwrite -m -p -a /dev/mtd0 /flashing/zImage
echo "FLASHING: flashing file system to /dev/mtd1 ..."
nandwrite -m -p -a /dev/mtd1 /flashing/wrs-image.jffs2.img
echo "FLASHING: complete!"
# Reboot immediatly because we have completed the flashing procedure
reboot
#!/bin/sh
#
# This is the installation script for wr-switch. It is activated by
# a special kernel argument, that reaches user-space environment variables
if [ "x$WRS_IMAGE" = "x" ]; then exit 0; fi
echo 1 > /proc/sys/kernel/printk
# keep /dev/ttyGS0 open, to prevent EOF being seen from the PC
sleep 99999 > /dev/ttyGS0 &
echo "Installation procedure starts" | tee /dev/ttyGS0
sleep 2
echo -n "Flashing kernel to /dev/mtd0 ..." | tee /dev/ttyGS0
nandwrite -m -p -a /dev/mtd0 /flashing/zImage
echo " done" | tee /dev/ttyGS0
# Eth0 is already up, thanks to ip= passed by bootloader
cd /flashing
echo -n "Getting tftp://$SERVERIP/$WRS_IMAGE ..." | tee /dev/ttyGS0
tftp -g -r $WRS_IMAGE -l $WRS_IMAGE $SERVERIP
echo " done" | tee /dev/ttyGS0
echo -n "Mounting target filesystem..." | tee /dev/ttyGS0
mount -t jffs2 /dev/mtdblock1 /mnt
echo " done" | tee /dev/ttyGS0
echo -n "Uncompressing image..." | tee /dev/ttyGS0
cd /mnt; zcat /flashing/wrs-image.tar.gz | tar xf -
echo " done" | tee /dev/ttyGS0
#/bin/sh
reboot
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment