File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,3 +114,24 @@ by the bootloader at the end of every write and erase operations on the external
114114If the IAP interface of the external memory requires it, this function
115115is called before every write and erase operations to unlock write access to the
116116device. On some drivers, this function may be empty.
117+
118+
119+ ### Additional functions required by ` DUALBANK_SWAP ` option
120+
121+ If the target device supports hardware-assisted bank swapping, it is appropriate
122+ to provide two additional functions in the port:
123+
124+ ` void hal_flash_dualbank_swap(void) `
125+
126+ Called by the bootloader when the two banks must be swapped. On some architectures
127+ this operation implies a reboot, so this function may also never return.
128+
129+
130+ ` void fork_bootloader(void) `
131+
132+ This function is called to provide a second copy of the bootloader. Wolfboot will
133+ clone itself if the content does not already match. ` fork_bootloader() `
134+ implementation in new ports must return immediately without performing any actions
135+ if the content of the bootloader partition in the two banks already match.
136+
137+
Original file line number Diff line number Diff line change @@ -461,6 +461,10 @@ void RAMFUNCTION fork_bootloader(void)
461461 uint32_t r = 0 , w = 0 ;
462462 int i ;
463463
464+ /* Return if content already matches */
465+ if (memcmp (data , (void * )WOLFBOOT_COPY_BOOTLOADER , BOOTLOADER_SIZE ) == 0 )
466+ return ;
467+
464468 /* Read the wolfBoot image in RAM */
465469 memcpy (bootloader_copy_mem , data , BOOTLOADER_SIZE );
466470
Original file line number Diff line number Diff line change @@ -376,6 +376,10 @@ static void RAMFUNCTION fork_bootloader(void)
376376 uint32_t r = 0 , w = 0 ;
377377 int i ;
378378
379+ /* Return if content already matches */
380+ if (memcmp (data , (void * )FLASH_BANK2_BASE , BOOTLOADER_SIZE ) == 0 )
381+ return ;
382+
379383 /* Read the wolfBoot image in RAM */
380384 memcpy (bootloader_copy_mem , data , BOOTLOADER_SIZE );
381385
Original file line number Diff line number Diff line change @@ -241,7 +241,7 @@ static void clock_pll_off(void)
241241 DMB ();
242242}
243243
244- /* This implementation will setup MSI 48 MHz as PLL Source Mux, PLLCLK as
244+ /* This implementation will setup MSI 48 MHz as PLL Source Mux, PLLCLK as
245245 * System Clock Source */
246246static void clock_pll_on (int powersave )
247247{
@@ -490,6 +490,10 @@ static void RAMFUNCTION fork_bootloader(void)
490490 uint32_t r = 0 , w = 0 ;
491491 int i ;
492492
493+ /* Return if content already matches */
494+ if (memcmp (data , (void * )FLASH_BANK2_BASE , BOOTLOADER_SIZE ) == 0 )
495+ return ;
496+
493497 /* Read the wolfBoot image in RAM */
494498 memcpy (bootloader_copy_mem , data , BOOTLOADER_SIZE );
495499
You can’t perform that action at this time.
0 commit comments