mbedtls FreeRTOS LPC54018 error no memory

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

mbedtls FreeRTOS LPC54018 error no memory

1,157 次查看
kiryat8
Contributor III

I have a working LPC54018 FreeRTOS project with AES256 encryption and an ECDL handshake. I have another non NXP board that works in the same way with mbedtls but not with FreeRTOS. I was using on the LPC54018 other code, instead of the mbedtls library but it did use IV initialization.  The mbedtls key functions are returning -16 which looks like MBEDTLS_ERR_MPI_ALLOC_FAILED. I am using RTOS configFRTOS_MEMORY_SCHEME 4 and have increased drastically the heap (configTOTAL_HEAP_SIZE ((size_t)(1024*100))) but nothing helps. I used MBEDTLS_CONFIG_FILE="ksdk_mbedtls_config.h" and also tried from a SDK example MBEDTLS_CONFIG_FILE='"azure_mbedtls_config.h"'. Is there some configuration parameter to lower memory usage or it may not be memory usage at all.

I first initialize mbedtls by calling the attached init_mbedtls() function and in my testing, I call my setupEcdhPeer() function to setup the keys I use. When calling mbedtls_ecdh_gen_public(), it returns -16 which looks like MBEDTLS_ERR_MPI_ALLOC_FAILED.

It maybe that I can remark mbedtls functionality that I do not need. I need AES256 SHA256 and the ECDL stuff.

Any help would be appreciated.

标签 (1)
标记 (1)
0 项奖励
回复
2 回复数

1,097 次查看
kiryat8
Contributor III

I changed to RTOS configFRTOS_MEMORY_SCHEME 3 and changed the linker script to allocate more heap memory and I do not get the out of memory error but generating keys takes 25s!

I only have a couple of tasks and even increased the task's priority.

I tried playing around with the mbedtls defines but nothing seems to help.

GenKeys 206685321 cycles 25005ms

#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 // ?!? 0 /* To reduce peak memory usage */
#define MBEDTLS_ECP_WINDOW_SIZE 4   // ?!? was 2
#define MBEDTLS_ECP_MAX_BITS    256 // ?!? 384 /* Maximum bit size of groups */

#define MBEDTLS_AES_ALT         1
#define MBEDTLS_AES_ROM_TABLES  1

#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024 // ?!? was (1024 * 10) /* Reduce SSL frame buffer. */
#define MBEDTLS_MPI_WINDOW_SIZE 4   // ?!? was 1
#define MBEDTLS_MPI_MAX_SIZE    32  // ?!? was 512 /* Maximum number of bytes for usable MPIs. */

Where is my problem now?

Thanks

0 项奖励
回复

1,097 次查看
FelipeGarcia
NXP Employee
NXP Employee

Hello David,

 

In our SDK package we have some mbedtls examples. Have you tried to use these examples? Do you experience same issue? Please also provide detailed steps to reproduce this issue on my side.

 

Best regards,

Felipe

0 项奖励
回复