Change the location of the reset partitions_cloned flag 07/275707/3
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Mon, 30 May 2022 14:17:59 +0000 (16:17 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 31 May 2022 08:34:31 +0000 (10:34 +0200)
The flag must be reset after verifying that partitions are currently
cloned, and before modifying partition contents.

Change-Id: Ieb1144ad1ff91d33acc1a0c7025d851a1d1992c3

scripts/upgrade-full.sh
scripts/upgrade-trigger.sh

index c37267d..f69b10b 100755 (executable)
@@ -63,13 +63,6 @@ reboot_to_fota() {
 check_ab_partition_scheme
 check_used_block_device
 unpack_file "$DELTA_TAR" "$CONFIG_FILE"
-if [ "$(device_board_get_partition_ab_cloned)" -eq 0 ]; then
-       load_background_copy_list
-       background_copy
-else
-       echo "[Info] Partitions already cloned"
-fi
-set_upgrade_status 20
 upgrade_images "$DOWNLOAD_DELTA"
 set_upgrade_status 80
 reboot_to_fota
index 9298f78..777cd5f 100755 (executable)
@@ -63,16 +63,30 @@ is_ab_upgrade() {
 }
 
 do_update() {
-       device_board_clear_partition_ab_cloned
-
        if is_ab_upgrade; then
+               set_upgrade_status 5
+
+               if [ "$(device_board_get_partition_ab_cloned)" -eq 0 ]; then
+                       unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"
+                       if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"; then
+                               exit_error
+                       fi
+               else
+                       echo "[Info] Partitions already cloned"
+               fi
+
+               set_upgrade_status 20
+
+               # In the next steps the content of the partitions of the second slot will
+               # be modified, so they will not be a clone of the current partitions
+               device_board_clear_partition_ab_cloned
+
                if is_full_upgrade; then
                        # If the update.cfg file contains only PRE_UA type updates, we consider
                        # it a full upgrade. In this case the provided images will be flashed to
                        # the appropriate partitions directly from the archive so as not to
                        # consume additional space on the device.
                        unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_FULL}"
-                       set_upgrade_status 5
                        if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_FULL}" "${DOWNLOAD_DELTA}"; then
                                exit_error
                        fi
@@ -80,18 +94,6 @@ do_update() {
                        # Regular A/B Upgrade
                        unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_PARTIAL}"
                        unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_FOTA}"
-                       set_upgrade_status 5
-
-                       if [ "$(device_board_get_partition_ab_cloned)" -eq 0 ]; then
-                               unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"
-                               if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"; then
-                                       exit_error
-                               fi
-                       else
-                               echo "[Info] Partitions already cloned"
-                       fi
-
-                       set_upgrade_status 20
 
                        if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_PARTIAL}" "${DOWNLOAD_DELTA}"; then
                                exit_error