add it with : -Wl,-TMCU.ld to your makefile or in your IDE linker settings
I self use code::blocks vor ATMEL AVR's and STM32 MCU's
Joshy
Code: Select all
' fill in your MCU specs
const as string MCU = "STM32F103C8T6"
const as uinteger FLASH_SIZE = 1024 * 64 ' size of read only programm memory
const as uinteger SRAM_SIZE = 1024 * 20 ' size of data ram
const as uinteger STACK_SIZE = 1024 ' size of stack
const as uinteger FLASH_BASE = &H8000000 ' start of read only programm memory
const as uinteger SRAM_BASE = &H2000000 ' start of data ram
' end of your MCU specs
' don't change
const as uinteger STACK_TOP = SRAM_BASE + SRAM_SIZE
const as uinteger STACK_BASE = STACK_TOP - STACK_SIZE
const as uinteger STACK_MIN = STACK_SIZE \ 4
const as uinteger TUMB_ALIGN = 4
' optional for debuging -g
#define USE_GDB
' write out the linker script
open MCU & ".ld" for output as #1
'open cons for output as #1
print #1,"/* linker script for MCU " & MCU & " */"
print #1,""
print #1,"PROVIDE( _Stack_Size = 0x" & hex(STACK_SIZE,8) & ");"
print #1,"PROVIDE( _Stack_Init = 0x" & hex(STACK_BASE,8) & ");"
print #1,""
print #1,"/* for the startup code stack init */"
print #1,"_estack = 0x" & hex(STACK_TOP) & ";"
print #1,""
print #1,"MEMORY {"
print #1," FLASH (rx) : ORIGIN = 0x" & hex(FLASH_BASE,8) & ", LENGTH = 0x" & hex(FLASH_SIZE,8)
print #1," RAM (xrw) : ORIGIN = 0x" & hex(SRAM_BASE ,8) & ", LENGTH = 0x" & hex(SRAM_SIZE ,8)
print #1,"}"
print #1,""
print #1,"SECTIONS {"
print #1," /* begin of the startup code in FLASH */"
print #1," .isr_vector : {"
print #1," . = ALIGN(4);"
print #1," KEEP(*(.isr_vector))"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," } >FLASH"
print #1,""
print #1," /* program code in FLASH */"
print #1," .text : {"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," *(.text)"
print #1," *(.text.*)"
print #1," *(.rodata)"
print #1," *(.rodata*)"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," _etext = .;"
print #1," _sidata = _etext;"
print #1," } >FLASH"
print #1,""
print #1," /* initialized data FLASH->SRAM */"
print #1," .data : AT ( _sidata ) {"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," _sdata = . ;"
print #1," KEEP( *(.data) )"
print #1," KEEP( *(.data.*) )"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," _edata = . ;"
print #1," } >RAM"
print #1,""
print #1," /* uninitialized data in SRAM */"
print #1," .bss : {"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," _sbss = .;"
print #1," *(.bss)"
print #1," *(COMMON)"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," _ebss = . ;"
print #1," } >RAM"
print #1," PROVIDE ( end = _ebss);"
print #1," PROVIDE (_end = _ebss);"
print #1," /* error check for user stack */"
print #1," ._usrstack : {"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," _susrstack = . ;"
print #1," . = . + 0x" & hex(STACK_MIN) & ";"
print #1," . = ALIGN(" & TUMB_ALIGN & ");"
print #1," _eusrstack = . ;"
print #1," } >RAM"
#ifdef USE_GDB
print #1," /* remove stabs from default libs */"
print #1," DISCARD : {"
print #1," libc.a ( * )"
print #1," libm.a ( * )"
print #1," libgcc.a ( * )"
print #1," }"
print #1," .comment 0 : {"
print #1," *(.comment)"
print #1," }"
print #1,""
print #1,"/* -g stab's */"
print #1," .stab 0 : {"
print #1," *(.stab)"
print #1," }"
print #1," .stabstr 0 : {"
print #1," *(.stabstr)"
print #1," }"
print #1," .stab.excl 0 : {"
print #1," *(.stab.excl)"
print #1," }"
print #1," .stab.exclstr 0 : {"
print #1," *(.stab.exclstr)"
print #1," }"
print #1," .stab.index 0 : {"
print #1," *(.stab.index)"
print #1," }"
print #1," .stab.indexstr 0 : {"
print #1," *(.stab.indexstr)"
print #1," }"
#endif
print #1,"/* end of sections */"
print #1,"}"
close #1
print "done wait for key ..."
sleep