Skip to content

Commit 37d92fd

Browse files
committed
DISABLE_BACKUP is now powerfail-safe.
By not checking/updating sector flags during copies from UPDATE to BOOT partitions, a copy operation getting interrupted by power failure will be less likely to cause problems to the integrity of the BOOT image. This is because in case of interruptions, the copy operation will be restarted from the first sector.
1 parent 11017d8 commit 37d92fd

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

src/update_flash.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -553,23 +553,14 @@ static int RAMFUNCTION wolfBoot_update(int fallback_allowed)
553553
#endif
554554
hal_flash_lock();
555555
#else /* DISABLE_BACKUP */
556-
#warning "Backup mechanism disabled! Update installation will not be interruptible"
557-
/* Read encryption key/IV before starting the update */
558556
#ifdef EXT_ENCRYPTED
559557
wolfBoot_get_encrypt_key(key, nonce);
560558
#endif
561559

562560
/* Directly copy the content of the UPDATE partition into the BOOT partition.
563-
* This mechanism is not fail-safe, and will brick your device if interrupted
564-
* before the copy is finished.
565561
*/
566562
while ((sector * sector_size) < total_size) {
567-
if ((wolfBoot_get_update_sector_flag(sector, &flag) != 0) || (flag == SECT_FLAG_NEW)) {
568-
flag = SECT_FLAG_SWAPPING;
569-
wolfBoot_copy_sector(&update, &boot, sector);
570-
if (((sector + 1) * sector_size) < WOLFBOOT_PARTITION_SIZE)
571-
wolfBoot_set_update_sector_flag(sector, flag);
572-
}
563+
wolfBoot_copy_sector(&update, &boot, sector);
573564
sector++;
574565
}
575566
while((sector * sector_size) < WOLFBOOT_PARTITION_SIZE) {
@@ -578,7 +569,6 @@ static int RAMFUNCTION wolfBoot_update(int fallback_allowed)
578569
}
579570
st = IMG_STATE_SUCCESS;
580571
wolfBoot_set_partition_state(PART_BOOT, st);
581-
582572
#ifdef EXT_FLASH
583573
ext_flash_lock();
584574
#endif

0 commit comments

Comments
 (0)