tao_z
2022-05-25 1044ba0d2286698d0da28112bffc0f114bef2134
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
*****************************************************************************
**
**  File        : xl6600x_flash.ld
**
**  Abstract    : Linker script for xl6600x Device with
**                256KByte FLASH, 24KByte DRAM
**
**                Set heap size, stack size and stack location according
**                to application requirements.
**
**                Set memory bank area and size if external memory is used.
**
**  Target      : CHIPWAYS xl6600
**
**  Environment : Chipways Code Editor(R)
**
**  Distribution: The file is distributed as is, without any warranty
**                of any kind.
**
**  (c)Copyright Chipways.
**  You may use this file as-is or modify it according to the needs of your
**  project. Distribution of this file (unmodified or modified) is not
**  permitted. Chipways permit registered Chipways Code Editor(R) users the
**  rights to distribute the assembled, compiled & linked contents of this
**  file as part of an application binary file, provided that it is built
**  using the Chipways Code Editor(R) toolchain.
**
*****************************************************************************
*/
 
 
/* Entry Point */
ENTRY(Reset_Handler)
 
/* Generate a link error if heap and stack don't fit into DRAM */
_Min_Heap_Size  = DEFINED(__heap_size__)  ? __heap_size__  : 0x00000200;      /* required amount of heap  */
_Min_Stack_Size = DEFINED(__stack_size__) ? __stack_size__ : 0x00000400; /* required amount of stack */
 
/* Specify the memory areas */
MEMORY
{
  FLASH (rx)      : ORIGIN = 0x00000000, LENGTH = 256K
  CRAM (xrw)      : ORIGIN = 0x1FFFE800, LENGTH = 6K
  DRAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 18K
  RAM_VECT_TBL (xrw) : ORIGIN = 0x20000000,        LENGTH = 0x200
  FALSH_DRIVER_RAM (xrw):ORIGIN = 0x20000200,        LENGTH = 0x100
  BOOTFLAG (xrw)  : ORIGIN = 0x20004700, LENGTH = 0x100
 
  FLASH_BOOT     (rx) : ORIGIN = 0x0000000, LENGTH = 48K
  FLASH_APP      (rx) : ORIGIN = 0x000C100, LENGTH = 256K -48K -8K-0x100
  FLASH_EEP      (rx) : ORIGIN = 0x003E000, LENGTH = 8K   /* FALSH EE */
 
  FLASH_APPL_CRC (rx) : ORIGIN = 0x000C000, LENGTH = 0x100
}
 
/* Define output sections */
SECTIONS
{
    /* no init ram data */
  .RAMNoInitSector :
  {
    . = ALIGN(8);
    KEEP(*(.noinit_bootReqFlag_ram)) /* Startup code */
    . = ALIGN(8);
  } >BOOTFLAG
 
  .RAMVectorTable  : {KEEP(*(.RAMVectorTable))} > RAM_VECT_TBL
  .flashdriver_ram  : {KEEP(*(.flashdriver_ram))} > FALSH_DRIVER_RAM
  
  
  /* file define  */
  .filedefine_rom :
  {
    . = ALIGN(8);
    KEEP(*(.filedefine_rom)) /* Startup code */
    . = ALIGN(8);
  } >FLASH_APPL_CRC
 
  /* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(8);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(8);
  } >FLASH
  
  . = ALIGN(8);
      _falsh_sidata = .;
      
  /* _falsh_sidata is load memory address*/
    .flash_ram : AT(_falsh_sidata)
    {
        . = ALIGN(8);
        _flash_start = .;
        KEEP(*(.flash_ram)) /* flash operation code */
    . = ALIGN(8);
    } >DRAM
    
    /*SIZEOF(.flash_ram) return the size in bytes of flash_ram*/
    _flash_end1 = SIZEOF(.flash_ram);
    _flash_end = _flash_start + _flash_end1;
  
  
  /* The program code and other data goes into FLASH */
  .text (_falsh_sidata + _flash_end1): 
  {
    . = ALIGN(8);
    *(.text)           /* .text sections (code) */
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
 
    KEEP (*(.init))
    KEEP (*(.fini))
 
    . = ALIGN(8);
    _etext = .;        /* define a global symbols at end of code */
  } >FLASH_BOOT
  . = ALIGN(8);
   .ARM.extab   : {
    *(.ARM.extab* .gnu.linkonce.armextab.*)  
    . = ALIGN(8); 
    } >FLASH_BOOT
    
    .ARM : {
    __exidx_start = .;
      *(.ARM.exidx*)
      __exidx_end = .;
       . = ALIGN(8);
    } >FLASH_BOOT
 
    . = ALIGN(8);
  .ARM.attributes : { 
  *(.ARM.attributes) 
  . = ALIGN(8);
  } > FLASH_BOOT
 
    . = ALIGN(8);
  .preinit_array     :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
    . = ALIGN(8);
  } >FLASH_BOOT
      . = ALIGN(8);
  .init_array :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
    . = ALIGN(8);
  } >FLASH_BOOT
  . = ALIGN(8);
  .fini_array :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(.fini_array*))
    KEEP (*(SORT(.fini_array.*)))
    PROVIDE_HIDDEN (__fini_array_end = .);
    . = ALIGN(8);
  } >FLASH_BOOT
 
    
    
  /* used by the startup to initialize data */
  . = ALIGN(8);
  _sidata = .;
  
  /* Initialized data sections goes into DRAM, load LMA copy after code */
  .data : AT ( _sidata )
  {
    . = ALIGN(8);
    _sdata = .;        /* create a global symbol at data start */
    *(.data)           /* .data sections */
    *(.data*)          /* .data* sections */
    . = ALIGN(8);
    _edata = .;        /* define a global symbol at data end */
  } >DRAM
  /* Uninitialized data section */
  . = ALIGN(8);
  .bss :
  {
    /* This is used by the startup in order to initialize the .bss secion */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)
 
    . = ALIGN(8);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >DRAM
 
  PROVIDE ( end = _ebss );
  PROVIDE ( _end = _ebss );
 
  /* User_heap_stack section, used to check that there is enough DRAM left */
  ._user_heap :
  {
    . = ALIGN(8);
    . = . + _Min_Heap_Size;
    . = ALIGN(8);
    __HeapLimit = .;
  } >DRAM
  
  /* Initializes stack on the end of block */
  _estack   = ORIGIN(DRAM) + LENGTH(DRAM);
  __StackLimit = _estack - _Min_Stack_Size;
  __RAM_END = _estack;
  
  ._user_stack __StackLimit :
  {
    . = ALIGN(8);
    __stack_start__ = .;
    . += _Min_Stack_Size;
    . = ALIGN(8);
    __stack_end__ = .;
  } >DRAM
  
  ASSERT(__StackLimit >= __HeapLimit, "region DRAM overflowed with stack and heap")
 
  /* Remove information from the standard libraries */
  /DISCARD/ :
  {
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )
  }
}