1 /** 2 ******************************************************************************* 3 * @file hc32f4a0_flash.lds 4 * @brief Linker script for HC32F4A0 Device with 2MByte FLASH, 512KByte RAM. 5 @verbatim 6 Change Logs: 7 Date Author Notes 8 2020-09-15 Chengy First version 9 @endverbatim 10 ******************************************************************************* 11 * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved. 12 * 13 * This software component is licensed by HDSC under BSD 3-Clause license 14 * (the "License"); You may not use this file except in compliance with the 15 * License. You may obtain a copy of the License at: 16 * opensource.org/licenses/BSD-3-Clause 17 * 18 ******************************************************************************* 19 */ 20 21/* Use contiguous memory regions for simple. */ 22MEMORY 23{ 24 FLASH (rx): ORIGIN = 0x00000000, LENGTH = 2M 25 OTP (rx): ORIGIN = 0x03000000, LENGTH = 6876 26 RAM (rwx): ORIGIN = 0x1FFE0000, LENGTH = 512K 27 RAMB (rwx): ORIGIN = 0x200F0000, LENGTH = 4K 28} 29 30ENTRY(Reset_Handler) 31 32SECTIONS 33{ 34 .vectors : 35 { 36 . = ALIGN(4); 37 KEEP(*(.vectors)) 38 . = ALIGN(4); 39 } >FLASH 40 41 .icg_sec 0x00000400 : 42 { 43 KEEP(*(.icg_sec)) 44 } >FLASH 45 46 .text : 47 { 48 . = ALIGN(4); 49 *(.text) 50 *(.text*) 51 *(.glue_7) 52 *(.glue_7t) 53 *(.eh_frame) 54 55 KEEP(*(.init)) 56 KEEP(*(.fini)) 57 . = ALIGN(4); 58 } >FLASH 59 60 .rodata : 61 { 62 . = ALIGN(4); 63 *(.rodata) 64 *(.rodata*) 65 . = ALIGN(4); 66 } >FLASH 67 68 .ARM.extab : 69 { 70 *(.ARM.extab* .gnu.linkonce.armextab.*) 71 } >FLASH 72 73 __exidx_start = .; 74 .ARM.exidx : 75 { 76 *(.ARM.exidx* .gnu.linkonce.armexidx.*) 77 } >FLASH 78 __exidx_end = .; 79 80 .preinit_array : 81 { 82 . = ALIGN(4); 83 /* preinit data */ 84 PROVIDE_HIDDEN (__preinit_array_start = .); 85 KEEP(*(.preinit_array)) 86 PROVIDE_HIDDEN (__preinit_array_end = .); 87 . = ALIGN(4); 88 } >FLASH 89 90 .init_array : 91 { 92 . = ALIGN(4); 93 /* init data */ 94 PROVIDE_HIDDEN (__init_array_start = .); 95 KEEP(*(SORT(.init_array.*))) 96 KEEP(*(.init_array)) 97 PROVIDE_HIDDEN (__init_array_end = .); 98 . = ALIGN(4); 99 } >FLASH 100 101 .fini_array : 102 { 103 . = ALIGN(4); 104 /* finit data */ 105 PROVIDE_HIDDEN (__fini_array_start = .); 106 KEEP(*(SORT(.fini_array.*))) 107 KEEP(*(.fini_array)) 108 PROVIDE_HIDDEN (__fini_array_end = .); 109 . = ALIGN(4); 110 } >FLASH 111 112 __etext = ALIGN(4); 113 114 .otp_sec : 115 { 116 KEEP(*(.otp_sec)) 117 } >OTP 118 119 .otp_lock_sec 0x03001800 : 120 { 121 KEEP(*(.otp_lock_sec)) 122 } >OTP 123 124 .data : AT (__etext) 125 { 126 . = ALIGN(4); 127 __data_start__ = .; 128 *(vtable) 129 *(.data) 130 *(.data*) 131 . = ALIGN(4); 132 *(.ramfunc) 133 *(.ramfunc*) 134 . = ALIGN(4); 135 __data_end__ = .; 136 } >RAM 137 138 __etext_ramb = __etext + ALIGN (SIZEOF(.data), 4); 139 .ramb_data : AT (__etext_ramb) 140 { 141 . = ALIGN(4); 142 __data_start_ramb__ = .; 143 *(.ramb_data) 144 *(.ramb_data*) 145 . = ALIGN(4); 146 __data_end_ramb__ = .; 147 } >RAMB 148 149 .bss : 150 { 151 . = ALIGN(4); 152 _sbss = .; 153 __bss_start__ = _sbss; 154 *(.bss) 155 *(.bss*) 156 *(COMMON) 157 . = ALIGN(4); 158 _ebss = .; 159 __bss_end__ = _ebss; 160 } >RAM 161 162 .ramb_bss : 163 { 164 . = ALIGN(4); 165 __bss_start_ramb__ = .; 166 *(.ramb_bss) 167 *(.ramb_bss*) 168 . = ALIGN(4); 169 __bss_end_ramb__ = .; 170 } >RAMB 171 172 .heap_stack (COPY) : 173 { 174 . = ALIGN(8); 175 __end__ = .; 176 PROVIDE(end = .); 177 PROVIDE(_end = .); 178 *(.heap*) 179 . = ALIGN(8); 180 __HeapLimit = .; 181 182 __StackLimit = .; 183 *(.stack*) 184 . = ALIGN(8); 185 __StackTop = .; 186 } >RAM 187 188 /DISCARD/ : 189 { 190 libc.a (*) 191 libm.a (*) 192 libgcc.a (*) 193 } 194 195 .ARM.attributes 0 : { *(.ARM.attributes) } 196 197 PROVIDE(_stack = __StackTop); 198 PROVIDE(_Min_Heap_Size = __HeapLimit - __HeapBase); 199 PROVIDE(_Min_Stack_Size = __StackTop - __StackLimit); 200 201 __RamEnd = ORIGIN(RAM) + LENGTH(RAM); 202 ASSERT(__StackTop <= __RamEnd, "region RAM overflowed with stack") 203} 204