2020-06-24 01: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.
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.
2020-06-25 08: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.
2020-06-25 05: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.
2020-06-25 09: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?