1/* 2***************************************************************************** 3** 4 5** File : Target_FLASH.ld 6** 7** Abstract : Linker script for Target Device with 8** 512Byte FLASH, 64KByte RAM 9** 10** Set heap size, stack size and stack location according 11** to application requirements. 12** 13** Set memory bank area and size if external memory is used. 14** 15** Date : 2019-10-28 16** 17***************************************************************************** 18*/ 19 20/* Entry Point */ 21ENTRY(Reset_Handler) 22 23/* Highest address of the user mode stack */ 24_estack = 0x20010000; /* end of RAM */ 25/* Generate a link error if heap and stack don't fit into RAM */ 26_Min_Heap_Size = 0x400; /* required amount of heap */ 27_Min_Stack_Size = 0x1000; /* required amount of stack */ 28 29/* Specify the memory areas */ 30MEMORY 31{ 32RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K 33FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K 34} 35 36/* Define output sections */ 37SECTIONS 38{ 39 /* The startup code goes first into FLASH */ 40 .isr_vector : AT(0) 41 { 42 . = ALIGN(4); 43 KEEP(*(.isr_vector)) /* Startup code */ 44 . = ALIGN(4); 45 } >FLASH 46 47 .chipinit_section : AT(0xC0) 48 { 49 . = ALIGN(4); 50 *(.chipinit_section) /* .text sections (code) */ 51 *(.chipinit_section*) /* .text* sections (code) */ 52 *(.glue_7) /* glue arm to thumb code */ 53 *(.glue_7t) /* glue thumb to arm code */ 54 *(.eh_frame) 55 56 KEEP (*(.init)) 57 KEEP (*(.fini)) 58 59 . = ALIGN(4); 60 _etext = .; /* define a global symbols at end of code */ 61 } >FLASH 62 63 /* The program code and other data goes into FLASH */ 64 .text : 65 { 66 . = ALIGN(4); 67 *(.text) /* .text sections (code) */ 68 *(.text*) /* .text* sections (code) */ 69 *(.glue_7) /* glue arm to thumb code */ 70 *(.glue_7t) /* glue thumb to arm code */ 71 *(.eh_frame) 72 73 KEEP (*(.init)) 74 KEEP (*(.fini)) 75 76 . = ALIGN(4); 77 _etext = .; /* define a global symbols at end of code */ 78 } >FLASH 79 80 /* Constant data goes into FLASH */ 81 .rodata : 82 { 83 . = ALIGN(4); 84 *(.rodata) /* .rodata sections (constants, strings, etc.) */ 85 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 86 . = ALIGN(4); 87 } >FLASH 88 89 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 90 .ARM : { 91 __exidx_start = .; 92 *(.ARM.exidx*) 93 __exidx_end = .; 94 } >FLASH 95 96 .preinit_array : 97 { 98 PROVIDE_HIDDEN (__preinit_array_start = .); 99 KEEP (*(.preinit_array*)) 100 PROVIDE_HIDDEN (__preinit_array_end = .); 101 } >FLASH 102 .init_array : 103 { 104 PROVIDE_HIDDEN (__init_array_start = .); 105 KEEP (*(SORT(.init_array.*))) 106 KEEP (*(.init_array*)) 107 PROVIDE_HIDDEN (__init_array_end = .); 108 } >FLASH 109 .fini_array : 110 { 111 PROVIDE_HIDDEN (__fini_array_start = .); 112 KEEP (*(SORT(.fini_array.*))) 113 KEEP (*(.fini_array*)) 114 PROVIDE_HIDDEN (__fini_array_end = .); 115 } >FLASH 116 117 /* used by the startup to initialize data */ 118 _sidata = LOADADDR(.data); 119 120 /* Initialized data sections goes into RAM, load LMA copy after code */ 121 .data : 122 { 123 . = ALIGN(4); 124 _sdata = .; /* create a global symbol at data start */ 125 *(.data) /* .data sections */ 126 *(.data*) /* .data* sections */ 127 128 . = ALIGN(4); 129 _edata = .; /* define a global symbol at data end */ 130 } >RAM AT> FLASH 131 132 133 /* Uninitialized data section */ 134 . = ALIGN(4); 135 .bss : 136 { 137 /* This is used by the startup in order to initialize the .bss secion */ 138 _sbss = .; /* define a global symbol at bss start */ 139 __bss_start__ = _sbss; 140 *(.bss) 141 *(.bss*) 142 *(COMMON) 143 144 . = ALIGN(4); 145 _ebss = .; /* define a global symbol at bss end */ 146 __bss_end__ = _ebss; 147 } >RAM 148 149 /* User_heap_stack section, used to check that there is enough RAM left */ 150 ._user_heap_stack : 151 { 152 . = ALIGN(8); 153 PROVIDE ( end = . ); 154 PROVIDE ( _end = . ); 155 . = . + _Min_Heap_Size; 156 . = . + _Min_Stack_Size; 157 . = ALIGN(8); 158 } >RAM 159 160 161 162 /* Remove information from the standard libraries */ 163 /DISCARD/ : 164 { 165 libc.a ( * ) 166 libm.a ( * ) 167 libgcc.a ( * ) 168 } 169 170 .ARM.attributes 0 : { *(.ARM.attributes) } 171} 172 173 174