mirror of https://github.com/wolfSSL/wolfBoot.git
DUALBANK: fork_bootloader should only execute once
fork_bootloader() should perform a physical copy of the bootloader to its partition in the second bank only if the content of the two partitions does not already match.pull/407/head
parent
9e2aaebed3
commit
c25497eba9
21
docs/HAL.md
21
docs/HAL.md
|
@ -114,3 +114,24 @@ by the bootloader at the end of every write and erase operations on the external
|
|||
If the IAP interface of the external memory requires it, this function
|
||||
is called before every write and erase operations to unlock write access to the
|
||||
device. On some drivers, this function may be empty.
|
||||
|
||||
|
||||
### Additional functions required by `DUALBANK_SWAP` option
|
||||
|
||||
If the target device supports hardware-assisted bank swapping, it is appropriate
|
||||
to provide two additional functions in the port:
|
||||
|
||||
`void hal_flash_dualbank_swap(void)`
|
||||
|
||||
Called by the bootloader when the two banks must be swapped. On some architectures
|
||||
this operation implies a reboot, so this function may also never return.
|
||||
|
||||
|
||||
`void fork_bootloader(void)`
|
||||
|
||||
This function is called to provide a second copy of the bootloader. Wolfboot will
|
||||
clone itself if the content does not already match. `fork_bootloader()`
|
||||
implementation in new ports must return immediately without performing any actions
|
||||
if the content of the bootloader partition in the two banks already match.
|
||||
|
||||
|
||||
|
|
|
@ -461,6 +461,10 @@ void RAMFUNCTION fork_bootloader(void)
|
|||
uint32_t r = 0, w = 0;
|
||||
int i;
|
||||
|
||||
/* Return if content already matches */
|
||||
if (memcmp(data, (void *)WOLFBOOT_COPY_BOOTLOADER, BOOTLOADER_SIZE) == 0)
|
||||
return;
|
||||
|
||||
/* Read the wolfBoot image in RAM */
|
||||
memcpy(bootloader_copy_mem, data, BOOTLOADER_SIZE);
|
||||
|
||||
|
|
|
@ -376,6 +376,10 @@ static void RAMFUNCTION fork_bootloader(void)
|
|||
uint32_t r = 0, w = 0;
|
||||
int i;
|
||||
|
||||
/* Return if content already matches */
|
||||
if (memcmp(data, (void *)FLASH_BANK2_BASE, BOOTLOADER_SIZE) == 0)
|
||||
return;
|
||||
|
||||
/* Read the wolfBoot image in RAM */
|
||||
memcpy(bootloader_copy_mem, data, BOOTLOADER_SIZE);
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ static void clock_pll_off(void)
|
|||
DMB();
|
||||
}
|
||||
|
||||
/* This implementation will setup MSI 48 MHz as PLL Source Mux, PLLCLK as
|
||||
/* This implementation will setup MSI 48 MHz as PLL Source Mux, PLLCLK as
|
||||
* System Clock Source */
|
||||
static void clock_pll_on(int powersave)
|
||||
{
|
||||
|
@ -490,6 +490,10 @@ static void RAMFUNCTION fork_bootloader(void)
|
|||
uint32_t r = 0, w = 0;
|
||||
int i;
|
||||
|
||||
/* Return if content already matches */
|
||||
if (memcmp(data, (void *)FLASH_BANK2_BASE, BOOTLOADER_SIZE) == 0)
|
||||
return;
|
||||
|
||||
/* Read the wolfBoot image in RAM */
|
||||
memcpy(bootloader_copy_mem, data, BOOTLOADER_SIZE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue