I am playing around with RTOS tasks and queues, and have started the JTAG debugger. Certain variables are shown as <unavailable>
within the watch-area. so I investigated the phenomena more closely with a small blink program. It looks like inside the simple C function all variables are shown, even the ones on the stack. That looks completely different in the task function. Variables that end up on the stack are listed as in the watch area.
The C-function: icnt:0
and num:2
are shown as expected.
The Task function: the variable on stack shows up as num_blink:<unavailable>
My dev environment looks like this, I would say from pio point of view, it is quite up to date:
OS Win10 (21H2, build 19044.2130)
VS-Code 1.72.2
PlatformIO IDE 2.5.4
IO core 6.1.5a4
PIO home 3.4.3
platform esp32 5.2.0
ESP32 board = ESP32 NodeMCU (38pins)
JTAG interface = FT2232HL USB
platformio.ini, debug environment
My first thought was that the build_flags und build_unflags should do the trick.
;----------------------------------------------------------------------
; debug environment
;----------------------------------------------------------------------
[env:esp32dev_dbg]
build_type = debug
platform = espressif32
board = esp32dev
framework = arduino
;##### Serial Port Settings #####
monitor_filters = esp32_exception_decoder, time
monitor_speed = 115200
monitor_port = COM4
;##### Upload-Port-Settings #####
upload_speed = 921600
upload_port = COM4
;##### In-Circuit-Debug-Settings #####
debug_tool = esp-prog
debug_init_break = tbreak setup
debug_speed = 8000
;build_flags =
; -DCORE_DEBUG_LEVEL=5
build_unflags = -Os
build_flags = -O1 -g3 -ggdb
the main.cpp file:
a simple C function and a similar task function as LED blinker.
#include <Arduino.h>
#define IR_LED 16 // led indicates received message
xQueueHandle LedQueue;
TaskHandle_t LedTask_h;
void LedBlink(int num, uint32_t pause){
int icnt=0;
for (icnt=0;icnt<num;icnt++) {
digitalWrite(IR_LED, LOW);
delay(pause);
digitalWrite(IR_LED, HIGH);
delay(pause);
}
}
void LedTask(void *parameter){
uint8_t num_blink=0;
uint8_t icnt=0;
while(1){
if(pdTRUE==xQueueReceive(LedQueue,&num_blink,portMAX_DELAY)) {
printf("received num_blink=%d\n",num_blink);
for(icnt=0;icnt<num_blink;icnt++){
digitalWrite(IR_LED,LOW);
delay(50);
digitalWrite(IR_LED,HIGH);
delay(50);
}
}
}
}
void setup() {
Serial.begin(115200);
LedQueue = xQueueCreate(50, sizeof(uint8_t));
printf("LedQueue created\n");
xTaskCreate(LedTask,"LedTask",2048,NULL,1,&LedTask_h);
printf("LedTask created\n");
pinMode(IR_LED,OUTPUT);
LedBlink(2,50); // double blink at start
}
uint8_t blinky=0;
void loop() {
blinky = (++blinky>5)? 1 : blinky;
xQueueSend(LedQueue,&blinky,0);
delay(2000);
}
I wonder what the cause is. Maybe there exists a special gcc switch or another setting of the debugger or the IDE ?
Any Ideas?