aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh')
-rwxr-xr-xtarget/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
new file mode 100755
index 0000000000..225fec0bca
--- /dev/null
+++ b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,68 @@
+platform_do_upgrade() {
+ local board=$(board_name)
+
+ case "$board" in
+ unielec,u7623-02-emmc-512m)
+ #Keep the persisten random mac address (if it exists)
+ mkdir -p /tmp/recovery
+ mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
+ [ -f "/tmp/recovery/mac_addr" ] && \
+ mv -f /tmp/recovery/mac_addr /tmp/
+ umount /tmp/recovery
+
+ #1310720 is the offset in bytes from the start of eMMC and to
+ #the location of the kernel (2560 512 byte sectors)
+ get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync
+
+ mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
+ [ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery
+ sync
+ umount /tmp/recovery
+ ;;
+ *)
+ default_do_upgrade "$1"
+ ;;
+ esac
+}
+
+PART_NAME=firmware
+
+platform_check_image() {
+ local board=$(board_name)
+ local magic="$(get_magic_long "$1")"
+
+ [ "$#" -gt 1 ] && return 1
+
+ case "$board" in
+ bananapi,bpi-r2|\
+ unielec,u7623-02-emmc-512m)
+ [ "$magic" != "27051956" ] && {
+ echo "Invalid image type."
+ return 1
+ }
+ return 0
+ ;;
+ *)
+ echo "Sysupgrade is not supported on your board yet."
+ return 1
+ ;;
+ esac
+
+ return 0
+}
+
+platform_copy_config_emmc() {
+ mkdir -p /recovery
+ mount -o rw,noatime /dev/mmcblk0p1 /recovery
+ cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE"
+ sync
+ umount /recovery
+}
+
+platform_copy_config() {
+ case "$(board_name)" in
+ unielec,u7623-02-emmc-512m)
+ platform_copy_config_emmc
+ ;;
+ esac
+}