From 1dda8b9e60a5c1e9c4a1cba75ddfd44b12dbee14 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Thu, 2 Nov 2023 14:58:52 -0300 Subject: [PATCH] Fix H743 FreeRTOS early SysTick crash --- .../nucleo-h743zi-make-freertos-builtin/FreeRTOSConfig.h | 2 +- examples/stm32/nucleo-h743zi-make-freertos-builtin/main.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/stm32/nucleo-h743zi-make-freertos-builtin/FreeRTOSConfig.h b/examples/stm32/nucleo-h743zi-make-freertos-builtin/FreeRTOSConfig.h index 9a933a2346..71d9c4bc9d 100644 --- a/examples/stm32/nucleo-h743zi-make-freertos-builtin/FreeRTOSConfig.h +++ b/examples/stm32/nucleo-h743zi-make-freertos-builtin/FreeRTOSConfig.h @@ -35,4 +35,4 @@ #define vPortSVCHandler SVC_Handler #define xPortPendSVHandler PendSV_Handler -#define xPortSysTickHandler SysTick_Handler +//#define xPortSysTickHandler SysTick_Handler diff --git a/examples/stm32/nucleo-h743zi-make-freertos-builtin/main.c b/examples/stm32/nucleo-h743zi-make-freertos-builtin/main.c index 272030a910..9706f30afc 100644 --- a/examples/stm32/nucleo-h743zi-make-freertos-builtin/main.c +++ b/examples/stm32/nucleo-h743zi-make-freertos-builtin/main.c @@ -7,6 +7,13 @@ #define BLINK_PERIOD_MS 1000 // LED blinking period in millis +// workaround SysTick firing before FreeRTOS has fully initialized (startup) +extern void xPortSysTickHandler(void); +void SysTick_Handler(void) { + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + xPortSysTickHandler(); +} + void mg_random(void *buf, size_t len) { // Use on-board RNG for (size_t n = 0; n < len; n += sizeof(uint32_t)) { uint32_t r = rng_read();