Peer review fixes. Added new WOLFBOOT_RESTORE_CLOCK option

pull/622/head
David Garske 2025-11-18 11:04:43 -08:00 committed by Daniele Lacamera
parent 3a85a27fb9
commit ecf1cb8a92
24 changed files with 46 additions and 14 deletions

View File

@ -267,7 +267,7 @@ ifeq ($(ARCH),ARM)
endif
ifeq ($(TARGET),va416x0)
CFLAGS+=-I$(WOLFBOOT_ROOT)/include/vorago/ \
CFLAGS+=-I$(WOLFBOOT_ROOT)/hal/vorago/ \
-I$(VORAGO_SDK_DIR)/common/drivers/hdr/ \
-I$(VORAGO_SDK_DIR)/common/mcu/hdr/ \
-I$(VORAGO_SDK_DIR)/common/utils/hdr/

View File

@ -75,5 +75,5 @@ USE_HAL_SPI_FRAM=1
#CFLAGS_EXTRA+=-DWOLFBOOT_EDAC_RAM_SCRUB=1000
#CFLAGS_EXTRA+=-DWOLFBOOT_EDAC_ROM_SCRUB=125
# Optionally restore clock to heart-beat oscillator after boot
#CFLAGS_EXTRA+=-DWOLFBOOT_RESTORE_CLOCK
# Leave clock at 100MHz (to restore clock to heart beat oscillator use =1)
WOLFBOOT_RESTORE_CLOCK?=0

View File

@ -69,7 +69,8 @@ the geometry of the flash sectors, and erase all the sectors in between.
This function is called by the bootloader at a very late stage, before chain-loading the firmware
in the next stage. This can be used to revert all the changes made to the clock settings, to ensure
that the state of the microcontroller is restored to its original settings.
that the state of the microcontroller is restored to its original settings. By default most targets will restore the
clock settings. Use the `WOLFBOOT_RESTORE_CLOCK=0` option to disable clock restoration.
### Optional support for external flash memory

View File

@ -124,7 +124,9 @@ void hal_init(void)
void hal_prepare_boot(void)
{
#ifdef WOLFBOOT_RESTORE_CLOCK
TASKS_HFCLKSTOP = 1;
#endif
}
#endif /* TARGET_nrf52 */

View File

@ -73,7 +73,7 @@ void hal_init(void)
void hal_prepare_boot(void)
{
#ifndef TZEN
#if !defined(TZEN) && defined(WOLFBOOT_RESTORE_CLOCK)
pic32_clock_reset();
#endif
}

View File

@ -104,5 +104,7 @@ void hal_init(void)
void hal_prepare_boot(void)
{
#ifdef WOLFBOOT_RESTORE_CLOCK
pic32_clock_reset();
#endif
}

View File

@ -317,6 +317,7 @@ void RAMFUNCTION hal_flash_dualbank_swap(void)
void RAMFUNCTION hal_prepare_boot(void)
{
#ifdef WOLFBOOT_RESTORE_CLOCK
/* Reset clock controller */
GCLK_CTRLA |= CTRLA_SWRST;
@ -332,6 +333,7 @@ void RAMFUNCTION hal_prepare_boot(void)
/* Clear PLL options */
OSCCTRL_DPLL0CTRLB = 0;
#endif
}
#endif /* __WOLFBOOT */

View File

@ -144,6 +144,7 @@ void hal_init(void)
void hal_prepare_boot(void)
{
#ifdef WOLFBOOT_RESTORE_CLOCK
/* Reset NVM wait states */
APBBMASK_REG |= APBBMASK_NVM_EN;
NVMCTRLB_REG &= ~((WAITSTATES & 0x0f) << 1);
@ -152,6 +153,7 @@ void hal_prepare_boot(void)
/* Reset clock controller */
GCLK_CTRL = GCLK_CTRL_RESET;
GCLK_WAITBUSY();
#endif
}

View File

@ -301,7 +301,9 @@ void RAMFUNCTION hal_prepare_boot(void)
#ifdef SPI_FLASH
spi_flash_release();
#endif
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
#ifdef FLASH_SECURABLE_MEMORY_SUPPORT
do_secure_boot();
#endif

View File

@ -330,5 +330,7 @@ void hal_init(void)
void hal_prepare_boot(void)
{
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
}

View File

@ -345,7 +345,8 @@ void hal_prepare_boot(void)
#ifdef SPI_FLASH
spi_flash_release();
#endif
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
}

View File

@ -423,8 +423,9 @@ void RAMFUNCTION hal_prepare_boot(void)
#ifdef SPI_FLASH
spi_flash_release();
#endif
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
}
void RAMFUNCTION hal_erase_bank2(void)

View File

@ -333,7 +333,9 @@ void RAMFUNCTION hal_prepare_boot(void)
#ifdef SPI_FLASH
spi_flash_release();
#endif
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
#ifdef FLASH_SECURABLE_MEMORY_SUPPORT
do_secure_boot();
#endif

View File

@ -608,7 +608,9 @@ void hal_prepare_boot(void)
#if (TZ_SECURE())
periph_unsecure();
#else
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
#endif
}

View File

@ -510,7 +510,9 @@ void hal_prepare_boot(void)
#ifdef SPI_FLASH
spi_flash_release();
#endif
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
}
#ifdef FLASH_OTP_KEYSTORE

View File

@ -262,8 +262,10 @@ void hal_prepare_boot(void)
spi_flash_release();
#endif
hal_flash_lock();
#ifdef WOLFBOOT_RESTORE_CLOCK
if ((FLASH_PECR & FLASH_PECR_PELOCK) == 0)
FLASH_PECR |= FLASH_PECR_PELOCK;
clock_pll_off();
#endif
}

View File

@ -279,8 +279,9 @@ void hal_prepare_boot(void)
#ifdef SPI_FLASH
spi_flash_release();
#endif
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
}
/* This value is unused, the function is never called

View File

@ -409,7 +409,9 @@ void hal_init(void)
void hal_prepare_boot(void)
{
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
periph_unsecure();
#endif

View File

@ -520,8 +520,9 @@ void hal_init(void)
void hal_prepare_boot(void)
{
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
#if TZ_SECURE()
led_unsecure();
#endif

View File

@ -325,7 +325,9 @@ void hal_prepare_boot(void)
#ifdef SPI_FLASH
spi_flash_release();
#endif
#ifdef WOLFBOOT_RESTORE_CLOCK
clock_pll_off();
#endif
}
#ifdef WOLFSSL_STM32_PKA

View File

@ -1,4 +1,4 @@
_Min_Heap_Size = 0x00000200; /* required amount of heap */
# no heap
_Min_Stack_Size = 0x00006000; /* required amount of stack */
/* Memory areas */
@ -140,14 +140,12 @@ SECTIONS
*(dma_blk)
} >RAM1
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
/* User_stack section, used to check that there is enough RAM left */
._user_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
PROVIDE ( _start_heap = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
PROVIDE ( END_STACK = . );

View File

@ -1040,3 +1040,8 @@ endif
ifneq ($(WOLFBOOT_PARTITION_FILENAME),)
CFLAGS += -DWOLFBOOT_PARTITION_FILENAME=$(WOLFBOOT_PARTITION_FILENAME)
endif
# Clock Restore Option (default on)
ifneq ($(WOLFBOOT_RESTORE_CLOCK),0)
CFLAGS += -DWOLFBOOT_RESTORE_CLOCK
endif