mbed 区域 m_data_2 溢出堆栈和堆

mbed Region m_data_2 overflowed with stack and heap

我正在为 Mbed OS 编写一个应用程序,它将 运行 在 K64F 板上。我有不同的线程 运行ning,使用系统的 RTOS 功能。

我需要处理一个相对较大的字符串,以便以 JSON 格式显示结果。我已将其定义为 char 数组。最初它被定义为 256 个字符长并且工作正确,但是当我将大小增加到 2048 以实际满足应用程序的需要时

char rData[2048];

我在编译时遇到这个错误:

c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: ./BUILD/K64F/GCC_ARM/02_device.elf section `.heap' will not fit in region `m_data_2'
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: Region m_data_2 overflowed with stack and heap
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: region `m_data_2' overflowed by 22944 bytes
collect2.exe: error: ld returned 1 exit status
[ERROR] c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: ./BUILD/K64F/GCC_ARM/02_device.elf section `.heap' will not fit in region `m_data_2'
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: Region m_data_2 overflowed with stack and heap
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: region `m_data_2' overflowed by 22944 bytes
collect2.exe: error: ld returned 1 exit status

我没有找到任何关于如何增加为此需求保留的 space 的参考资料。

我错过了什么?

在堆上声明变量,而不是在栈上:

char* rData = (char*)malloc(2048);
// potentially, don't always malloc 2048 bytes, but only the amount you need

完成后别忘了打电话给 free(rData)