Hello, good morning everyone,
I was developing my program in Arduino and when running my program I got the following errors:
Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (loopTask)
After a search on the internet, most users agreed on the problem of the stack and the increase of its size, so I added the command: SET_LOOP_TASK_STACK_SIZE( 16*1024 );
This was done by researching here:
#6025
/*
ESP32 Arduino creates a task to run setup() and then to execute loop() continuously
This task can be found at https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp
By default "loopTask" will be created with a stack size of 8KB.
This should be plenty for most general sketches.
There is a way to change the stack size of this task by using
SET_LOOP_TASK_STACK_SIZE(size);
It will bypass the default stack size of 8KB and allow the user to define a new size.
It is recommend this value to be higher than 8KB, for instance 16KB.
This increasing may be necessary for the sketches that use deep recursion for instance.
In this example, you can verify it by changing or just commenting out SET_LOOP_TASK_STACK_SIZE();
*/
// This sets Arduino Stack Size - comment this line to use default 8K stack size
SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB
This file has been truncated. show original
espressif:master
← SuGlider:ArduinoStack
opened 05:09AM - 15 Dec 21 UTC
## Summary
Arduino ```setup()``` and ```loop()``` run under a Task with a fixed… Stack size of 8KB.
Users may want to change this size.
This PR adds this possibility by just adding a line of code, as for example:
``` dart
ESP_LOOP_TASK_STACK_SIZE(16384);
void setup() {
}
void loop() {
}
```
## Impact
None. It adds a new functionality to ESP32 Arduino.
If ```ESP_LOOP_TASK_STACK_SIZE(newSize);``` is not declared/used, it will compile the sketch with the default stack size of 8KB.
## Related links
fix #6010
https://github.com/espressif/arduino-esp32/issues/6010#issuecomment-992701658
Thanks @igrr for the suggestion!
#7824
However when I added the command and compiled, I got this error:
"Compilation error: expected constructor, destructor, or type conversion before '((' token"
I compile with the ESP32 Wrover module support board, and all the ESP32 libraries are added as I saw in various tutorials. I attach the code in case it might help.
If anyone knows why this error occurs and what I should change I would be very grateful.
Thanks and best regards
#include <SPI.h>
#include <LoRa.h>
#include <Arduino.h>
//define the pins used by the transceiver module
#define ssl 5
#define rst 14
#define dio0 2
SET_LOOP_TASK_STACK_SIZE(12*1024);
void setup() {
}
void loop() {
}
robertrojosil:
before '((' token
Please indicate the line where this token is flagged. A full error message were nice.
Perhaps one of the #defines is defective?
robertrojosil:
while (1);
You want to stop your program without feeding the watchdog?
Attached is the complete error
error: expected constructor, destructor, or type conversion before '(' token
SET_LOOP_TASK_STACK_SIZE(12*1024);
^
exit status 1
Compilation error: expected constructor, destructor, or type conversion before '(' token
Is the line where I call SET_LOOP_TASK_STACK_SIZE just before void setup
The program is designed to execute the loop only once, since you want to generate variables only once, not repeatedly.
robertrojosil:
SET_LOOP_TASK_STACK_SIZE
How is that declared?
Such things should go into setup(), not loop(). You only replace the outer loop() loop by an inner while() loop.
I have no knowledge, Imooerate here on pattern matching and I note in case it means anything that
// This sets Arduino Stack Size - comment this line to use default 8K stack size
SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB
is the very very first thing that gets appears in the code in the example.
a7
Try moving that line into setup().
And
DrDiettrich:
[t]ry moving that line
to before the very first # include…
a7
Where will it be defined then?
The same place it gets defined in the example. Somewhere .
It looks like something that is known. The structure of the example is
SET_LOOP…
void setup(){}
void loop(){}
a7
From what I have read from the various sources I have posted, I believe it would be like a function to increase the stack size and would be included in the ESP32 board manager done by Espressif. That board manager is already added and installed.
Yes, from there I have based it, but I have put it before the includes and the same error comes out, if I put it in the setup this error:
error: 'SET_LOOP_TASK_STACK_SIZE' was not declared in this scope.
SET_LOOP_TASK_STACK_SIZE(12*1024);
^
exit status 1
Compilation error: 'SET_LOOP_TASK_STACK_SIZE' was not declared in this scope
I also downloaded the example you mention and I get the same Compilation error I mentioned above: expected constructor, destructor, or type conversion before '(' token
To me that is progress. At least you are looking through someone else's lunch, not your own.
a7
An #include is missing or you don't use the required firmware. MightyCore or FreeRTOS or ...
Where did you find the hint on using SET_LOOP_TASK_STACK_SIZE?
I found the suggestion in these files that I attach below
espressif:master
← SuGlider:ArduinoStack
opened 05:09AM - 15 Dec 21 UTC
## Summary
Arduino ```setup()``` and ```loop()``` run under a Task with a fixed… Stack size of 8KB.
Users may want to change this size.
This PR adds this possibility by just adding a line of code, as for example:
``` dart
ESP_LOOP_TASK_STACK_SIZE(16384);
void setup() {
}
void loop() {
}
```
## Impact
None. It adds a new functionality to ESP32 Arduino.
If ```ESP_LOOP_TASK_STACK_SIZE(newSize);``` is not declared/used, it will compile the sketch with the default stack size of 8KB.
## Related links
fix #6010
https://github.com/espressif/arduino-esp32/issues/6010#issuecomment-992701658
Thanks @igrr for the suggestion!
/*
ESP32 Arduino creates a task to run setup() and then to execute loop() continuously
This task can be found at https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp
By default "loopTask" will be created with a stack size of 8KB.
This should be plenty for most general sketches.
There is a way to change the stack size of this task by using
SET_LOOP_TASK_STACK_SIZE(size);
It will bypass the default stack size of 8KB and allow the user to define a new size.
It is recommend this value to be higher than 8KB, for instance 16KB.
This increasing may be necessary for the sketches that use deep recursion for instance.
In this example, you can verify it by changing or just commenting out SET_LOOP_TASK_STACK_SIZE();
*/
// This sets Arduino Stack Size - comment this line to use default 8K stack size
SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB
This file has been truncated. show original
espressif:master
← SuGlider:ArduinoStack
opened 05:09AM - 15 Dec 21 UTC
## Summary
Arduino ```setup()``` and ```loop()``` run under a Task with a fixed… Stack size of 8KB.
Users may want to change this size.
This PR adds this possibility by just adding a line of code, as for example:
``` dart
ESP_LOOP_TASK_STACK_SIZE(16384);
void setup() {
}
void loop() {
}
```
## Impact
None. It adds a new functionality to ESP32 Arduino.
If ```ESP_LOOP_TASK_STACK_SIZE(newSize);``` is not declared/used, it will compile the sketch with the default stack size of 8KB.
## Related links
fix #6010
https://github.com/espressif/arduino-esp32/issues/6010#issuecomment-992701658
Thanks @igrr for the suggestion!
Also in this thread of this same page it is suggested to use SET_LOOP_TASK_STACK_SIZE
Moinsen Combie / der Rest,
ich hab tatsächlich nochmal ne Frage zu dem Thema.
Was ich verstanden habe:
Ich kann mir die aktuelle "Rest"-Stacksize des Loop-Tasks folgendermaßen ausgeben:
Serial.printf("Arduino Stack was set to %d bytes", getArduinoLoopTaskStackSize());
Und ich kann die Stackksize (falls das erforderlich wäre, warum auch immer) folgendermaßen hochschrauben (z.B. auf 16 KB):
SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB
Nun frage ich mich immer noch, wie ich ermitteln kann, wa…
I'd look into the source code of that task.
did you try the example sketch??
ESP32 Change Stack Size..
good luck.. ~q
The example does not work, at least with my version of arduino and my ESP32 board.
I've already done some research on that but without much success, I'll try to check it out again and see. Thank you very much
The example in the Arduino IDE works as expected.
In my case I do not see this stack issue. I have Arduino IDE 2.1.0 and ESP32 version 2.0.9.