|
项目开发使用的H743IIT6具有较大的RAM空间,目前想将固件整个拷贝到地址段0x24000000-0x2403FFFF运行以提高代码整体运行速率。参考了很多网上攻略,进行了多种尝试均未成功,不知道这个坑在哪里,因此发帖希望能够得到一点启发。
我的代码分Bootloader和APP两部分,其中Bootloader负责固件更新检查,最后直接到APP的Reset_Handler。
我的操作包括:
1)APP使用的.ld文件如下:
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x3000; /* required amount of heap */
_Min_Stack_Size = 0x3000; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 1920K
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_EXEC (xrw) : ORIGIN = 0x24000000, LENGTH = 256K
RAM_D1 (xrw) : ORIGIN = 0x24040000, LENGTH = 256K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM_1 (xrw) : ORIGIN = 0xD0000000, LENGTH = 32M
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into RAM_EXEC */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >RAM_EXEC AT> FLASH
/* The program code and other data goes into RAM_EXEC */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >RAM_EXEC AT> FLASH
/* Constant data goes into RAM_EXEC */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >RAM_EXEC AT> FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM_EXEC AT> FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >RAM_EXEC AT> FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >RAM_EXEC AT> FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >RAM_EXEC AT> FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >RAM_EXEC AT> FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */
*(.RamFunc*) /* .RamFunc* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM_D1 AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM_D1
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM_D1 /*>DTCMRAM */ /*>RAM_D1*/
.preset_sec (NOLOAD) :
{
. = ALIGN(4);
} >DTCMRAM
.dtcmram_sec (NOLOAD):
{
} >DTCMRAM AT> FLASH
.itcmram_sec (NOLOAD) :
{
. = ABSOLUTE(0x00000008); /*让出地址0x0,防止与NULL指针判断冲突*/
. = ALIGN(8);
} >ITCMRAM
/* ETH_CODE: add placement of DMA descriptors and RX buffers */
.lwip_sec (NOLOAD) :
{
. = ABSOLUTE(0x30000000);
KEEP ( *(.RxDecripSection) )
. = ABSOLUTE(0x30000100);
KEEP ( *(.TxDecripSection) )
. = ABSOLUTE(0x30000200);
/*KEEP ( *(.Rx_PoolSection) )
. = ABSOLUTE(0x30000000); */
KEEP ( *(.lwipram) )
} >RAM_D2 AT >FLASH
.ram3_sec (NOLOAD) :
{
. = ABSOLUTE(0x38000000);
KEEP ( *(.ram3))
} >RAM_D3
.sdram1_sec (NOLOAD) :
{
. = ABSOLUTE(0xD0000000);
KEEP ( *(.sdram1) )
} >SDRAM_1
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
其中的RAM_EXEC 就是准备用来放置全部code的空间。
固件编译链接后的.list文件中确认已将全部函数及中断向量表都转移到RAM_EXEC中了。

在Bootloader中直接将存放在起始地址为0x08020000的flash空间数据直接拷贝到RAM_EXEC,并修改跳转指针指向RAM_EXEC中的Reset_Handler。
此外,在system_stm32h7xx.c文件中追加了宏定义#define VECT_TAB_SRAM
以确保中断向量表寻址正确。
经过上述修改后分别下载Bootloader和APP固件到测试板,上电后程序无法正常运行。
我随后修改.ld文件,将全部存放于FLASH的内容都转移到RAM中,代码下载后是可以正常运行的,说明我对于中断向量表这块的改动是成功的,但在实现代码从FLASH向RAM搬运和跳转控制上存在问题。
哪位大侠对这个有研究啊?
|
|