Skip to content

Commit 26787f2

Browse files
committed
Peer review fixes. Added new WOLFBOOT_RESTORE_CLOCK option
1 parent 14bee12 commit 26787f2

24 files changed

+46
-14
lines changed

arch.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ ifeq ($(ARCH),ARM)
267267
endif
268268

269269
ifeq ($(TARGET),va416x0)
270-
CFLAGS+=-I$(WOLFBOOT_ROOT)/include/vorago/ \
270+
CFLAGS+=-I$(WOLFBOOT_ROOT)/hal/vorago/ \
271271
-I$(VORAGO_SDK_DIR)/common/drivers/hdr/ \
272272
-I$(VORAGO_SDK_DIR)/common/mcu/hdr/ \
273273
-I$(VORAGO_SDK_DIR)/common/utils/hdr/

config/examples/vorago_va416x0.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ USE_HAL_SPI_FRAM=1
7575
#CFLAGS_EXTRA+=-DWOLFBOOT_EDAC_RAM_SCRUB=1000
7676
#CFLAGS_EXTRA+=-DWOLFBOOT_EDAC_ROM_SCRUB=125
7777

78-
# Optionally restore clock to heart-beat oscillator after boot
79-
#CFLAGS_EXTRA+=-DWOLFBOOT_RESTORE_CLOCK
78+
# Leave clock at 100MHz (to restore clock to heart beat oscillator use =1)
79+
WOLFBOOT_RESTORE_CLOCK?=0

docs/HAL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ the geometry of the flash sectors, and erase all the sectors in between.
6969

7070
This function is called by the bootloader at a very late stage, before chain-loading the firmware
7171
in the next stage. This can be used to revert all the changes made to the clock settings, to ensure
72-
that the state of the microcontroller is restored to its original settings.
72+
that the state of the microcontroller is restored to its original settings. By default most targets will restore the
73+
clock settings. Use the `WOLFBOOT_RESTORE_CLOCK=0` option to disable clock restoration.
7374

7475
### Optional support for external flash memory
7576

hal/nrf52.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ void hal_init(void)
124124

125125
void hal_prepare_boot(void)
126126
{
127+
#ifdef WOLFBOOT_RESTORE_CLOCK
127128
TASKS_HFCLKSTOP = 1;
129+
#endif
128130
}
129131

130132
#endif /* TARGET_nrf52 */

hal/pic32ck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void hal_init(void)
7373

7474
void hal_prepare_boot(void)
7575
{
76-
#ifndef TZEN
76+
#if !defined(TZEN) && defined(WOLFBOOT_RESTORE_CLOCK)
7777
pic32_clock_reset();
7878
#endif
7979
}

hal/pic32cz.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,7 @@ void hal_init(void)
104104

105105
void hal_prepare_boot(void)
106106
{
107+
#ifdef WOLFBOOT_RESTORE_CLOCK
107108
pic32_clock_reset();
109+
#endif
108110
}

hal/same51.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ void RAMFUNCTION hal_flash_dualbank_swap(void)
317317

318318
void RAMFUNCTION hal_prepare_boot(void)
319319
{
320+
#ifdef WOLFBOOT_RESTORE_CLOCK
320321
/* Reset clock controller */
321322
GCLK_CTRLA |= CTRLA_SWRST;
322323

@@ -332,6 +333,7 @@ void RAMFUNCTION hal_prepare_boot(void)
332333

333334
/* Clear PLL options */
334335
OSCCTRL_DPLL0CTRLB = 0;
336+
#endif
335337
}
336338

337339
#endif /* __WOLFBOOT */

hal/samr21.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ void hal_init(void)
144144

145145
void hal_prepare_boot(void)
146146
{
147+
#ifdef WOLFBOOT_RESTORE_CLOCK
147148
/* Reset NVM wait states */
148149
APBBMASK_REG |= APBBMASK_NVM_EN;
149150
NVMCTRLB_REG &= ~((WAITSTATES & 0x0f) << 1);
@@ -152,6 +153,7 @@ void hal_prepare_boot(void)
152153
/* Reset clock controller */
153154
GCLK_CTRL = GCLK_CTRL_RESET;
154155
GCLK_WAITBUSY();
156+
#endif
155157
}
156158

157159

hal/stm32c0.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ void RAMFUNCTION hal_prepare_boot(void)
301301
#ifdef SPI_FLASH
302302
spi_flash_release();
303303
#endif
304+
#ifdef WOLFBOOT_RESTORE_CLOCK
304305
clock_pll_off();
306+
#endif
305307
#ifdef FLASH_SECURABLE_MEMORY_SUPPORT
306308
do_secure_boot();
307309
#endif

hal/stm32f1.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,7 @@ void hal_init(void)
330330

331331
void hal_prepare_boot(void)
332332
{
333+
#ifdef WOLFBOOT_RESTORE_CLOCK
333334
clock_pll_off();
335+
#endif
334336
}

0 commit comments

Comments
 (0)