"Malloc failure" using FreeRTOS heap3.c with LPCXpresso tool chain

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

"Malloc failure" using FreeRTOS heap3.c with LPCXpresso tool chain

2,359 次查看
lpcware-support
Senior Contributor I
Quote:                                                                                                                                                                      WARNING: This FAQ is obsolete, the new version LPCXpesso tool will have this problem fixed

FreeRTOS (heap3.c) uses the malloc and free provided by the tool to allocate dynamic objects. LPCOpen, when compiled using LPCXpresso, gets the malloc and free functions from redlib, default heap check function can be found here. The default heap check function will return 1 (heap is full) because the stack for the current process is allocated in the heap. Override the default __check_heap_overflow function with the one given below, by copying the code to the application source or by creating a new source file with the below contents and adding it to the project.

#if defined (__REDLIB__)  

#ifndef STACK_SIZE 
#define STACK_SIZE  (0x400) 
#endif  

/* Top of stack that comes from linker script */ 
extern void _vStackTop(void);  

/* 
 * Heap check function override, fixes heap3.c malloc failures 
 */ 
extern unsigned int *_pvHeapStart; 
unsigned int __check_heap_overflow (void * new_end_of_heap)
{ 
         unsigned long stackend = ((unsigned long) &_vStackTop) - STACK_SIZE; 
         return ((unsigned long)new_end_of_heap >= stackend); 
} 
#endif /* defined (__REDLIB__) */ 

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