File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -760,17 +760,24 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
760760 wolfBoot_set_partition_state (PART_UPDATE , st );
761761#else
762762 uint32_t magic_trail = WOLFBOOT_MAGIC_TRAIL ;
763+ uint32_t offset ;
763764 selSec = nvm_select_fresh_sector (PART_UPDATE );
764765 XMEMCPY (NVM_CACHE , (uint8_t * )lastSector - WOLFBOOT_SECTOR_SIZE * selSec ,
765766 WOLFBOOT_SECTOR_SIZE );
766767
767768 /* Set the IMG_STATE_UPDATING flag and
768769 * the trailer magic in cache before committing to flash
769770 */
770- NVM_CACHE [WOLFBOOT_SECTOR_SIZE - (sizeof (uint32_t ) + 1 )] =
771- IMG_STATE_UPDATING ;
772- XMEMCPY (NVM_CACHE + WOLFBOOT_SECTOR_SIZE - sizeof (uint32_t ),
773- & magic_trail , sizeof (uint32_t ));
771+ offset = WOLFBOOT_SECTOR_SIZE - (sizeof (uint32_t ) + 1 );
772+ #ifdef FLAGS_HOME
773+ /* If flags are stored in BOOT partition, take into account the offset
774+ * of the flags used for the update partition too, to avoid erasing the
775+ * sector.
776+ */
777+ offset -= (PART_BOOT_ENDFLAGS - PART_UPDATE_ENDFLAGS );
778+ #endif
779+ NVM_CACHE [offset ] = st ;
780+ XMEMCPY (NVM_CACHE + offset + 1 , & magic_trail , sizeof (uint32_t ));
774781
775782 /* write to the non selected sector */
776783 hal_flash_erase (lastSector - WOLFBOOT_SECTOR_SIZE * !selSec ,
You can’t perform that action at this time.
0 commit comments