Mykola Kostenok | 4d17df6 | 2017-09-01 09:56:45 +0300 | [diff] [blame] | 1 | |
| 2 | #!/bin/sh |
| 3 | # |
| 4 | # Script to burn entire 32MB of BMC SPI Flash 1 |
| 5 | # |
| 6 | # Usage: |
| 7 | # a) Local: /run/initramfs/recovery <bmc-image-file> |
| 8 | # |
| 9 | # Assumptions: |
| 10 | # <bmc-image-file> is a 32MB file representing all partitions in BMC SPI Flash |
| 11 | # <bmc-image-file> exists on local filesystem |
| 12 | # /dev/mtd0 represents entire BMC SPI Flash device |
| 13 | # /dev/mtd5 is a JFFS2 filesystem (rwfs) partition |
| 14 | # /bsp/reset/bmc_upgrade is symlink pointing to proper sticky bit in CPLD |
| 15 | # |
| 16 | |
| 17 | if [ -f $1 ] |
| 18 | then |
| 19 | echo $0: Update BMC SPI Flash with $1 |
| 20 | else |
| 21 | echo $0: File $1 not found on target, exiting |
| 22 | exit |
| 23 | fi |
| 24 | |
| 25 | echo $0: Remounting rwfs "(/dev/mtd5)" as read-only |
| 26 | mount /dev/mtdblock5 /run/initramfs/rw -t jffs2 -o remount,ro |
| 27 | |
| 28 | echo $0: Unmounting rofs "(/dev/mtd4)" |
| 29 | umount /dev/mtdblock4 |
| 30 | |
| 31 | devmem 0x1e785034 l 0x01; |
| 32 | |
| 33 | MAC=`fw_printenv ethaddr | sed -n "s/^ethaddr=//p"` |
| 34 | |
| 35 | echo $0: Burning SPI Flash "(/dev/mtd0)" with image "$1" |
| 36 | /usr/sbin/flashcp -v $1 /dev/mtd0 |
| 37 | |
| 38 | if [ -v $MAC ]; then |
| 39 | echo "MAC env variable not exist. Set eth0 MAC from eeprom." |
| 40 | MAC=`hexdump -n 6 -s 0xf0 -v -e '/1 "%02x:"' /sys/bus/i2c/devices/6-0055/eeprom`;MAC=${MAC::-1}; |
| 41 | else |
| 42 | echo "MAC env variable exist. Set eth0 MAC from env." |
| 43 | fi; |
| 44 | |
| 45 | fw_setenv ethaddr $MAC |
| 46 | |
| 47 | echo $0: Setting bmc_upgrade sticky bit in CPLD |
| 48 | echo 1 > /bsp/reset/bmc_upgrade |
| 49 | |
| 50 | echo $0: Rebooting BMC |
| 51 | echo 0 > /bsp/reset/bmc_reset_soft |
| 52 | |