admin管理员组文章数量:1332873
In the stm32f767zi reference manual the memory anization is divvied into: FLASH, SRAM1, SRAM2, ITCM and DTCM but in the linker script the project is either stored into FLASH or RAM. I want to edit the linker script so I can store data in a specific memory region.
I am trying to change it from:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
}
To this:
MEMORY
{
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 16K
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20020000, LENGTH = 368K
SRAM (xrw) : ORIGIN = 0x2007C000, LENGTH = 16K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
}
So I added in the sections this:
_sisram = LOADADDR(.sram);
.sram :
{
. = ALIGN(4);
_ssram = .; /* create a global symbol at data start */
(.sram) / .data sections */
(.sram) /* .data* sections */
. = ALIGN(4);
_esram = .; /* define a global symbol at data end */
} >SRAM AT> FLASH
_siitcm = LOADADDR(.itcm);
.itcm :
. = ALIGN(4);
_sitcm = .; /* create a global symbol at data start */
(.itcm) / .data sections */
(.itcm) /* .data* sections */
. = ALIGN(4);
_eitcm = .; /* define a global symbol at data end */
} >ITCMRAM AT> FLASH
_sidtcm = LOADADDR(.data);
.dtcm :
{
. = ALIGN(4);
_sdtcm = .; /* create a global symbol at data start */
(.dtcm) / .data sections */
(.dtcm) /* .data* sections */
. = ALIGN(4);
_edtcm = .; /* define a global symbol at data end */
} >DTCMRAM AT> FLASH
and then moved to the startup file
first I added the following:
.word _sisram
.word _ssram
.word _esram
.word _siitcm
.word _sitcm
.word _eitcm
.word _sidtcm
.word _sdtcm
.word _edtcm
and then the copy loop like this:
//SRAM
ldr r0, =_ssram
ldr r1, =_esram
ldr r2, =_sisram
movs r3, #0
b LoopCopySramInit
CopySramInit:
ldr r4, [r2, r3]
str r4, [r0, r3]
adds r3, r3, #4
LoopCopySramInit:
adds r4, r0, r3
cmp r4, r1
bcc CopySramInit
//ITCM
ldr r0, =_sitcm
ldr r1, =_eitcm
ldr r2, =_siitcm
movs r3, #0
b LoopCopyItcmInit
CopyItcmInit:
ldr r4, [r2, r3]
str r4, [r0, r3]
adds r3, r3, #4
LoopCopyItcmInit:
adds r4, r0, r3
cmp r4, r1
bcc CopyItcmInit
//DTCM
ldr r0, =_sdtcm
ldr r1, =_edtcm
ldr r2, =_sidtcm
movs r3, #0
b LoopCopyDtcmInit
CopyDtcmInit:
ldr r4, [r2, r3]
str r4, [r0, r3]
adds r3, r3, #4
LoopCopyDtcmInit:
adds r4, r0, r3
cmp r4, r1
bcc CopyDtcmInit
So I am basically copying what the mx did to the data section from flash to RAM, but when I run I get this error undefined reference to `_ssram' I tried to change it from .word to .extern but still the same error.
what am I missing ? is there a better way to divided the RAM region to ITCM DTCM and RAM ? Thank you for your time.
本文标签: memorySTM32 Editing Linker ScriptStack Overflow
版权声明:本文标题:memory - STM32 Editing Linker Script - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742304720a2449688.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论