Skip to content

Commit 61a0bf5

Browse files
committed
Added comments in delta update
1 parent 8555ce4 commit 61a0bf5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/update_flash.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ static int wolfBoot_delta_update(struct wolfBoot_image *boot,
486486
#endif
487487

488488
if (inverse) {
489+
/* Fallback path: accept the delta when resuming or when the base image
490+
* matches the recorded diff origin. */
489491
if (resume ||
490492
((cur_v == upd_v) && (delta_base_v <= cur_v)) ||
491493
((cur_v == delta_base_v) && (upd_v >= cur_v))) {
@@ -794,9 +796,13 @@ static int RAMFUNCTION wolfBoot_update(int fallback_allowed)
794796
* header we can't determine the direction by version numbers. instead
795797
* use the update partition state, updating means regular, new means
796798
* reverting */
799+
/* Any touched sector (or lack of recorded version) means we are
800+
* recovering from an interrupted delta application. */
797801
if ((flag != SECT_FLAG_NEW) || (cur_ver == 0)) {
798802
resume = 1;
799803
if (stateRet == 0) {
804+
/* Partition trailer tells us whether we were mid-upgrade
805+
* (UPDATING) or reverting an older image. */
800806
if (st == IMG_STATE_UPDATING) {
801807
inverse = 0;
802808
}

0 commit comments

Comments
 (0)