From 3050f06a8ddc30a70d5b4752b38aa51755a64160 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 27 Feb 2017 11:46:16 +1100 Subject: [PATCH 1/3] FreeRTOS: Support setting task name max length Ref: https://esp32.com/viewtopic.php?f=13&t=1297&p=5762 --- components/freertos/Kconfig | 11 +++++++++++ components/freertos/include/freertos/FreeRTOSConfig.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index ee2b289ef8..c28287644d 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -164,6 +164,17 @@ config FREERTOS_LEGACY_TICK_HOOK endif #FREERTOS_LEGACY_HOOKS +config FREERTOS_MAX_TASK_NAME_LEN + int "Maximum task name length" + range 1 256 + default 16 + help + Changes the maximum task name length. Each task allocated will + include this many bytes for a task name. Using a shorter value + saves a small amount of RAM, a longer value allows more complex + names. + + For most uses, the default of 16 is OK. menuconfig FREERTOS_DEBUG_INTERNALS bool "Debug FreeRTOS internals" diff --git a/components/freertos/include/freertos/FreeRTOSConfig.h b/components/freertos/include/freertos/FreeRTOSConfig.h index 9deb9f4b5e..4f40330398 100644 --- a/components/freertos/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/include/freertos/FreeRTOSConfig.h @@ -187,7 +187,7 @@ #define configAPPLICATION_ALLOCATED_HEAP 1 #define configTOTAL_HEAP_SIZE (&_heap_end - &_heap_start)//( ( size_t ) (64 * 1024) ) -#define configMAX_TASK_NAME_LEN ( 16 ) +#define configMAX_TASK_NAME_LEN ( CONFIG_FREERTOS_MAX_TASK_NAME_LEN ) #define configUSE_TRACE_FACILITY 0 /* Used by vTaskList in main.c */ #define configUSE_STATS_FORMATTING_FUNCTIONS 0 /* Used by vTaskList in main.c */ #define configUSE_TRACE_FACILITY_2 0 /* Provided by Xtensa port patch */ From 47a5851d4599498c5a1f9b612242b9362bb9250f Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 27 Feb 2017 11:49:46 +1100 Subject: [PATCH 2/3] freertos: Move the "set debug watchpoint as stack overflow check" out of debugging internals Place it near the other stack overflow kconfig items, instead. --- components/freertos/Kconfig | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index c28287644d..04821cd5fc 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -76,6 +76,24 @@ config FREERTOS_CHECK_STACKOVERFLOW_CANARY (configCHECK_FOR_STACK_OVERFLOW=2) endchoice +config FREERTOS_WATCHPOINT_END_OF_STACK + bool "Set a debug watchpoint as a stack overflow check" + default n + help + FreeRTOS can check if a stack has overflown its bounds by checking either the value of + the stack pointer or by checking the integrity of canary bytes. (See FREERTOS_CHECK_STACKOVERFLOW + for more information.) These checks only happen on a context switch, and the situation that caused + the stack overflow may already be long gone by then. This option will use the debug memory + watchpoint 1 (the second one) to allow breaking into the debugger (or panic'ing) as soon as any + of the last 32 bytes on the stack of a task are overwritten. The side effect is that using gdb, you + effectively only have one watchpoint; the 2nd one is overwritten as soon as a task switch happens. + + This check only triggers if the stack overflow writes within 4 bytes of the end of the stack, rather than + overshooting further, so it is worth combining this approach with one of the other stack overflow check methods. + + When this watchpoint is hit, gdb will stop with a SIGTRAP message. When no OCD is attached, esp-idf + will panic on an unhandled debug exception. + config FREERTOS_THREAD_LOCAL_STORAGE_POINTERS int "Amount of thread local storage pointers" range 0 256 if !WIFI_ENABLED @@ -203,22 +221,6 @@ config FREERTOS_PORTMUX_DEBUG_RECURSIVE portMUX usage. endif #FREERTOS_UNICORE - -config FREERTOS_WATCHPOINT_END_OF_STACK - bool "Set a debug watchpoint at the end of each stack" - default n - help - FreeRTOS can check if a stack has overflown its bounds by checking either the value of - the stack pointer or by checking the integrity of canary bytes. (See FREERTOS_CHECK_STACKOVERFLOW - for more information.) These checks only happen on a context switch, and the situation that caused - the stack overflow may already be long gone by then. This option will use the debug memory - watchpoint 1 (the second one) to allow breaking into the debugger (or panic'ing) as soon as any - of the last 32 bytes on the stack of a task are overwritten. The side effect is that using gdb, you - effectively only have one watchpoint; the 2nd one is overwritten as soon as a task switch happens. - - When this watchpoint is hit, gdb will stop with a SIGTRAP message. When no OCD is attached, esp-idf - will panic on an unhandled debug exception. - endif # FREERTOS_DEBUG_INTERNALS endmenu From d0f8fb9b939a9850763b7c3f90dc21346f567842 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 28 Feb 2017 10:59:23 +1100 Subject: [PATCH 3/3] freertos Kconfig: Thread local storage pointer feature required for WiFi or Ethernet --- components/freertos/Kconfig | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 04821cd5fc..b4bcfc3fe1 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -95,16 +95,19 @@ config FREERTOS_WATCHPOINT_END_OF_STACK will panic on an unhandled debug exception. config FREERTOS_THREAD_LOCAL_STORAGE_POINTERS - int "Amount of thread local storage pointers" - range 0 256 if !WIFI_ENABLED - range 1 256 if WIFI_ENABLED + int "Number of thread local storage pointers" + range 0 256 if !(WIFI_ENABLED || ETHERNET) + range 1 256 if WIFI_ENABLED || ETHERNET default 1 help FreeRTOS has the ability to store per-thread pointers in the task - control block. This controls the amount of pointers available; - 0 turns off this functionality. + control block. This controls the number of pointers available. - If using the WiFi stack, this value must be at least 1. + Value 0 turns off this functionality. + + If using the LWIP TCP/IP stack (with WiFi or Ethernet), this value must be at least 1. See the + LWIP_THREAD_LOCAL_STORAGE_INDEX config item in LWIP configuration to determine which thread-local-storage + pointer is reserved for LWIP. choice FREERTOS_ASSERT prompt "FreeRTOS assertions"