joelguittet / mender-esp32-example

Mender MCU example running on ESP32 using ESP-IDF platform
Apache License 2.0
15 stars 7 forks source link

Stack overflow in task mender #5

Closed oiketiwhunter23 closed 1 year ago

oiketiwhunter23 commented 1 year ago

Hi there,

I just tried to go through your intructions for connecting a ESP32 module with mender, unfortunately there are some errors displayed when flashing the device, i added a screenshot of the Error message in the terminal down below. (stack overflow) Afterwards it starts rebooting multiple times with the same result.

I also tried to flash on another device but the error is still there, the main device I am using is an ESP32-WROOM-32, so I guess there should be no poblem about flash sizes or stuff like that. Do you have any advices how to fix this error?

Thanks in advance for any kind of help.

with best regards Sam

Errorpicture

joelguittet commented 1 year ago

Hello @oiketiwhunter23

Can you join your sdkconfig file please ? Can you indicate which commit of this repository you are using ? Have you modified the demo app or just build and flashed ? Which environment are you using ? vscode with esp-idf extension ?

Thanks for the details, Joel

oiketiwhunter23 commented 1 year ago

Hi @joelguittet ,

the sdconfig file is attached, I compared the default version with the auto generated one (with added Token, SSID and so on) and there are no differences except of the ones for the configuration with mender, ...

The commit I am using should be the current one (9ba4ed1cb3f9fb3c887f966075b1cd2730eabd74) I didnt change anything about the demo version, just build an flashed and yes, with the same environment that you just asked (vscode with esp-idf extension)

Do you need any other information?

Thanks in advance

Best regards

sdkconfig.txt

joelguittet commented 1 year ago

Hello @oiketiwhunter23

Thanks for the details. I will double check and inform you. I have previously decreased a bit the size of the mender task stack. Maybe too much. You can increase MENDER_RTOS_WORK_QUEUE_STACK_SIZE in the esp-idf mender-rtos.c file if you want to unblock you and continue working. Probably 20kB is enough (12kB actually). Tell me if this help too.

Joel

oiketiwhunter23 commented 1 year ago

Hi @joelguittet, now it worked and i could connect the esp32 with mender, thanks!

joelguittet commented 1 year ago

Thanks, I will investigate more. One more question please: what is the ESP-IDF version you are using ?

oiketiwhunter23 commented 1 year ago

Hi @joelguittet ,

sorry for late response, I was trying to analyze and to understand the whole process at all.

The ESP-IDF is 1.6.2

with best regards

joelguittet commented 1 year ago

Hello @oiketiwhunter23

No problem. 1.6.2 is the latest ESP-IDF vscode extension. I would like the version of ESP-IDF framework you are using itself. It's from https://github.com/espressif/esp-idf and probably v4.x or v5.x. You should have selected this during the installation of ESP-IDF extension in vscode, or you can retrieve it from your esp-idf installation.

Sorry to annoy you with these details, it's important because I suspect the issue is related to the generation of the keys with mbedtls. ESP-IDF v4 uses mbedtls v2 and ESP-IDF v5 uses mbedtls v3 so it's major change.

Thanks,

joelguittet commented 1 year ago

Answering myself, issue reproduced with esp-idf v5.0.2 (not visible with v4.4). The issue is visible while re-generating authentication keys with mbedtls (which is changing between the two releases moving to mbedtls v3).

Using FreeRTOS traces to check Stack High Water Mark informs:

The current mender stack size is 12kB so it's normal to see a stack overflow.

Default stack size of the mender task will be increased to 20kB. If user would like to optimize the mender stack size, this is generally possible but optimization should be done to the config probably. Or not using mbedtls (roadmap: secure element solution as an alternative).

joelguittet commented 1 year ago

Issue is solved with #7