Skip to content

Commit 94ecf06

Browse files
committed
Take into account offset for encryption with FLAGS_HOME
1 parent 4e4ff3c commit 94ecf06

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libwolfboot.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,18 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
768768
/* Set the IMG_STATE_UPDATING flag and
769769
* the trailer magic in cache before committing to flash
770770
*/
771+
#ifndef FLAGS_HOME
771772
offset = WOLFBOOT_SECTOR_SIZE - (sizeof(uint32_t) + 1);
772-
#ifdef FLAGS_HOME
773+
#else
773774
/* If flags are stored in BOOT partition, take into account the offset
774775
* of the flags used for the update partition too, to avoid erasing the
775776
* sector.
776777
*/
778+
#ifdef EXT_ENCRYPTED
779+
offset = WOLFBOOT_SECTOR_SIZE - TRAILER_OVERHEAD;
780+
#else
781+
offset = WOLFBOOT_SECTOR_SIZE - (sizeof(uint32_t) + 1);
782+
#endif
777783
offset -= (PART_BOOT_ENDFLAGS - PART_UPDATE_ENDFLAGS);
778784
#endif
779785
NVM_CACHE[offset] = st;

0 commit comments

Comments
 (0)