From ccd69a523e8d08cbc9d7936f1a46749a61fbd055 Mon Sep 17 00:00:00 2001 From: xiao Date: Thu, 23 Apr 2026 00:00:31 +0800 Subject: [PATCH] fix: tune FreeRTOS and RTT diagnostics for runtime stability --- Core/Inc/FreeRTOSConfig.h | 16 +++++++++------- Core/Src/debug_log.c | 2 +- Drivers/SEGGER/RTT/SEGGER_RTT_Conf.h | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index 824ce61..48e89ee 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -66,7 +66,7 @@ #define configTICK_RATE_HZ ((TickType_t)1000) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ((uint16_t)128) -#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configTOTAL_HEAP_SIZE ((size_t)21760) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 @@ -87,6 +87,8 @@ #define configTIMER_TASK_PRIORITY ( 2 ) #define configTIMER_QUEUE_LENGTH 10 #define configTIMER_TASK_STACK_DEPTH 256 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */ @@ -165,13 +167,13 @@ standard names. */ /* Application task stack sizes (in words) */ #define TASK_STACK_TCPIP 512 -#define TASK_STACK_NET_POLL 384 -#define TASK_STACK_TCP_SERVER 384 -#define TASK_STACK_TCP_CLIENT 384 -#define TASK_STACK_UART_RX 256 +#define TASK_STACK_NET_POLL 512 +#define TASK_STACK_TCP_SERVER 512 +#define TASK_STACK_TCP_CLIENT 512 +#define TASK_STACK_UART_RX 384 #define TASK_STACK_ROUTE 512 -#define TASK_STACK_CONFIG 256 -#define TASK_STACK_DEFAULT 128 +#define TASK_STACK_CONFIG 384 +#define TASK_STACK_DEFAULT 192 /* Route message pool for zero-copy inter-task communication */ #define ROUTE_MSG_POOL_SIZE 8 diff --git a/Core/Src/debug_log.c b/Core/Src/debug_log.c index dbcc94e..d2a909d 100644 --- a/Core/Src/debug_log.c +++ b/Core/Src/debug_log.c @@ -45,7 +45,7 @@ void debug_log_write(const char *msg) void debug_log_printf(const char *fmt, ...) { - char buffer[128]; + char buffer[256]; va_list args; int len; diff --git a/Drivers/SEGGER/RTT/SEGGER_RTT_Conf.h b/Drivers/SEGGER/RTT/SEGGER_RTT_Conf.h index 513e314..a6472da 100644 --- a/Drivers/SEGGER/RTT/SEGGER_RTT_Conf.h +++ b/Drivers/SEGGER/RTT/SEGGER_RTT_Conf.h @@ -92,7 +92,7 @@ Revision: $Rev: 24316 $ #endif #ifndef BUFFER_SIZE_UP - #define BUFFER_SIZE_UP (512) // Size of the buffer for terminal output of target, up to host (Default: 1k) + #define BUFFER_SIZE_UP (2048) // Size of the buffer for terminal output of target, up to host (Default: 1k) #endif #ifndef BUFFER_SIZE_DOWN @@ -100,7 +100,7 @@ Revision: $Rev: 24316 $ #endif #ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE - #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) + #define SEGGER_RTT_PRINTF_BUFFER_SIZE (128u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) #endif #ifndef SEGGER_RTT_MODE_DEFAULT