发现CubeMX生成的syscall.c文件中没有_sbrk. 找到实现如下
caddr_t _sbrk(int incr)
{
extern char end; /* Defined by the linker */
static char *heap_end;
char *prev_heap_end;
if (heap_end == 0)
{
heap_end = &end;
/* give 16KB area for stacks and use the rest of memory for heap*/
heap_end += 0x4000;
}
prev_heap_end = heap_end;
heap_end += incr;
return (caddr_t) prev_heap_end;
}
添加到syscall.c, 问题即可解决.