From 032645f0d4bf47496c9dc6856a76e9ea55841f92 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 19 Dec 2024 21:25:43 +0100 Subject: [PATCH 1/3] bootloaders/riotboot: don't change CPU/pin state --- bootloaders/riotboot/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bootloaders/riotboot/Makefile b/bootloaders/riotboot/Makefile index 4800be4f9e4e..bd478e0a24e7 100644 --- a/bootloaders/riotboot/Makefile +++ b/bootloaders/riotboot/Makefile @@ -4,4 +4,8 @@ APPLICATION = riotboot # Include riotboot flash partition functionality USEMODULE += riotboot_slot +# We don't want to re-configure any hardware +CFLAGS += -DDISABLE_BOARD_INIT=1 +CFLAGS += -DDISABLE_CPU_INIT=1 + include ../riotboot_common.mk From 5e2ec9d51dab66531c518d700180392791776980 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 19 Dec 2024 21:26:14 +0100 Subject: [PATCH 2/3] cpu/cortexm_common: add option to skip hardware init --- cpu/cortexm_common/vectors_cortexm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cpu/cortexm_common/vectors_cortexm.c b/cpu/cortexm_common/vectors_cortexm.c index f70419bc648a..4d7b9274fa93 100644 --- a/cpu/cortexm_common/vectors_cortexm.c +++ b/cpu/cortexm_common/vectors_cortexm.c @@ -197,12 +197,15 @@ void reset_handler_default(void) dbgpin_init(); #endif +#if !DISABLE_CPU_INIT /* initialize the CPU */ extern void cpu_init(void); cpu_init(); - - /* initialize the board (which also initiates CPU initialization) */ +#endif +#if !DISABLE_BOARD_INIT + /* initialize the board */ board_init(); +#endif #if MODULE_NEWLIB || MODULE_PICOLIBC /* initialize std-c library (this must be done after board_init) */ From 581bd8afadf85ae2171429d876a5560e59c088d4 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 16 Jan 2025 18:12:21 +0100 Subject: [PATCH 3/3] cpu: add documentation for DISABLE_BOARD_INIT/DISABLE_CPU_INIT --- cpu/doc.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cpu/doc.txt b/cpu/doc.txt index 467ada6e6af4..a58d2c56c1fd 100644 --- a/cpu/doc.txt +++ b/cpu/doc.txt @@ -20,3 +20,27 @@ * @ingroup config * @brief Compile time configurations for different kinds of CPU. */ + +/** + * @brief Skip calling `board_init()` + * + * Don't call `board_init()`, leave all pins in their default state. + * + * This is intended to be used with basic riotboot_slot which does not interact + * with any external hardware. + * + * @experimental Only use this if you know what you are doing + */ +#define DISABLE_BOARD_INIT 0 + +/** + * @brief Skip calling `cpu_init()` + * + * Don't call `cpu_init()`, leave all CPU configuration in boot-up state. + * + * This is intended to be used with basic riotboot_slot which does not interact + * with any CPU peripherals. + * + * @experimental Only use this if you know what you are doing + */ +#define DISABLE_CPU_INIT 0