stm32f405.ld 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. GNU linker script for STM32F405
  3. */
  4. /* Specify the memory areas */
  5. MEMORY
  6. {
  7. FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x100000 /* entire flash, 1 MiB */
  8. FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 0x004000 /* sector 0, 16 KiB */
  9. FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 0x080000 /* sectors 5,6,7,8, 4*128KiB = 512 KiB (could increase it more) */
  10. CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0x010000 /* 64 KiB */
  11. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x020000 /* 128 KiB */
  12. }
  13. /* top end of the stack */
  14. _estack = ORIGIN(RAM) + LENGTH(RAM);
  15. /* RAM extents for the garbage collector */
  16. _ram_end = ORIGIN(RAM) + LENGTH(RAM);
  17. _heap_end = 0x2001c000; /* tunable */
  18. /* define output sections */
  19. SECTIONS
  20. {
  21. /* The startup code goes first into FLASH */
  22. .isr_vector :
  23. {
  24. . = ALIGN(4);
  25. KEEP(*(.isr_vector)) /* Startup code */
  26. . = ALIGN(4);
  27. } >FLASH_ISR
  28. /* The program code and other data goes into FLASH */
  29. .text :
  30. {
  31. . = ALIGN(4);
  32. *(.text) /* .text sections (code) */
  33. *(.text*) /* .text* sections (code) */
  34. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  35. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  36. /* *(.glue_7) */ /* glue arm to thumb code */
  37. /* *(.glue_7t) */ /* glue thumb to arm code */
  38. . = ALIGN(4);
  39. _etext = .; /* define a global symbol at end of code */
  40. _sidata = _etext; /* This is used by the startup in order to initialize the .data secion */
  41. } >FLASH_TEXT
  42. /*
  43. .ARM.extab :
  44. {
  45. *(.ARM.extab* .gnu.linkonce.armextab.*)
  46. } >FLASH
  47. .ARM :
  48. {
  49. __exidx_start = .;
  50. *(.ARM.exidx*)
  51. __exidx_end = .;
  52. } >FLASH
  53. */
  54. /* This is the initialized data section
  55. The program executes knowing that the data is in the RAM
  56. but the loader puts the initial values in the FLASH (inidata).
  57. It is one task of the startup to copy the initial values from FLASH to RAM. */
  58. .data : AT ( _sidata )
  59. {
  60. . = ALIGN(4);
  61. _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
  62. _ram_start = .; /* create a global symbol at ram start for garbage collector */
  63. *(.data) /* .data sections */
  64. *(.data*) /* .data* sections */
  65. . = ALIGN(4);
  66. _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
  67. } >RAM
  68. /* Uninitialized data section */
  69. .bss :
  70. {
  71. . = ALIGN(4);
  72. _sbss = .; /* define a global symbol at bss start; used by startup code */
  73. *(.bss)
  74. *(.bss*)
  75. *(COMMON)
  76. . = ALIGN(4);
  77. _ebss = .; /* define a global symbol at bss end; used by startup code */
  78. } >RAM
  79. /* this is to define the start of the heap, and make sure we have a minimum size */
  80. .heap :
  81. {
  82. . = ALIGN(4);
  83. _heap_start = .; /* define a global symbol at heap start */
  84. } >RAM
  85. /* this just checks there is enough RAM for the stack */
  86. .stack :
  87. {
  88. . = ALIGN(4);
  89. } >RAM
  90. /* Remove information from the standard libraries */
  91. /*
  92. /DISCARD/ :
  93. {
  94. libc.a ( * )
  95. libm.a ( * )
  96. libgcc.a ( * )
  97. }
  98. */
  99. .ARM.attributes 0 : { *(.ARM.attributes) }
  100. }