File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,9 @@ static int wolfBoot_swap_and_final_erase(int resume)
247247 }
248248
249249 hal_flash_unlock ();
250+ #ifdef EXT_ENCRYPTED
251+ ext_flash_unlock ();
252+ #endif
250253
251254 /* IMG_STATE_FINAL_FLAGS allows re-entry without blowing away swap */
252255 if (st != IMG_STATE_FINAL_FLAGS ) {
@@ -256,8 +259,6 @@ static int wolfBoot_swap_and_final_erase(int resume)
256259 wolfBoot_set_partition_state (PART_UPDATE , IMG_STATE_FINAL_FLAGS );
257260 }
258261#ifdef EXT_ENCRYPTED
259- ext_flash_unlock ();
260-
261262 if (swapDone == 0 ) {
262263 /* get encryption key and iv if encryption is enabled */
263264 wolfBoot_get_encrypt_key ((uint8_t * )tmpBuffer ,
@@ -937,9 +938,25 @@ void RAMFUNCTION wolfBoot_start(void)
937938 wolfBoot_check_self_update ();
938939#endif
939940
941+ #ifdef NVM_FLASH_WRITEONCE
942+ /* nvm_select_fresh_sector needs unlocked flash in cases where */
943+ hal_flash_unlock ();
944+ #ifdef EXT_FLASH
945+ ext_flash_unlock ();
946+ #endif
947+ #endif
948+
940949 bootRet = wolfBoot_get_partition_state (PART_BOOT , & bootState );
941950 updateRet = wolfBoot_get_partition_state (PART_UPDATE , & updateState );
942951
952+ #ifdef NVM_FLASH_WRITEONCE
953+ /* nvm_select_fresh_sector needs unlocked flash in cases where */
954+ hal_flash_lock ();
955+ #ifdef EXT_FLASH
956+ ext_flash_lock ();
957+ #endif
958+ #endif
959+
943960#if !defined(DISABLE_BACKUP )
944961 /* resume the final erase in case the power failed before it finished */
945962 resumedFinalErase = wolfBoot_swap_and_final_erase (1 );
You can’t perform that action at this time.
0 commit comments