diff --git a/components/newlib/Kconfig b/components/newlib/Kconfig index 9a30784c21..b1ba0ed516 100644 --- a/components/newlib/Kconfig +++ b/components/newlib/Kconfig @@ -160,6 +160,22 @@ menu "LibC" - str[n]cpy - str[n]cmp + config LIBC_ASSERT_BUFFER_SIZE + int "Assert message buffer size" + range 100 2048 + default 200 + help + Size of the buffer used to format assert failure messages. + + When assertions fail, the system formats a message containing the function name, + file name, line number, and the failed expression. This option controls the + maximum length of this message. + + If you encounter truncated assert messages (especially with C++ templates or + long function names), increase this value. The default value of 200 bytes + should be sufficient for most cases, but complex template expressions may + require larger buffers. + endmenu # LibC config STDATOMIC_S32C1I_SPIRAM_WORKAROUND diff --git a/components/newlib/src/assert.c b/components/newlib/src/assert.c index 9bdb2f66cc..fbe3540d8e 100644 --- a/components/newlib/src/assert.c +++ b/components/newlib/src/assert.c @@ -9,6 +9,7 @@ #include "esp_system.h" #include "soc/soc_memory_layout.h" #include "esp_private/cache_utils.h" +#include "sdkconfig.h" #define ASSERT_STR "assert failed: " #define CACHE_DISABLED_STR "" @@ -39,7 +40,7 @@ void __attribute__((noreturn)) __assert_func(const char *file, int line, const c esp_system_abort(buff); #else char addr[11] = { 0 }; - char buff[200]; + char buff[CONFIG_LIBC_ASSERT_BUFFER_SIZE]; char lbuf[5]; uint32_t rem_len = sizeof(buff) - 1; uint32_t off = 0;