Skip to content

Commit

Permalink
Include backup/restore of UBOOT and recovery to maintain backup consi…
Browse files Browse the repository at this point in the history
…stency

Since MTK6589 BOOT partition is totally dependent on UBOOT we must make
sure that the corresponding UBOOT is backed up/restored together with
BOOT, otherwise device could be soft-bricked after restoration of
previous backup having incompatible boot/uboot pair.

Additionally, we have to make sure also recovery that is compatible
with restored boot/uboot pair is restored so device is able to boot
into recovery after restore.
The drawback of this approach is that in specific cases newer version of recovery
already present in the device will get replaced by the older one.
But... This is still the better case than to end up with
recovery that is totally unbootable...

This change makes backups fully consistent.

Change-Id: Id6ed36ae250b7b4fc54faa5c10ac327f0b623977
  • Loading branch information
C3C0 committed Apr 30, 2013
1 parent 226e86a commit c3e25de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions mmcutils/Android.mk
Expand Up @@ -19,6 +19,14 @@ ifneq ($(CWM_EMMC_RECOVERY_DEVICE_SIZE),)
LOCAL_CFLAGS += -DCWM_EMMC_RECOVERY_DEVICE_SIZE=$(CWM_EMMC_RECOVERY_DEVICE_SIZE)
endif

ifneq ($(CWM_EMMC_UBOOT_DEVICE_NAME),)
LOCAL_CFLAGS += -DCWM_EMMC_UBOOT_DEVICE_NAME="$(CWM_EMMC_UBOOT_DEVICE_NAME)"
endif

ifneq ($(CWM_EMMC_UBOOT_DEVICE_SIZE),)
LOCAL_CFLAGS += -DCWM_EMMC_UBOOT_DEVICE_SIZE=$(CWM_EMMC_UBOOT_DEVICE_SIZE)
endif

LOCAL_SRC_FILES := \
mmcutils.c

Expand Down
7 changes: 7 additions & 0 deletions mmcutils/mmcutils.c
Expand Up @@ -636,6 +636,13 @@ int cmd_mmc_backup_raw_partition(const char *partition, const char *filename)
}
#endif

#if defined(CWM_EMMC_UBOOT_DEVICE_NAME) && defined(CWM_EMMC_UBOOT_DEVICE_SIZE)
if (strcmp(partition, STR(CWM_EMMC_UBOOT_DEVICE_NAME)) == 0) {
size = CWM_EMMC_UBOOT_DEVICE_SIZE;
printf("CWM_EMMC_UBOOT_DEVICE: %s; Size: 0x%x\n", partition, size);
}
#endif

return mmc_raw_dump_internal(partition, filename, size);
}
}
Expand Down
16 changes: 14 additions & 2 deletions nandroid.c
Expand Up @@ -358,6 +358,9 @@ int nandroid_backup(const char* backup_path)
if (0 != (ret = nandroid_backup_partition(backup_path, "/boot")))
return ret;

if (0 != (ret = nandroid_backup_partition(backup_path, "/uboot")))
return ret;

if (0 != (ret = nandroid_backup_partition(backup_path, "/recovery")))
return ret;

Expand Down Expand Up @@ -677,8 +680,17 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst

int ret;

if (restore_boot && NULL != volume_for_path("/boot") && 0 != (ret = nandroid_restore_partition(backup_path, "/boot")))
return ret;
if (restore_boot)
{
if (NULL != volume_for_path("/boot") && 0 != (ret = nandroid_restore_partition(backup_path, "/boot")))
return ret;

if (NULL != volume_for_path("/uboot") && 0 != (ret = nandroid_restore_partition(backup_path, "/uboot")))
return ret;

if (NULL != volume_for_path("/recovery") && 0 != (ret = nandroid_restore_partition(backup_path, "/recovery")))
return ret;
}

struct stat s;
Volume *vol = volume_for_path("/wimax");
Expand Down

0 comments on commit c3e25de

Please sign in to comment.