4
0
raspi-alpine-builder/resources/scripts/ab_flash

39 lines
738 B
Plaintext
Raw Normal View History

2019-11-03 16:04:17 +01:00
#!/bin/bash
set -e
image_file=$1
if [ -z $image_file ]; then
echo "USAGE: $0 [IMAGE_PATH]"
return 1
fi
# change to directory containing update file
cd $(dirname $image_file)
# check integrity of image
sha256sum -c ${image_file}.sha256
# get current partition index
current_idx=$(rdev | sed 's#/dev/mmcblk0p\([^ ]*\).*#\1#')
if [ $current_idx -eq 2 ]; then
echo "Start update for partition B"
else
echo "Start update for partition A"
fi
flash_device="/dev/mmcblk0p${flash_idx}"
# flash device
gunzip -c ${image_file} | dd of=${flash_device} status=progress
# switch active partition
mount -o remount,rw /uboot
2019-11-08 22:33:12 +01:00
/sbin/uboot_tool part_switch
2019-11-03 16:04:17 +01:00
sync
mount -o remount,ro /uboot
echo "Update complete -> please reboot"