#!/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 A" else echo "Start update for partition B" 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 /sbin/uboot_tool part_switch sync mount -o remount,ro /uboot echo "Update complete -> please reboot"