espressif / esp-rainmaker

ESP RainMaker Agent for firmware development
Apache License 2.0
453 stars 152 forks source link

SSL/TLS Handshake error on esp32-wrover-e kit with rainmaker matter controller example (MEGH-5732) #319

Open Shivi-6 opened 3 months ago

Shivi-6 commented 3 months ago

Answers checklist.

General issue report

I was trying to create a matter controller out of my esp32-wrover-e kit with 4mb flash. First of all. the partition was 2mb each which was insufficient for a binary of 2.1mb so I crreated a single partition of 3.5 mb instead of two ota partitions. After this, the build was successful and I was able to flash the binary to my board. I was also able to generate the QR code for commissioning. While monitoring using the "idf.py monitor" and trying to connect the controller with rainamaker app, I am getting mbedtls handshake issue. Please find the logs attached and let me know what could be the solution. idf_py_stdout_output.pdf

Shivi-6 commented 3 months ago

idf_py_stdout_output.pdf This is the log when the controller got connected to the google home app but after the message "Device connected" appeared and I clicked the "Done" option, it showed "something went wrong" and the device did not connect. In this case, the error "ERROR A stack overflow in task Tmr Svc has been detected." appears. I am a bit new to this so I don't know exactly where the issue lies. Please help me.

vikramdattu commented 3 months ago

Hi @Shivi-6 this looks like a memory issue.
ESP32 Wrover Kit has external RAM. Could you please enable it via menuconfig, and check if it solves the issue?

Shivi-6 commented 3 months ago

I tried enabling the option in menuconfig but the build failed. With the help of "https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/performance/ram-usage.html#optimizing-iram-usage" this document, I changed some configurations and the build succeeded. But now there's a different error while monitoring. Attaching the log : idf_py_stdout_output_new.pdf

vikramdattu commented 3 months ago

Can you share more details? Where exactly the crash is happening? You may want to enable Invoke GDB Stub on Panic option and check the backtrace.
Do you have any changes of your own which would lead to the crash?

Shivi-6 commented 3 months ago

No I do not have any changes of my own. I was just simply flashing the matter_controller example in rainmaker sdk to my esp32 board. The only change I have done is in the partition table because the 2 partitions (each of 2 MB) were not sufficient for the binary (2.1 MB) so I created a single one. partitions.csv

Can you please guide me about the steps that I need to take to crrectly work with the controller example.

Shivi-6 commented 3 months ago

Steps for configuration.pdf These are the steps I tried for flashing the controller example in ESP32

vikramdattu commented 3 months ago

Hi @Shivi-6 please increase FreeRTOS Timer task stack size by 2K and let me know if the problem persists. You can do this via menuconfig.

idf.py menuconfig > Component config > FreeRTOS > Kernel > configTIMER_TASK_STACK_DEPTH Do set this number to 4K.

Shivi-6 commented 2 months ago

configTIMER_TASK_STACK_DEPTH was already configured to 8192. I still tried with 4K and in both the cases, the error is still there. @vikramdattu can you please confirm if the steps mentioned in https://github.com/espressif/esp-rainmaker/issues/319#issuecomment-2212956583 are correct. I just want to make sure if I am going in the right direction

Shivi-6 commented 2 months ago

Update : @vikramdattu I changed the board and now using an ESP32 with 16 MB flash but the ssl/tls error is still there.. Please let me know what can be done

vikramdattu commented 2 months ago

Hi @Shivi-6 the issue has nothing to do with the flash. Can you try very large CONFIG_TIMER_TASK_STACK_DEPTH? 16KB maybe? The issue is clearly, the stack is not sufficient. Do you have some custom code added in the callback which might be causing the issue?

Shivi-6 commented 2 months ago

Hi @vikramdattu , after changing the hardware, the stack overflow error is not there, but I am still getting errors related to MQTT saying "Failed to Initialise MQTT". How can I solve this issue? Or can I disable MQTT and connect locally?