Skip to content
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

Adds support to change LoopTask Stack size #6025

Merged
merged 5 commits into from
Dec 20, 2021

Conversation

SuGlider
Copy link
Collaborator

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:

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

#6010 (comment)
Thanks @igrr for the suggestion!

@SuGlider SuGlider self-assigned this Dec 15, 2021
cores/esp32/Arduino.h Outdated Show resolved Hide resolved
@me-no-dev
Copy link
Member

@SuGlider let's add one example that shows the usage :)

@igrr
Copy link
Member

igrr commented Dec 15, 2021

+1 regarding adding an example. I think you can call some FreeRTOS function like uxTaskGetStackHighWaterMark(NULL) from setup() to demonstrate that the available stack space is increased when ESP_LOOP_TASK_STACK_SIZE is added. Once we have the test framework up and running, this would also make it easier for us to test that this functionality doesn't get broken — we can run this example in CI and check the a value larger than a certain threshold is printed.

@pedrominatel
Copy link
Member

Add to the docs as well.

@pedrominatel
Copy link
Member

Besides the macro, are we going to add this configuration through the Arduino IDE Tools menu with some predefined options?

@me-no-dev
Copy link
Member

Besides the macro, are we going to add this configuration through the Arduino IDE Tools menu with some predefined options?

Not really. This is niche usage. For all the default should be plenty.

@SuGlider
Copy link
Collaborator Author

SuGlider commented Dec 15, 2021

+1 regarding adding an example. I think you can call some FreeRTOS function like uxTaskGetStackHighWaterMark(NULL) from setup() to demonstrate that the available stack space is increased when ESP_LOOP_TASK_STACK_SIZE is added. Once we have the test framework up and running, this would also make it easier for us to test that this functionality doesn't get broken — we can run this example in CI and check the a value larger than a certain threshold is printed.

Done. Example commited.
@pedrominatel - in the example, I added some commentaries explaining it. Maybe it can be used for documentation.

@me-no-dev me-no-dev merged commit 82ec74a into espressif:master Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Core 1 panic'ed (Unhandled debug exception)
4 participants