From a40af493a57fa99e9383290dabdcc10e1fa9a309 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 11 Aug 2026 17:07:23 +0700 Subject: sysview: FreeRTOS trace hooks, stack high-water and heap tracking hw/bsp/sysview_freertos_hooks.h maps the FreeRTOS trace macros onto SystemView task records (task names, switches, ready/blocked) and adds heap tracking; the FreeRTOSConfig.h of the families used on the rig include it when SYSVIEW is on. The FreeRTOS examples grow their USB task stacks when CFG_TU*_SYSVIEW is enabled, the same way they already do for CFG_TUSB_DEBUG -- the instrumentation's stack cost is real (measured overflows on lpc55 before the bump). --- examples/device/audio_4_channel_mic_freertos/src/main.c | 4 ++-- examples/device/audio_test_freertos/src/main.c | 4 ++-- examples/device/cdc_msc_freertos/src/main.c | 6 +++--- examples/device/hid_composite_freertos/src/main.c | 6 +++--- examples/device/midi_test_freertos/src/main.c | 6 +++--- examples/device/msc_dual_lun/src/main.c | 2 +- examples/device/usbtest/src/main.c | 4 ++-- examples/device/video_capture/src/main.c | 4 ++-- examples/device/video_capture_2ch/src/main.c | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) (limited to 'examples/device') diff --git a/examples/device/audio_4_channel_mic_freertos/src/main.c b/examples/device/audio_4_channel_mic_freertos/src/main.c index eac66a4ef..e23ece633 100644 --- a/examples/device/audio_4_channel_mic_freertos/src/main.c +++ b/examples/device/audio_4_channel_mic_freertos/src/main.c @@ -57,8 +57,8 @@ #include "task.h" #include "timers.h" - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (4 * configMINIMAL_STACK_SIZE / 2) * (CFG_TUSB_DEBUG ? 2 : 1) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (4 * configMINIMAL_STACK_SIZE / 2) * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1) #endif #define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE diff --git a/examples/device/audio_test_freertos/src/main.c b/examples/device/audio_test_freertos/src/main.c index cf2fb74d1..41cdaae0e 100644 --- a/examples/device/audio_test_freertos/src/main.c +++ b/examples/device/audio_test_freertos/src/main.c @@ -56,8 +56,8 @@ #include "task.h" #include "timers.h" - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (4 * configMINIMAL_STACK_SIZE / 2) * (CFG_TUSB_DEBUG ? 2 : 1) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (4 * configMINIMAL_STACK_SIZE / 2) * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1) #endif #define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE diff --git a/examples/device/cdc_msc_freertos/src/main.c b/examples/device/cdc_msc_freertos/src/main.c index 4a920c90b..5677f72a7 100644 --- a/examples/device/cdc_msc_freertos/src/main.c +++ b/examples/device/cdc_msc_freertos/src/main.c @@ -33,11 +33,11 @@ #ifdef ESP_PLATFORM #define USBD_STACK_SIZE 4096 #else - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (configMINIMAL_STACK_SIZE * (CFG_TUSB_DEBUG ? 4 : 2)) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (configMINIMAL_STACK_SIZE * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 4 : 2)) #endif -#define CDC_STACK_SIZE (configMINIMAL_STACK_SIZE * (CFG_TUSB_DEBUG ? 3 : 2)) +#define CDC_STACK_SIZE (configMINIMAL_STACK_SIZE * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 3 : 2)) #define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE //--------------------------------------------------------------------+ diff --git a/examples/device/hid_composite_freertos/src/main.c b/examples/device/hid_composite_freertos/src/main.c index 35fdfea9e..00e48983d 100644 --- a/examples/device/hid_composite_freertos/src/main.c +++ b/examples/device/hid_composite_freertos/src/main.c @@ -49,11 +49,11 @@ #include "task.h" #include "timers.h" - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1) #endif -#define HID_STACK_SIZE (configMINIMAL_STACK_SIZE * (CFG_TUSB_DEBUG ? 2 : 1)) +#define HID_STACK_SIZE (configMINIMAL_STACK_SIZE * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1)) //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF PROTYPES diff --git a/examples/device/midi_test_freertos/src/main.c b/examples/device/midi_test_freertos/src/main.c index f5267214e..4fc9eba92 100644 --- a/examples/device/midi_test_freertos/src/main.c +++ b/examples/device/midi_test_freertos/src/main.c @@ -43,12 +43,12 @@ #ifdef ESP_PLATFORM #define USBD_STACK_SIZE 4096 #else - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1) #endif #define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE -#define MIDI_STACK_SIZE (configMINIMAL_STACK_SIZE * (CFG_TUSB_DEBUG ? 2 : 1)) +#define MIDI_STACK_SIZE (configMINIMAL_STACK_SIZE * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1)) // static task #if configSUPPORT_STATIC_ALLOCATION diff --git a/examples/device/msc_dual_lun/src/main.c b/examples/device/msc_dual_lun/src/main.c index 1d764f12c..f13e79c2e 100644 --- a/examples/device/msc_dual_lun/src/main.c +++ b/examples/device/msc_dual_lun/src/main.c @@ -164,7 +164,7 @@ void led_blinking_task(RTOS_PARAM param) { #ifdef ESP_PLATFORM #define USBD_STACK_SIZE 4096 #else -#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2 * (CFG_TUSB_DEBUG ? 2 : 1)) +#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2 * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1)) #endif #define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE diff --git a/examples/device/usbtest/src/main.c b/examples/device/usbtest/src/main.c index e57a90161..eff564e7f 100644 --- a/examples/device/usbtest/src/main.c +++ b/examples/device/usbtest/src/main.c @@ -289,8 +289,8 @@ void led_blinking_task(void* param) { main(); } #else - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1) #endif // static task allocation diff --git a/examples/device/video_capture/src/main.c b/examples/device/video_capture/src/main.c index d366a17e8..f22ccdae8 100644 --- a/examples/device/video_capture/src/main.c +++ b/examples/device/video_capture/src/main.c @@ -342,8 +342,8 @@ void led_blinking_task(void* param) { main(); } #else - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1) #endif // static task diff --git a/examples/device/video_capture_2ch/src/main.c b/examples/device/video_capture_2ch/src/main.c index fb45038c8..bb8c25b93 100644 --- a/examples/device/video_capture_2ch/src/main.c +++ b/examples/device/video_capture_2ch/src/main.c @@ -304,8 +304,8 @@ void led_blinking_task(void* param) { main(); } #else - // Increase stack size when debug log is enabled - #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1) + // Increase stack size when debug log or SYSVIEW instrumentation is enabled + #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * ((CFG_TUSB_DEBUG || CFG_TUD_SYSVIEW) ? 2 : 1) #endif // static task -- cgit v1.3.1