bss太大了,有60多M,客户要求处理一下
readelf -s app.elf | grep "OBJECT"
发现有一条
592: 8800dd78 0x4000000 OBJECT LOCAL DEFAULT 15 ucHeap
长度64M,地址8800dd78刚好在bss段里,bss段地址如下:
readelf -S app.elf
[15] .bss NOBITS 8800aee0 0bc218 4890eac 00 WA 0 0 4
于是需要把ucHeap单独放到一段
ucHeap是freeRTOS里内存分配里的一个静态变量,freeRTOS的堆分配都是在这个ucHeap上
/* Allocate the memory for the heap. */
#if ( configAPPLICATION_ALLOCATED_HEAP == 1 )
/* The application writer has already defined the array used for the RTOS
* heap - probably so it can be placed in a special segment or address. */
extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#else
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#endif /* configAPPLICATION_ALLOCATED_HEAP */
修改方式如下
a、FreeRTOSConfig.h里定义
#define configAPPLICATION_ALLOCATED_HEAP 1
b、增加一个ucHeaps段0x06000000==100,663,296,100M,应该够了,调整一下段地址
ucHeaps 0x84000000 0x06000000
c、程序里定义一个
uint8_t ucHeap[ configTOTAL_HEAP_SIZE ] __attribute__((section(".ucHeap"))) __attribute__((aligned(4096)));
重新编译一个app.elf就行了