added A/B partition update
This commit is contained in:
11
resources/scripts/ab_active
Executable file
11
resources/scripts/ab_active
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# get current partition index
|
||||
current_idx=$(rdev | sed 's#/dev/mmcblk0p\([^ ]*\).*#\1#')
|
||||
|
||||
if [ $current_idx -eq 2 ]; then
|
||||
echo "Active partition: A"
|
||||
else
|
||||
echo "Active partition: B"
|
||||
fi
|
40
resources/scripts/ab_flash
Executable file
40
resources/scripts/ab_flash
Executable file
@ -0,0 +1,40 @@
|
||||
#!/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"
|
||||
flash_idx=3
|
||||
else
|
||||
echo "Start update for partition A"
|
||||
flash_idx=2
|
||||
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
|
||||
fw_setenv boot_partition ${flash_idx}
|
||||
sync
|
||||
mount -o remount,ro /uboot
|
||||
|
||||
echo "Update complete -> please reboot"
|
Reference in New Issue
Block a user