summaryrefslogtreecommitdiff
path: root/RIKOR/flash-sila-bmc.in
diff options
context:
space:
mode:
Diffstat (limited to 'RIKOR/flash-sila-bmc.in')
-rw-r--r--RIKOR/flash-sila-bmc.in93
1 files changed, 93 insertions, 0 deletions
diff --git a/RIKOR/flash-sila-bmc.in b/RIKOR/flash-sila-bmc.in
new file mode 100644
index 0000000..329d97b
--- /dev/null
+++ b/RIKOR/flash-sila-bmc.in
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+CWD=`pwd`
+
+IMAGEDIR=${HOME}/sila
+mkdir -p ${IMAGEDIR}
+
+BINDIR=${HOME}/bin
+mkdir -p ${BINDIR}
+
+IMAGE=${IMAGEDIR}/image-bmc
+
+cat > ${BINDIR}/flash-sila <<EOF
+#!/bin/sh
+
+flashcp -v ${IMAGE} /dev/mtd0
+EOF
+
+chmod a+x ${BINDIR}/flash-sila
+
+#
+# Extract image:
+# =============
+#
+sed -e '1,/^exit$/d' "$0" | tar -C "${IMAGEDIR}" -xf -
+
+echo -n "Verifying Image..."
+( cd ${IMAGEDIR}
+ cat image-bmc.sig MANIFEST.sig publickey.sig > image-full
+ verify=`openssl dgst -verify publickey -signature image-full.sig image-full`
+ if [ "${verify}" != "Verified OK" ] ; then
+ echo -e "\nERROR: Wrong Image signature.\n"
+ exit 1
+ else
+ rm -f MANIFEST image-full publickey *.sig
+ fi
+)
+echo -e "\t OK"
+
+#
+# Get current MAC Address:
+# =======================
+#
+mac=`ifconfig eth0 | grep HWaddr | tr -s ' ' | cut -f5 -d' '`
+
+#
+# Umount mtd file systems:
+# =======================
+#
+cd /
+
+while [ 1 ] ; do
+ umount /tmp/.rwfs 2>/dev/null 1>/dev/null
+ ret=$?
+ if [ $ret -eq 0 ] ; then
+ break
+ fi
+ echo "Trying to umount rwfs partition..."
+ sleep 0.1
+done
+
+while [ 1 ] ; do
+ umount /var/sofs 2>/dev/null 1>/dev/null
+ ret=$?
+ if [ $ret -eq 0 ] ; then
+ break
+ fi
+ echo "Trying to umount sofs partition..."
+ sleep 0.1
+done
+
+sleep 0.5
+
+#
+# Flash image:
+# ===========
+#
+echo "Flashing SILA Image..."
+
+${BINDIR}/flash-sila
+
+echo -e "\t OK"
+
+
+#
+# Save current MAC Address:
+# ========================
+#
+fw_setenv eth0addr ${mac} 2>/dev/null
+
+reboot -f
+
+exit