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
Daniele Lacamera 2024-02-15 16:45:08 +01:00
parent 9e2aaebed3
commit c25497eba9
4 changed files with 34 additions and 1 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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);

View File

@ -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);