@@ -752,23 +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 );
756756 wolfBoot_set_partition_state (PART_UPDATE , st );
757757 } else {
758758#ifndef NVM_FLASH_WRITEONCE
759- hal_flash_erase (lastSector , SECTOR_FLAGS_SIZE );
759+ hal_flash_erase (lastSector , WOLFBOOT_SECTOR_SIZE );
760760 wolfBoot_set_partition_state (PART_UPDATE , st );
761761#else
762762 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
763767 selSec = nvm_select_fresh_sector (PART_UPDATE );
764768 XMEMCPY (NVM_CACHE , (uint8_t * )lastSector - WOLFBOOT_SECTOR_SIZE * selSec ,
765769 WOLFBOOT_SECTOR_SIZE );
766770 /* write to the non selected sector */
767771 hal_flash_erase (lastSector - WOLFBOOT_SECTOR_SIZE * !selSec ,
768772 WOLFBOOT_SECTOR_SIZE );
769773
770- NVM_CACHE [SECTOR_FLAGS_SIZE ] = IMG_STATE_UPDATING ;
771- memcpy (NVM_CACHE + SECTOR_FLAGS_SIZE + 1 , & magic , sizeof (uint32_t ));
774+ NVM_CACHE [offset ] = IMG_STATE_UPDATING ;
775+ memcpy (NVM_CACHE + offset + 1 , & magic , sizeof (uint32_t ));
772776 hal_flash_write (lastSector - WOLFBOOT_SECTOR_SIZE * !selSec , NVM_CACHE ,
773777 WOLFBOOT_SECTOR_SIZE );
774778 /* erase the previously selected sector */
0 commit comments