blob: 256e18fdbc1d5945e8d78df5589e1da1f8d173ed [file] [log] [blame]
Mykola Kostenok4d17df62017-09-01 09:56:45 +03001
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
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: Remounting rwfs "(/dev/mtd5)" as read-only
26mount /dev/mtdblock5 /run/initramfs/rw -t jffs2 -o remount,ro
27
28echo $0: Unmounting rofs "(/dev/mtd4)"
29umount /dev/mtdblock4
30
31devmem 0x1e785034 l 0x01;
32
33MAC=`fw_printenv ethaddr | sed -n "s/^ethaddr=//p"`
34
35echo $0: Burning SPI Flash "(/dev/mtd0)" with image "$1"
36/usr/sbin/flashcp -v $1 /dev/mtd0
37
38if [ -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};
41else
42 echo "MAC env variable exist. Set eth0 MAC from env."
43fi;
44
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