blob: fbcf466d6bb44e099d3134ba867f117927df93e5 [file] [log] [blame]
Mykola Kostenok4d17df62017-09-01 09:56:45 +03001#!/bin/sh
2#
3# Script to burn entire 32MB of BMC SPI Flash
4#
5# Usage:
6# a) Local: /run/initramfs/update_all <bmc-image-file>
7# b) Remote: sshpass -p "<root-password>" ssh root@<ip> '/run/initramfs/update_all <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
17if [ -f $1 ]
18then
19 echo $0: Update BMC SPI Flash with $1
20else
21 echo $0: File $1 not found on target, exiting
22 exit
23fi
24
25echo $0: Stopping system services
26systemctl stop mlx_ipmid
27
28echo $0: Remounting rwfs "(/dev/mtd5)" as read-only
29mount /dev/mtdblock5 /run/initramfs/rw -t jffs2 -o remount,ro
30
31echo $0: Unmounting rofs "(/dev/mtd4)"
32umount /dev/mtdblock4
33
34MAC=`fw_printenv ethaddr | sed -n "s/^ethaddr=//p"`
35
36echo $0: Burning SPI Flash "(/dev/mtd0)" with image "$1"
37/usr/sbin/flashcp -v $1 /dev/mtd0
38
39if [ -v $MAC ]; then
40 echo "MAC env variable not exist. Set eth0 MAC from eeprom."
41 MAC=`hexdump -n 6 -s 0xf0 -v -e '/1 "%02x:"' /sys/bus/i2c/devices/6-0055/eeprom`;MAC=${MAC::-1};
42else
43 echo "MAC env variable exist. Set eth0 MAC from env."
44fi;
45fw_setenv ethaddr $MAC
46
47echo $0: Setting bmc_upgrade sticky bit in CPLD
48echo 1 > /bsp/reset/bmc_upgrade
49
50echo $0: Rebooting BMC
51echo 0 > /bsp/reset/bmc_reset_soft
52
53
54