-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ArduinoStackCrash #7824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
platformio.ini:
|
This macro will change a weak link to a function that returns the size of the stack used when starting the Arduino Task. Try runing your example with different values in the Arduino Core source code references: |
@SuGlider Yes, I saw the #define in https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/ArduinoStackSize/ArduinoStackSize.ino. I tried it and it works. It's clever. My example is not about the Arduino loop. Perhaps the Arduino folder is not the right place for it. I was thinking Arduino because xTaskCreate() is the Arduino way of handling threads. The example is about understanding how a Task's "stack space" is used. It specifically starts a separate task with 2048 [bytes? (documentation says words)] of stack space, then intentionally causes a crash using recursive function calls. Originally I was calling the functions from loop(), but I wanted to see how it behaved within a user defined task. I find it interesting that every function call appears to consume 64 bytes of stack space. Given that, a stack space of 2048 should allow a max function call depth of 32. |
I see, thank for explaining. Is it just an experiment? |
Correct. Not an issue. It would be helpful for fellow developers to have an example that demonstrates how a Stack Task is used. I spent about 6 hours figuring that out by writing test code. |
OK. You may also open a discussion and/or write here your findings. |
This is helpful: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#task-api.
|
I've decided adding example code for this is overkill, so closing this issue. |
For those who arrive here and wish to avoid playing around with where to call the SET_LOOP_TASK_STACK_SIZE, it should be called as follows:
|
Related area
FreeRTOS
Hardware specification
NA
Is your feature request related to a problem?
I didn't understand what a task's stack size did or how uxTaskGetStackHighWaterMark(NULL) worked.
Describe the solution you'd like
I propose added a new example to https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/ArduinoStackSize called "ArduinoStackCrash.ino", or making a separate folder for it.
I have a working example in VSCode+PIO. Happy to submit a PR, but I need some help because I don't use Arduino IDE.
Describe alternatives you've considered
No response
Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
The text was updated successfully, but these errors were encountered: