|
| 1 | +/** Copyright © 2021 The Things Industries B.V. |
| 2 | +* |
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +* you may not use this file except in compliance with the License. |
| 5 | +* You may obtain a copy of the License at |
| 6 | +* |
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +* |
| 9 | +* Unless required by applicable law or agreed to in writing, software |
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +* See the License for the specific language governing permissions and |
| 13 | +* limitations under the License. |
| 14 | +*/ |
| 15 | + |
| 16 | +/* Entry Point */ |
| 17 | +ENTRY(Reset_Handler) |
| 18 | + |
| 19 | +/* Highest address of the user mode stack */ |
| 20 | +_estack = ORIGIN(RAM1) + LENGTH(RAM1); /* end of "SRAM1" Ram type memory */ |
| 21 | + |
| 22 | +_Min_Heap_Size = 0x400; /* required amount of heap */ |
| 23 | +_Min_Stack_Size = 0x800; /* required amount of stack */ |
| 24 | + |
| 25 | +/* Memories definition */ |
| 26 | +MEMORY |
| 27 | +{ |
| 28 | + ROM (rx) : ORIGIN = 0x08000000, LENGTH = 256K /* Flash memory dedicated to CM4 */ |
| 29 | + RAM1 (xrw) : ORIGIN = 0x20000000, LENGTH = 32K /* Non-backup SRAM1 dedicated to CM4 */ |
| 30 | + RAM2 (xrw) : ORIGIN = 0x20008000, LENGTH = 32K /* Backup SRAM2 dedicated to CM4 */ |
| 31 | +} |
| 32 | + |
| 33 | +/* Sections */ |
| 34 | +SECTIONS |
| 35 | +{ |
| 36 | + /* The startup code into "ROM" Rom type memory */ |
| 37 | + .isr_vector : |
| 38 | + { |
| 39 | + . = ALIGN(8); |
| 40 | + KEEP(*(.isr_vector)) /* Startup code */ |
| 41 | + . = ALIGN(8); |
| 42 | + } >ROM |
| 43 | + |
| 44 | + /* The program code and other data into "ROM" Rom type memory */ |
| 45 | + .text : |
| 46 | + { |
| 47 | + . = ALIGN(8); |
| 48 | + *(.text) /* .text sections (code) */ |
| 49 | + *(.text*) /* .text* sections (code) */ |
| 50 | + *(.glue_7) /* glue arm to thumb code */ |
| 51 | + *(.glue_7t) /* glue thumb to arm code */ |
| 52 | + *(.eh_frame) |
| 53 | + |
| 54 | + KEEP (*(.init)) |
| 55 | + KEEP (*(.fini)) |
| 56 | + |
| 57 | + . = ALIGN(8); |
| 58 | + _etext = .; /* define a global symbols at end of code */ |
| 59 | + } >ROM |
| 60 | + |
| 61 | + /* Constant data into "ROM" Rom type memory */ |
| 62 | + .rodata : |
| 63 | + { |
| 64 | + . = ALIGN(8); |
| 65 | + *(.rodata) /* .rodata sections (constants, strings, etc.) */ |
| 66 | + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ |
| 67 | + . = ALIGN(8); |
| 68 | + } >ROM |
| 69 | + |
| 70 | + .ARM.extab : { |
| 71 | + . = ALIGN(8); |
| 72 | + *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 73 | + . = ALIGN(8); |
| 74 | + } >ROM |
| 75 | + |
| 76 | + .ARM : { |
| 77 | + . = ALIGN(8); |
| 78 | + __exidx_start = .; |
| 79 | + *(.ARM.exidx*) |
| 80 | + __exidx_end = .; |
| 81 | + . = ALIGN(8); |
| 82 | + } >ROM |
| 83 | + |
| 84 | + .preinit_array : |
| 85 | + { |
| 86 | + . = ALIGN(8); |
| 87 | + PROVIDE_HIDDEN (__preinit_array_start = .); |
| 88 | + KEEP (*(.preinit_array*)) |
| 89 | + PROVIDE_HIDDEN (__preinit_array_end = .); |
| 90 | + . = ALIGN(8); |
| 91 | + } >ROM |
| 92 | + |
| 93 | + .init_array : |
| 94 | + { |
| 95 | + . = ALIGN(8); |
| 96 | + PROVIDE_HIDDEN (__init_array_start = .); |
| 97 | + KEEP (*(SORT(.init_array.*))) |
| 98 | + KEEP (*(.init_array*)) |
| 99 | + PROVIDE_HIDDEN (__init_array_end = .); |
| 100 | + . = ALIGN(8); |
| 101 | + } >ROM |
| 102 | + |
| 103 | + .fini_array : |
| 104 | + { |
| 105 | + . = ALIGN(8); |
| 106 | + PROVIDE_HIDDEN (__fini_array_start = .); |
| 107 | + KEEP (*(SORT(.fini_array.*))) |
| 108 | + KEEP (*(.fini_array*)) |
| 109 | + PROVIDE_HIDDEN (__fini_array_end = .); |
| 110 | + . = ALIGN(8); |
| 111 | + } >ROM |
| 112 | + |
| 113 | + /* Used by the startup to initialize data */ |
| 114 | + _sidata = LOADADDR(.data); |
| 115 | + |
| 116 | + /* Initialized data sections into "SRAM1" Ram type memory */ |
| 117 | + .data : |
| 118 | + { |
| 119 | + . = ALIGN(8); |
| 120 | + _sdata = .; /* create a global symbol at data start */ |
| 121 | + *(.data) /* .data sections */ |
| 122 | + *(.data*) /* .data* sections */ |
| 123 | + |
| 124 | + . = ALIGN(8); |
| 125 | + _edata = .; /* define a global symbol at data end */ |
| 126 | + |
| 127 | + } >RAM1 AT> ROM |
| 128 | + |
| 129 | + /* Uninitialized data section into "SRAM1" Ram type memory */ |
| 130 | + . = ALIGN(8); |
| 131 | + .bss : |
| 132 | + { |
| 133 | + /* This is used by the startup in order to initialize the .bss section */ |
| 134 | + _sbss = .; /* define a global symbol at bss start */ |
| 135 | + __bss_start__ = _sbss; |
| 136 | + *(.bss) |
| 137 | + *(.bss*) |
| 138 | + *(COMMON) |
| 139 | + |
| 140 | + . = ALIGN(8); |
| 141 | + _ebss = .; /* define a global symbol at bss end */ |
| 142 | + __bss_end__ = _ebss; |
| 143 | + } >RAM1 |
| 144 | + |
| 145 | + /* Data section into "SRAM1" Ram type memory: Non-backup SRAM1 dedicated to CM4 */ |
| 146 | + . = ALIGN(8); |
| 147 | + RAM1_region : |
| 148 | + { |
| 149 | + _sRAM1_region = .; /* define a global symbol at section start */ |
| 150 | + *(.RAM1_region) |
| 151 | + |
| 152 | + . = ALIGN(8); |
| 153 | + _eRAM1_region = .; /* define a global symbol at section end */ |
| 154 | + } >RAM1 |
| 155 | + |
| 156 | + /* Data section into "SRAM2" Ram type memory: Backup SRAM2 dedicated to CM4 */ |
| 157 | + . = ALIGN(8); |
| 158 | + RAM2_region : |
| 159 | + { |
| 160 | + _sRAM2_region = .; /* define a global symbol at section start */ |
| 161 | + *(.RAM2_region) |
| 162 | + |
| 163 | + . = ALIGN(8); |
| 164 | + _eRAM2_region = .; /* define a global symbol at section end */ |
| 165 | + } >RAM2 |
| 166 | + |
| 167 | + /* User_heap_stack section, used to check that there is enough "SRAM1" Ram type memory left */ |
| 168 | + ._user_heap_stack : |
| 169 | + { |
| 170 | + . = ALIGN(8); |
| 171 | + PROVIDE ( end = . ); |
| 172 | + PROVIDE ( _end = . ); |
| 173 | + . = . + _Min_Heap_Size; |
| 174 | + . = . + _Min_Stack_Size; |
| 175 | + . = ALIGN(8); |
| 176 | + __RAM_segment_used_end__ = .; |
| 177 | + } >RAM1 |
| 178 | + |
| 179 | + /* Remove information from the compiler libraries */ |
| 180 | + /DISCARD/ : |
| 181 | + { |
| 182 | + libc.a ( * ) |
| 183 | + libm.a ( * ) |
| 184 | + libgcc.a ( * ) |
| 185 | + } |
| 186 | + |
| 187 | + .ARM.attributes 0 : { *(.ARM.attributes) } |
| 188 | +} |
0 commit comments