FreeRTOS: bumping into vApplicationMallocFailedHook() ?

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

FreeRTOS: bumping into vApplicationMallocFailedHook() ?

跳至解决方案
8,168 次查看
victorleite
Contributor I

Hi,

I've followed all the steps on [Tutorial: IAR + FreeRTOS + Freedom Board | MCU on Eclipse] to setup FreeRTOS on FRDM-KL25Z. Processor Expert Driver Suite was used to generate the code. Everything was going perfect (no warnings, no errors, task running ok) until I try to create my second task:

int main(void)

{

PE_low_level_init();

FRTOS1_xTaskCreate(ToggleRedLed, (signed portCHAR *)"Task1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);

FRTOS1_xTaskCreate(ToggleGreenLed, (signed portCHAR *)"Task2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);

#ifdef PEX_RTOS_START

   PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

#endif

for(;;){}

/* END main */

Now I'm in trouble. From debugging I've noticed the execution reaches PEX_RTOS_START(); and then goes to FRTOS1_vApplicationMallocFailedHook(void)

If anyone knows what is happening with this simple code or maybe know where do I need to start investigating, help please!

标签 (1)
标记 (3)
0 项奖励
1 解答
4,698 次查看
BlackNight
NXP Employee
NXP Employee

Hi Victor

You need to increase the heap size to a higher value in the FreeRTOS component:

pastedImage_0.png

So you know why this happens:

Each of your task is using space in the heap.

pastedImage_1.png

This is the value you are using in your call to create the task (configMINIMAL_STACK_SIZE).

This size is in 'stack addressable memory uints', so 4 bytes for each. So if you have a minimal stack size of 200, this means 800 bytes per task (plus some bytes for the header information, etc). Additionally to the two task you create, there is as well the IDLE task created at scheduler start. So if you have 2 KByte of heap size, this will get you that out of heap error.

Erich

在原帖中查看解决方案

0 项奖励
3 回复数
4,699 次查看
BlackNight
NXP Employee
NXP Employee

Hi Victor

You need to increase the heap size to a higher value in the FreeRTOS component:

pastedImage_0.png

So you know why this happens:

Each of your task is using space in the heap.

pastedImage_1.png

This is the value you are using in your call to create the task (configMINIMAL_STACK_SIZE).

This size is in 'stack addressable memory uints', so 4 bytes for each. So if you have a minimal stack size of 200, this means 800 bytes per task (plus some bytes for the header information, etc). Additionally to the two task you create, there is as well the IDLE task created at scheduler start. So if you have 2 KByte of heap size, this will get you that out of heap error.

Erich

0 项奖励
4,698 次查看
victorleite
Contributor I

Thanks guys! That was exactly my problem!

Erich, you're awesome! Thank you for this simple and powerful explanation!

0 项奖励
4,698 次查看
FreeRTOS_org
Contributor IV

I'm not familiar with the Processor Expert component but would guess you just need to allocate a larger heap.  Maybe you can do that through the PE component, but if not see the memory management pages on the FreeRTOS.org website.