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

39 lines
737 B
Plaintext
Raw Normal View History

2019-12-01 21:20:32 +01:00
#!/bin/bash
2019-11-03 16:04:17 +01:00
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 A"
2019-12-15 14:56:25 +01:00
else
echo "Start update for partition B"
2019-11-03 16:04:17 +01:00
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"