@@ -752,17 +752,27 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
752752 * FLAGS_INVERT needs erased flags because the bin-assemble's fill byte may
753753 * not match what's in wolfBoot */
754754 if (FLAGS_UPDATE_EXT ()) {
755- ext_flash_erase (lastSector , SECTOR_FLAGS_SIZE );
755+ ext_flash_erase (lastSector , WOLFBOOT_SECTOR_SIZE );
756+ wolfBoot_set_partition_state (PART_UPDATE , st );
756757 } else {
757758#ifndef NVM_FLASH_WRITEONCE
758- hal_flash_erase (lastSector , SECTOR_FLAGS_SIZE );
759+ hal_flash_erase (lastSector , WOLFBOOT_SECTOR_SIZE );
760+ wolfBoot_set_partition_state (PART_UPDATE , st );
759761#else
762+ uint32_t magic = WOLFBOOT_MAGIC_TRAIL ;
763+ uint32_t offset = SECTOR_FLAGS_SIZE ;
764+ #ifdef FLAGS_HOME
765+ offset -= (PART_BOOT_ENDFLAGS - PART_UPDATE_ENDFLAGS );
766+ #endif
760767 selSec = nvm_select_fresh_sector (PART_UPDATE );
761768 XMEMCPY (NVM_CACHE , (uint8_t * )lastSector - WOLFBOOT_SECTOR_SIZE * selSec ,
762769 WOLFBOOT_SECTOR_SIZE );
763770 /* write to the non selected sector */
764771 hal_flash_erase (lastSector - WOLFBOOT_SECTOR_SIZE * !selSec ,
765772 WOLFBOOT_SECTOR_SIZE );
773+
774+ NVM_CACHE [offset ] = IMG_STATE_UPDATING ;
775+ memcpy (NVM_CACHE + offset + 1 , & magic , sizeof (uint32_t ));
766776 hal_flash_write (lastSector - WOLFBOOT_SECTOR_SIZE * !selSec , NVM_CACHE ,
767777 WOLFBOOT_SECTOR_SIZE );
768778 /* erase the previously selected sector */
@@ -771,7 +781,6 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
771781#endif
772782 }
773783
774- wolfBoot_set_partition_state (PART_UPDATE , st );
775784
776785 if (FLAGS_UPDATE_EXT ()) {
777786 ext_flash_lock ();
0 commit comments