Skip to main content
n.serina
Associate III
September 4, 2017
Solved

STM32f4x and Data section

  • September 4, 2017
  • 1 reply
  • 895 views
Posted on September 04, 2017 at 15:18

Hello, 

I need small clarifications about  .data section placement in the STM32F446x mcu. 

Let say i have a global array in the program and if i run the program on MCU, 

The arry can be located at 0x20000000 address onwards . 

How did that array came to that location ? I dont see any code in my project (built using KEIL) which copies data section from flash to SRAM. 

and as far i know, code region will be mapped to flash memory and not to SRAM. 

Can anybody please help me to understand how did .data section moves from flash to SRAM ? is it done through sofware or hardware remapping ? Thanks

#stm32f4 #stm32f466
This topic has been closed for replies.
Best answer by Tesla DeLorean
Posted on September 04, 2017 at 17:47

The linker determines where code/data is placed, the 'Load Region' from the Keil Scatter File (linker script) via the Target address options, packs the static RAM data into FLASH. The code within __main (called from startup_stm32f4xx.s) zeros and copies statics into RAM from FLASH, and then executes your main() function.

1 reply

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
September 4, 2017
Posted on September 04, 2017 at 17:47

The linker determines where code/data is placed, the 'Load Region' from the Keil Scatter File (linker script) via the Target address options, packs the static RAM data into FLASH. The code within __main (called from startup_stm32f4xx.s) zeros and copies statics into RAM from FLASH, and then executes your main() function.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
n.serina
n.serinaAuthor
Associate III
September 5, 2017
Posted on September 05, 2017 at 04:22

Thanks Clive, 

Understood.

Jeroen3
Senior
September 5, 2017
Posted on September 05, 2017 at 10:46

This is the ARM linker. You can find the documentation here:

http://www.keil.com/support/man/docs/armlink/armlink_pge1362065968963.htm