File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -486,7 +486,9 @@ static int wolfBoot_delta_update(struct wolfBoot_image *boot,
486486#endif
487487
488488 if (inverse ) {
489- if (((cur_v == upd_v ) && (delta_base_v < cur_v )) || resume ) {
489+ if (resume ||
490+ ((cur_v == upd_v ) && (delta_base_v <= cur_v )) ||
491+ ((cur_v == delta_base_v ) && (upd_v >= cur_v ))) {
490492 ret = wb_patch_init (& ctx , boot -> hdr , boot -> fw_size +
491493 IMAGE_HEADER_SIZE , update -> hdr + * img_offset , * img_size );
492494 } else {
@@ -792,19 +794,22 @@ static int RAMFUNCTION wolfBoot_update(int fallback_allowed)
792794 * header we can't determine the direction by version numbers. instead
793795 * use the update partition state, updating means regular, new means
794796 * reverting */
795- if ((stateRet == 0 ) && (( flag != SECT_FLAG_NEW ) || (cur_ver == 0 ) )) {
797+ if ((flag != SECT_FLAG_NEW ) || (cur_ver == 0 )) {
796798 resume = 1 ;
797- if (st == IMG_STATE_UPDATING ) {
798- inverse = 0 ;
799- }
800- else {
801- inverse = 1 ;
799+ if (stateRet == 0 ) {
800+ if (st == IMG_STATE_UPDATING ) {
801+ inverse = 0 ;
802+ }
803+ else {
804+ inverse = 1 ;
805+ }
802806 }
803807 }
804808 /* If we're dealing with a "ping-pong" fallback that wasn't interrupted
805809 * we need to set to UPDATING, otherwise there's no way to tell the
806810 * original direction of the update once interrupted */
807- else if ((inverse == 0 ) && (fallback_allowed == 1 )) {
811+ else if ((inverse == 0 ) && (fallback_allowed == 1 ) &&
812+ (cur_ver >= upd_ver )) {
808813 hal_flash_unlock ();
809814#ifdef EXT_FLASH
810815 ext_flash_unlock ();
You can’t perform that action at this time.
0 commit comments