ESP32 Main Task Size
ESP32 Main Task Size
In my main function if I start 4 tasks of 2048 heap size each. Does my main task size need to be 4 * 2048?
Re: ESP32 Main Task Size
Howdy ... no sir.
Each task you create has its own stack size that YOU explicitly specify when you create a task. If you look at the API you are using to create a task, you will find that the stack size for THAT task that you are are creating is a parameter on the API. Since there are some tasks within ESP-IDF that are created outside of your control (i.e. the main task that gets the story running in the first place), it is the stack size for those ESP-IDF tasks that are specified in the make menuconfig.
Each task you create has its own stack size that YOU explicitly specify when you create a task. If you look at the API you are using to create a task, you will find that the stack size for THAT task that you are are creating is a parameter on the API. Since there are some tasks within ESP-IDF that are created outside of your control (i.e. the main task that gets the story running in the first place), it is the stack size for those ESP-IDF tasks that are specified in the make menuconfig.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: ESP32 Main Task Size
Edit: As per ESP_igrr's post below, the FreeRTOS documentation doesn't correspond the the IDF-version of FreeRTOS. Please refer to ESP_igrr's post for correct info.
Also worth noting is that the number you specify isn't the size in the traditional sense. It is, as is clearly documented here (see usStackDepth), the depth of the stack.
In the case if the ESP32, the word size is four (32 bits, 4 bytes)
Also worth noting is that the number you specify isn't the size in the traditional sense. It is, as is clearly documented here (see usStackDepth), the depth of the stack.
The number of words (not bytes!) to allocate for use as the task's stack. For example, if the stack is 16-bits wide and usStackDepth is 100, then 200 bytes will be allocated for use as the task's stack. As another example, if the stack is 32-bits wide and usStackDepth is 400 then 1600 bytes will be allocated for use as the task's stack.
The stack depth multiplied by the stack width must not exceed the maximum value that can be contained in a variable of type size_t.
In the case if the ESP32, the word size is four (32 bits, 4 bytes)
Last edited by permal on Thu Aug 17, 2017 6:46 pm, edited 1 time in total.
Re: ESP32 Main Task Size
Actually, stack size is given in units StackType_t (even though FreeRTOS documentation says that it is given in words).
In the original xtensa port StackType_t was defined as uint8_t. This was preserved in ESP-IDF version of FreeRTOS as well:
https://github.com/espressif/esp-idf/bl ... .h#L50-L52
https://github.com/espressif/esp-idf/bl ... #L104-L108
In the original xtensa port StackType_t was defined as uint8_t. This was preserved in ESP-IDF version of FreeRTOS as well:
https://github.com/espressif/esp-idf/bl ... .h#L50-L52
https://github.com/espressif/esp-idf/bl ... #L104-L108
Re: ESP32 Main Task Size
Oh, wow. That's a factor of four from what the manual says!
What other IDF-specific quirks are there that are not corresponding to the official documentation? Is there a list of such things? These kind of differences are rather valuable/important to know.
What other IDF-specific quirks are there that are not corresponding to the official documentation? Is there a list of such things? These kind of differences are rather valuable/important to know.
Re: ESP32 Main Task Size
Thanx A lot everyone. This helps !!
-
- Posts: 132
- Joined: Tue Aug 14, 2018 6:21 am
- Location: India
Re: ESP32 Main Task Size
How can we determine the main task stack size?kolban wrote: ↑Thu Aug 17, 2017 1:34 pmHowdy ... no sir.
Each task you create has its own stack size that YOU explicitly specify when you create a task. If you look at the API you are using to create a task, you will find that the stack size for THAT task that you are are creating is a parameter on the API. Since there are some tasks within ESP-IDF that are created outside of your control (i.e. the main task that gets the story running in the first place), it is the stack size for those ESP-IDF tasks that are specified in the make menuconfig.
it is 3584 default.
--
Somesh Burkule
Somesh Burkule
Who is online
Users browsing this forum: No registered users and 140 guests