cancel
Showing results for 
Search instead for 
Did you mean: 

MQTT with TLS using STM32f767

cleonb322
Associate III

I am using an STM32F767 with MQTT, and everything works without using TLS. But when I try to enable TLS, it fails to connect to the server because of a memory issue (calloc fails). I read other message boards that state that I need up to 60K of RAM to use TLS (this seems excessive). What are the correction options for configuring stm32F767 when using TLS? Thank you in advance.

steps:

1. this works.

mqtt_client_info.tls_config = altcp_tls_create_config_client((const uint8_t *)tls_root_ca_cert , strlen(tls_root_ca_cert) + 1);

2. this fails with -1, failed malloc

 err = mqtt_client_connect(mqtt_client, &pServerSetting->ip_pri, pServerSetting->priServerPort, mqtt_connection_cb, LWIP_CONST_CAST(void*, &mqtt_client_info), &mqtt_client_info);

 

Other info. 

SRAM2 is used for ethernet buffer which is 16K. 

I have an external SDRAM (FMC interface) currently being used for a display buffer with plenty of space available is it possible to configure it to use as the buffer?

in lwipopts.h

#define LWIP_RAM_HEAP_POINTER (0x20078000)

in main.c mpu is configured correctly

 
/** Initializes and configures the Region and the memory to be protected

*/

MPU_InitStruct.Number = MPU_REGION_NUMBER3;

MPU_InitStruct.BaseAddress = 0x20078000;

MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;

MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;

MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;

MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;



HAL_MPU_ConfigRegion(&MPU_InitStruct);



/** Initializes and configures the Region and the memory to be protected

*/

MPU_InitStruct.Number = MPU_REGION_NUMBER4;

MPU_InitStruct.BaseAddress = 0x2007C000;

MPU_InitStruct.Size = MPU_REGION_SIZE_1KB;

MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;

MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;



HAL_MPU_ConfigRegion(&MPU_InitStruct);

 

1 REPLY 1
STea
ST Employee

Hello @cleonb322 ,

Regarding "I have an external SDRAM (FMC interface) currently being used for a display buffer with plenty of space available is it possible to configure it to use as the buffer?"

if you meant using the SDRAM via FMC interface for DMA buffers and descriptors yes this could be done 

STea_0-1730902716192.png

Regards



In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.