【发布时间】:2021-01-19 23:44:26
【问题描述】:
我正在尝试使用我的 cortex-m4 (STM32F407) 的核心耦合内存 (CCMRAM)。它适用于 Keil MDK-ARM,但 gcc-arm-none-eabi 会忽略 __attribute__((section("CCMRAM")))。
#define configTOTAL_HEAP_SIZE 1000*1024
#define region1_HEAP_SIZE (40*1024)
#define region2_HEAP_SIZE (configTOTAL_HEAP_SIZE - region1_HEAP_SIZE)
static uint8_t ucHeap1[ region1_HEAP_SIZE ] __attribute__((section("CCMRAM")));
static uint8_t ucHeap2[ region2_HEAP_SIZE ];
const HeapRegion_t xHeapRegions[] =
{
{ ucHeap1, sizeof(ucHeap1) },
{ ucHeap2, sizeof(ucHeap2) },
{ NULL, 0 } /* Terminates the array. */
};
根据手册我也尝试初始化ucHeap1
static uint8_t ucHeap1[ region1_HEAP_SIZE ] __attribute__((section("CCMRAM"))) = {0};
但是没有效果。
地图文件不包含任何关于ucHeap1 的内容。 GCC 编译时没有关于属性的警告。但未能链接,原因是:
arm-none-eabi/bin/ld: avds.elf section `.bss' will not fit in region `RAM'
arm-none-eabi/bin/ld: region `RAM' overflowed by 55032 bytes
这些 55032 应该分配在 CCMRAM 中。但它试图使用 RAM。 请帮助我了解如何使其工作。
链接器脚本:
ENTRY(Reset_Handler)
_estack = 0x20000000 + 128K - 1;
_Min_Heap_Size = 0;
_Min_Stack_Size = 0x200;
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
}
SECTIONS
{
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector))
. = ALIGN(4);
} >FLASH
.text :
{
. = ALIGN(4);
*(.text)
*(.text*)
*(.glue_7)
*(.glue_7t)
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .;
} >FLASH
.rodata :
{
. = ALIGN(4);
*(.rodata)
*(.rodata*)
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
_sidata = LOADADDR(.data);
.data :
{
. = ALIGN(4);
_sdata = .;
*(.data)
*(.data*)
. = ALIGN(4);
_edata = .;
} >RAM AT> FLASH
_siccmram = LOADADDR(.ccmram);
.ccmram :
{ . = ALIGN(4);
_sccmram = .;
*(.ccmram)
*(.ccmram*)
. = ALIGN(4);
_eccmram = .;
} >CCMRAM AT> FLASH
. = ALIGN(4);
.bss :
{
_sbss = .;
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
__bss_end__ = _ebss;
} >RAM
._user_heap_stack :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
【问题讨论】:
-
请创建一个minimal reproducible example。
HeapRegion_t是什么?*(.ccmram)但.ccram!=CCRAM,不是吗? -
很难,因为上下文足够大。 stm32 和 cmsis 和 freertos 合二为一看起来是一个足够大的项目