Commit 88d2e085 authored by Adam Wujek's avatar Adam Wujek 💬

rootfs: fix overwriting hwinfo during switch update (buildroot)

When switch's firmware with buildroot older than 2016.02 was updated via
copying wrs-firmware.tar with buildroot at least 2016.02 to the
/update partition, then hwinfo in the flash was overwriten.
Such behaviour was caused by crashing during execution of /wr/bin/sdb-read.
Crashing sdb-read caused the following if's condition from the file
/etc/init.d/hwinfo to be false.

if /wr/bin/sdb-read /dev/mtd5ro > /dev/null; then

This triggered later overwrite of hwinfo partition.

/wr/bin/sdb-read was crashing because during update the binary /wr/bin/sdb-read
was called from just extracted firmware. Problem pops up when libraries
required by sdb-read are in the different versions in the old and the new
firmware. Unfortunatelly, this problem cannot be easily solved, since we cannot
change the update procedure in already installed firmware (the one that is
performing update).

Implemented solution does the following:
--change the name of /wr/etc/sdb-for-dataflash to /wr/etc/sdb-for-dataflash.bin
  by this /etc/init.d/hwinfo script exits with an error without modification
  to the hwinfo partition.
--rename link /etc/rcS/S90hwinfo to /etc/rcS/S10hwinfo, which will trigger
  update of hwinfo partition earlier during the boot.
--restart switch after update of hwinfo in the flash
--remove calls of /etc/init.d/hwinfo during the update
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 72ba3542
......@@ -31,7 +31,7 @@ fi
echo "Creating SDB filesystem in /dev/mtd5"
# So, we must create an sdb file, we need the template
cp /wr/etc/sdb-for-dataflash /tmp
cp /wr/etc/sdb-for-dataflash.bin /tmp
if [ $? -ne 0 ] ; then
echo "hwinfo_error" > /tmp/hwinfo_read_status
exit 1
......@@ -52,14 +52,19 @@ if [ "x$ethaddr" = "x" ]; then ethaddr="02:34:56:78:9A:BC"; fi
if [ "x$wraddr" = "x" ]; then wraddr="02:34:56:78:9A:00"; fi
# we lack sdb-write...
sed -i s,02:34:56:78:9A:BC,$ethaddr, /tmp/sdb-for-dataflash
sed -i s,02:34:56:78:9A:00,$wraddr, /tmp/sdb-for-dataflash
sed -i s,02:34:56:78:9A:BC,$ethaddr, /tmp/sdb-for-dataflash.bin
sed -i s,02:34:56:78:9A:00,$wraddr, /tmp/sdb-for-dataflash.bin
# Create the writable device file and write in there, then remove it
test -c /dev/mtd5 || mknod /dev/mtd5 c 90 10
flash_erase /dev/mtd5 0 0
cat /tmp/sdb-for-dataflash > /dev/mtd5
cat /tmp/sdb-for-dataflash.bin > /dev/mtd5
rm /dev/mtd5
# save script result for snmp
echo "hwinfo_ok" > /tmp/hwinfo_read_status
# reboot if hw info was updated
# Please note that reboot will take pleace after switch finishes booting
echo -e "\n\nOrdering reboot after hwinfo update!!!\n\n"
reboot
......@@ -141,10 +141,6 @@ if [ -f /update/$WRS_FW -o -f /update/$WRS_USR ]; then
else
tar xzf /update/$WRS_USR
fi
# a special fix: we may need to create hwinfo when upgrading from 4.0
if [ -x /wr/bin/sdb-read ]; then
/etc/init.d/hwinfo
fi
sync; cd /; umount /usr
echo " done" | $TEE /dev/ttyGS0
......
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