Two heaps, MCUXPresso IDE 11.5.0

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

Two heaps, MCUXPresso IDE 11.5.0

1,884 次查看
a8Chcx
Contributor V

Hi,

I am using the sample project "frdmk66f_lwip_httpsrv_mbedTLS_httpsrv" to build my application.

It works fine. In my application, there is other task that is using lot of memory from heap. So, when they are together, it stop working after certain time...

It is possible to set up two heaps in different memory section because I have SDRAM, one for http server, other is for other task?

Thanks,

Christie

0 项奖励
回复
6 回复数

1,875 次查看
ErichStyger
Specialist I
0 项奖励
回复

1,872 次查看
a8Chcx
Contributor V

HI Erich,

Thank you. And I have the following questions:

1) I am using heap_3.c for now. I have to get heap_5.c. What is the major difference between hap_3 and heap_5? will it cause any problem on existing project? Where can I get heap_5.c?

2) I want to use the different heap for the different task. Can you tell me if it is possible and how to do it?

Thanks,

Christie

0 项奖励
回复

1,868 次查看
ErichStyger
Specialist I

Hi Christie,

1) see https://www.freertos.org/a00111.html. Heap_3 is basically a wrapper around malloc()/free() with thread safety. But I would not recommend using Heap_3 if you are using malloc()/free() from your application in other places. Use Heap_6 for this, see https://mcuoneclipse.com/2017/07/02/using-freertos-with-newlib-and-newlib-nano/ 
Heap_4 is usually what I would recommend, and Heap_5 is simply the same but with multiple regions.

2) No, you cannot use different heaps for different tasks. I would suggest that you consider using static memory for tasks instead which has been introduced with FreeRTOS v9.0.0, see https://mcuoneclipse.com/2016/05/29/freertos-v9-0-0-with-static-memory-allocation/

I hope this helps,

Erich

0 项奖励
回复

1,865 次查看
a8Chcx
Contributor V

Hi Erich,

I am using IDE 11.5.0. What is RTOS version included? 

Where can I select memory allocation? It has to use heap_6.c?

Thanks,

Christie

0 项奖励
回复

1,854 次查看
ErichStyger
Specialist I

NXP had that heap_6 as part of their SDK FreeRTOS, but somehow it is not present any more in the latest SDK (not sure why).

Anyway, I'm using the FreeRTOS from the McuLib (https://github.com/ErichStyger/McuOnEclipseLibrary), see https://github.com/ErichStyger/McuOnEclipseLibrary/tree/master/lib/FreeRTOS/Source/portable/MemMang where you can find heap_useNewlib.c.

You can copy it from there, or use that FreeRTOS port (this is what I do).

I hope this helps,

Erich

0 项奖励
回复

1,836 次查看
a8Chcx
Contributor V

Hi Erich,

I am trying to change to heap_4.c for "frdmk66f_lwip_httpsrv_mbedTLS" sample project(Use heap_3.c) and it stop working.

Can you help me to see why it cannot switch to heap_4.c?

Thanks,

Christie

0 项奖励
回复