mvebu: sysupgrade support for TP-Link OC200
authorStijn Tintel <stijn@linux-ipv6.be>
Mon, 30 Nov 2020 21:32:54 +0000 (23:32 +0200)
committerStijn Tintel <stijn@linux-ipv6.be>
Wed, 8 Nov 2023 12:00:41 +0000 (14:00 +0200)
target/linux/mvebu/cortexa53/base-files/lib/preinit/82_uDPU
target/linux/mvebu/cortexa53/base-files/lib/upgrade/oc200.sh [new file with mode: 0644]
target/linux/mvebu/cortexa53/base-files/lib/upgrade/platform.sh

index 8d5a482b8290d8487a8d973356b3ca48d97c96e9..9005bb3ae6ca44a55655e9ff7c6acad2dd821ecf 100644 (file)
@@ -43,6 +43,18 @@ preinit_mount_udpu() {
                # Legacy support - if rootfs was booted, instruct u-boot to keep the current root dev
                [ "$(df | grep /dev/root)" ] && fw_setenv root_ok '2'
        ;;
+       tplink,oc200)
+               if [ -b /dev/mmcblk0p4 ]; then
+                       mkdir -p /data
+                       mount -t ext4 /dev/mmcblk0p4 /data
+                       [ -f "/data/$BACKUP_FILE" ] && {
+                               echo "- Restoring configuration files -"
+                               tar xzf "/data/$BACKUP_FILE" -C /
+                               rm -f "/data/$BACKUP_FILE"
+                               sync
+                       }
+               fi
+       ;;
        esac
 }
 
diff --git a/target/linux/mvebu/cortexa53/base-files/lib/upgrade/oc200.sh b/target/linux/mvebu/cortexa53/base-files/lib/upgrade/oc200.sh
new file mode 100644 (file)
index 0000000..b94d5b4
--- /dev/null
@@ -0,0 +1,26 @@
+platform_do_prepare_oc200() {
+       if ! grep -q /data /proc/mounts; then
+               mkdir -p /data
+               mount /dev/mmcblk0p4 /data
+       fi
+}
+
+platform_do_upgrade_oc200() {
+       platform_do_prepare_oc200
+       platform_copy_config_oc200
+
+       grep -q /dev/mmcblk0p4 /proc/mounts && umount /data
+       grep -q /dev/root /proc/mounts && umount /
+
+       dd if="$1" of=/dev/mmcblk0 bs=512 seek=896
+       sync
+
+       umount -l /tmp
+       umount -l /dev
+}
+
+platform_copy_config_oc200() {
+       if [ -f "$UPGRADE_BACKUP" ]; then
+               cp -f "$UPGRADE_BACKUP" "/data/$BACKUP_FILE"
+       fi
+}
index cd41c39d7c7ab183dc840d4830fda60ede70114e..4011c88bee51df3cf1d9c0537573190663298d68 100755 (executable)
@@ -37,6 +37,9 @@ platform_do_upgrade() {
        methode,edpu)
                platform_do_upgrade_uDPU "$1"
                ;;
+       tplink,oc200)
+               platform_do_upgrade_oc200 "$1"
+               ;;
        *)
                default_do_upgrade "$1"
                ;;
@@ -56,5 +59,8 @@ platform_copy_config() {
        methode,edpu)
                platform_copy_config_uDPU
                ;;
+       tplink,oc200)
+               platform_copy_config_oc200
+               ;;
        esac
 }