summaryrefslogtreecommitdiff
path: root/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh')
-rwxr-xr-xmeta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh31
1 files changed, 24 insertions, 7 deletions
diff --git a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
index b7f4bc52e..b13e4b50a 100755
--- a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
@@ -15,10 +15,8 @@
# limitations under the License.
do_flash () {
- OFFSET=$1
-
# Check the PNOR partition available
- HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+ HOST_MTD=$(< /proc/mtd grep "pnor-uefi" | sed -n 's/^\(.*\):.*/\1/p')
if [ -z "$HOST_MTD" ];
then
# If the PNOR partition is not available, then bind again driver
@@ -26,7 +24,7 @@ do_flash () {
echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/bind
sleep 2
- HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+ HOST_MTD=$(< /proc/mtd grep "pnor-uefi" | sed -n 's/^\(.*\):.*/\1/p')
if [ -z "$HOST_MTD" ];
then
echo "Fail to probe Host SPI-NOR device"
@@ -34,8 +32,8 @@ do_flash () {
fi
fi
- echo "--- Flashing firmware to @/dev/$HOST_MTD offset=$OFFSET"
- flashcp -v "$IMAGE" /dev/"$HOST_MTD" "$OFFSET"
+ echo "--- Flashing firmware to @/dev/$HOST_MTD"
+ flashcp -v "$IMAGE" /dev/"$HOST_MTD"
}
@@ -50,6 +48,12 @@ if [ ! -f "$IMAGE" ]; then
exit 1
fi
+if [ -z "$2" ]; then
+ DEV_SEL="1" # by default, select primary device
+else
+ DEV_SEL="$2"
+fi
+
# Turn off the Host if it is currently ON
chassisstate=$(obmcutil chassisstate | awk -F. '{print $NF}')
echo "--- Current Chassis State: $chassisstate"
@@ -74,8 +78,21 @@ if ! gpioset 0 226=0; then
exit 1
fi
+# Switch the host SPI bus (between primary and secondary)
+# 227 is BMC_SPI0_BACKUP_SEL
+if [[ $DEV_SEL == 1 ]]; then
+ echo "Run update primary Host SPI-NOR"
+ gpioset 0 227=0 # Primary SPI
+elif [[ $DEV_SEL == 2 ]]; then
+ echo "Run update secondary Host SPI-NOR"
+ gpioset 0 227=1 # Second SPI
+else
+ echo "Please choose primary SPI (1) or second SPI (2)"
+ exit 0
+fi
+
# Flash the firmware
-do_flash 0x400000
+do_flash
# Switch the host SPI bus to HOST."
echo "--- Switch the host SPI bus to HOST."