1/**
2  ****************************************************************************
3  Copyright (c) 2019, Nations Technologies Inc.
4
5  All rights reserved.
6  ****************************************************************************
7
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10
11  - Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the disclaimer below.
13
14  Nations' name may not be used to endorse or promote products derived from
15  this software without specific prior written permission.
16
17  DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
18  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20  DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
21  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  ****************************************************************************
28 **/
29
30/* Entry Point */
31ENTRY(Reset_Handler)
32
33/* Highest address of the user mode stack */
34_estack = 0x20008000;    /* end of RAM */
35
36/* Generate a link error if heap and stack don't fit into RAM */
37_Min_Heap_Size = 0x200;      /* required amount of heap  */
38_Min_Stack_Size = 0x800; /* required amount of stack */
39
40/* Specify the memory areas */
41MEMORY
42{
43FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 128K
44RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 32K
45}
46
47/* Define output sections */
48SECTIONS
49{
50  /* The startup code goes first into FLASH */
51  .isr_vector :
52  {
53    . = ALIGN(4);
54    KEEP(*(.isr_vector)) /* Startup code */
55    . = ALIGN(4);
56  } >FLASH
57
58  /* The program code and other data goes into FLASH */
59  .text :
60  {
61    . = ALIGN(4);
62    *(.text)           /* .text sections (code) */
63    *(.text*)          /* .text* sections (code) */
64    *(.glue_7)         /* glue arm to thumb code */
65    *(.glue_7t)        /* glue thumb to arm code */
66    *(.eh_frame)
67
68    KEEP (*(.init))
69    KEEP (*(.fini))
70
71	/* section information for finsh shell */
72	. = ALIGN(4);
73	__fsymtab_start = .;
74	KEEP(*(FSymTab))
75	__fsymtab_end = .;
76
77	. = ALIGN(4);
78	__vsymtab_start = .;
79	KEEP(*(VSymTab))
80	__vsymtab_end = .;
81
82	/* section information for initial. */
83	. = ALIGN(4);
84	__rt_init_start = .;
85	KEEP(*(SORT(.rti_fn*)))
86	__rt_init_end = .;
87
88    . = ALIGN(4);
89    _etext = .;        /* define a global symbols at end of code */
90  } >FLASH
91
92  /* Constant data goes into FLASH */
93  .rodata :
94  {
95    . = ALIGN(4);
96    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
97    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
98    . = ALIGN(4);
99  } >FLASH
100
101  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
102  .ARM : {
103    __exidx_start = .;
104    *(.ARM.exidx*)
105    __exidx_end = .;
106  } >FLASH
107
108  .preinit_array     :
109  {
110    PROVIDE_HIDDEN (__preinit_array_start = .);
111    KEEP (*(.preinit_array*))
112    PROVIDE_HIDDEN (__preinit_array_end = .);
113  } >FLASH
114  .init_array :
115  {
116    PROVIDE_HIDDEN (__init_array_start = .);
117    KEEP (*(SORT(.init_array.*)))
118    KEEP (*(.init_array*))
119    PROVIDE_HIDDEN (__init_array_end = .);
120  } >FLASH
121  .fini_array :
122  {
123    PROVIDE_HIDDEN (__fini_array_start = .);
124    KEEP (*(SORT(.fini_array.*)))
125    KEEP (*(.fini_array*))
126    PROVIDE_HIDDEN (__fini_array_end = .);
127  } >FLASH
128
129  /* used by the startup to initialize data */
130  _sidata = LOADADDR(.data);
131
132  /* Initialized data sections goes into RAM, load LMA copy after code */
133  .data :
134  {
135    . = ALIGN(4);
136    _sdata = .;        /* create a global symbol at data start */
137    *(.data)           /* .data sections */
138    *(.data*)          /* .data* sections */
139
140    . = ALIGN(4);
141    _edata = .;        /* define a global symbol at data end */
142  } >RAM AT> FLASH
143
144  /* Uninitialized data section */
145  . = ALIGN(4);
146  .bss :
147  {
148    /* This is used by the startup in order to initialize the .bss secion */
149    _sbss = .;         /* define a global symbol at bss start */
150    __bss_start__ = _sbss;
151    *(.bss)
152    *(.bss*)
153    *(COMMON)
154
155    . = ALIGN(4);
156    _ebss = .;         /* define a global symbol at bss end */
157    __bss_end__ = _ebss;
158  } >RAM
159
160  /* User_heap_stack section, used to check that there is enough RAM left */
161  ._user_heap_stack :
162  {
163    . = ALIGN(4);
164    PROVIDE ( end = . );
165    PROVIDE ( _end = . );
166    . = . + _Min_Heap_Size;
167    . = . + _Min_Stack_Size;
168    . = ALIGN(4);
169  } >RAM
170
171
172
173  /* Remove information from the standard libraries */
174  /DISCARD/ :
175  {
176    libc.a ( * )
177    libm.a ( * )
178    libgcc.a ( * )
179  }
180
181  .ARM.attributes 0 : { *(.ARM.attributes) }
182}
183