MBEDTLS / STM32CubeMX Broken?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-24 1:02 PM
I am trying to implement an MBEDTLS client based on an ST example. The MBEDTLS code fails when it tries to allocate memory using calloc. Apparently, users have been experiencing this for over a year.
The MBEDTLS code uses dynamic memory allocation (calloc()) which apparently is incompatible with FreeRTOS.
- Is there an easy work around?
- Do I need to write my own memory allocation?
- Am I going to run into problems with LWIP stack?
I am not an experienced embedded programmer. I am willing to try to work around this problem; but, I don't want to keep running into road block after road block. I will soon have to consider moving to another platform.
- Labels:
-
STM32CubeMX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-25 8:55 AM
I found a solution to the memory allocation issue. Although I do not yet have my application working.
In "mbedtls_config.h" uncomment these defines:
MBEDTLS_MEMORY_BUFFER_ALLOC_C
MBEDTLS_PLATFORM_MEMORY
MBEDTLS_PLATFORM_C
And then you must add a statically defined memory buffer for MBEDTLS.
Add these lines to application code (buffer may need to be larger):
unsigned char memory_buf[40000];
mbedtls_memory_buffer_alloc_init( memory_buf, sizeof(memory_buf) );
MBEDTLS does not work with FreeRTOS as is. STM32CubeMX should address these items automatically; probably with a config item for the size of the static bufffer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-25 5:15 PM
>MBEDTLS does not work with FreeRTOS as is. STM32CubeMX should address these items
Each developer's circumstances may differ.
Mbed TLS' memory allocation options are well documented.
It's your code. You choose your allocation strategy. Don' task ST to do it as then you're lumped with having to work with it or around it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-25 9:41 PM
Sorry, but the whole point of CubeMX is to produce WORKING code - otherwise why bother. Your assertion makes no sense, because either way, I can modify the code to match my requirements. Why not start with working code?
