69,371
社区成员
发帖
与我相关
我的任务
分享
MEMORY
{
rom: ORIGIN = 0x08000000, LENGTH = 32M
ram: ORIGIN = 0x03000000, LENGTH = 32K
}
__text_start = ORIGIN(rom);
__ram_start = ORIGIN(ram);
SECTIONS
{
. = __text_start;
...
/* 将函数A()和B()等其他'ram functions'放到iwram内存区 */
__ram_lma = .;
.ramsect __ram_start : AT(__ram_lma)
{
__ramcode_start = ABSOLUTE(.); /* ram code vma start */
*(.ramcode)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__ramcode_end = ABSOLUTE(.); /* ram code vma ending */
} >ram
...
}
#define RAM_FUNC __attribute__((section(".ramcode"), long_call))
RAM_FUNC void A(void) { B(); /* do anything else you wants */ }
RAM_FUNC void B(void) { /* do anything you wants */ }
...
/* 代码片段用来将ram functions 拷贝到链结后的地址 */
ldr r1, = __ram_lma
ldr r2, = __ramcode_start
ldr r4, = __ramcode_end
bl memcpy /* maybe you need to customize your memcpy() */
/* after this line, you could call A(),B() and other ram functions like a ordinary function */
...