Handshake failed external memory FreeRTOS heap

Hello everyone,

I am encountering a challenging issue with mbedTLS during SSL handshake processes in my project. I hope to gain some insights or solutions from the community’s vast experience.

Project Setup:

  • RTOS: FreeRTOS
  • TLS Library: mbedTLS
  • Hardware: Embedded platform with both internal memory and external HyperRAM.

Problem Description: In my setup, everything functions correctly when the FreeRTOS heap is allocated in the internal memory. Specifically, the mbedTLS library successfully completes the SSL handshake without any issues. However, when I transition the FreeRTOS heap to be hosted in the external HyperRAM, I start experiencing failures during the SSL handshake.

Technical Details:

  • The exact error I encounter when the heap is in HyperRAM is MBEDTLS_ERR_SSL_INTERNAL_ERROR with an error code of -0x6C00.
  • This problem manifests during the mbedtls_ssl_setup, which is responsible for setting up the SSL context based on my configurations.

Steps Taken:

  • I have confirmed that the HyperRAM is stable and functional as other components like ethernet_data operate correctly when hosted on it.
  • My mbedtls_config.h and memory management routines are standard, and the system operates as expected with internal memory.

Request for Assistance: I am looking for insights into what might be causing this issue when switching the heap to HyperRAM. Could this be related to memory alignment, access speed, or perhaps specific configurations within mbedTLS that are sensitive to where the heap is located?

Additional Considerations:

  • Any tips on adjusting mbedTLS settings or FreeRTOS configurations that might cater to external memory usage would be greatly appreciated.
  • If anyone has faced similar challenges or has debugging suggestions that could help isolate this issue, your input would be invaluable.

Thank you for taking the time to read this post. I am looking forward to your suggestions and any assistance you can provide to help resolve this peculiar issue.

Best regards, Emo

I see your comment about other components residing in HyperRAM, but have you tested the entire memory? There are conventions in how to test entire RAMs that do things like, for example, test for an address line being shorted (not a good example in the HyperRAM case probably). Try testing the entire RAM as it is described by your linker script.

If the heap is in HyperRAM, and you are allocated task stacks dynamically using xTaskCreate(), then performance could be an issue.

Have you look at where that error code is coming from in the code, and stepped through that part of the code?

Enabling mbedTLS debug logs may also be helpful in finding it.