Placing data at an address
If you wish to place data (for example a buffer used by a peripheral) at a known address, you can use the following technique.
- Place your data into its own section. e.g.
__attribute__ ((section(".myBuffer"))) unsigned char myBuffer[1024] ;Modify your project to provide your own linker script. See OwnLinkScripts
- If it doesn't exist, create a Memory region in the linker script for Memory
MEMORY
{
/* Define each memory region */
MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32k */
RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8k */
MyBufferRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x2000
}- Modify the linker script to place your data section to a known address
.myBuffer (NOLOAD):
{
*(.myBuffer)
} > MyBufferRAM