generated from calebmarting/BlueNRG-1-VSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlueNRG1.ld
384 lines (327 loc) · 12.2 KB
/
BlueNRG1.ld
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/*******************************************************************************
* BlueNRG-1 generic linker file for ATOLLIC
* Main linker variables to control it are:
*
* MEMORY_FLASH_APP_SIZE: define the size of the application in case not all the flash is needed.
* Default value is: 156KB when no OTA firmware upgrade is supported
*
* MEMORY_FLASH_APP_OFFSET: define the offset of the application.
* Default value is: 0 offset
*
* MEMORY_RAM_APP_OFFSET: define the offset in RAM from which sections can be
* allocated.
* Default value is: 0x02CC
*
* ST_OTA_HIGHER_APPLICATION: When defined application is built for OTA support
* in the higher part of memory
*
* ST_OTA_LOWER_APPLICATION: When defined application is built for OTA support
* in the lower part of memory
*
* ST_USE_OTA_SERVICE_MANAGER_APPLICATION: When defined application is built for
* OTA firmware upgrade support with separated application for firmware upgrade
*
*******************************************************************************/
/*******************************************************************************
* Memory Definitions
*******************************************************************************/
/*
BlueNRG-1 memory map
+-----------------------+ 0x20005FFF
| RAM (24K) |
+-----------------------+ 0x20000000
| |
| |
+-----------------------+ 0x10067FFF
| |
| FLASH (160K) |
+-----------------------+ 0x10040000
| |
+-----------------------| 0x100007FF
| ROM (2K) |
+-----------------------+ 0x10000000
*/
_MEMORY_RAM_BEGIN_ = 0x20000000;
_MEMORY_RAM_SIZE_ = 0x6000; /* 24KB */
_MEMORY_RAM_END_ = 0x20005FFF;
_MEMORY_FLASH_BEGIN_ = 0x10040000;
_MEMORY_FLASH_SIZE_ = 0x28000; /* 160KB */
_MEMORY_FLASH_END_ = 0x10067FFF;
_MEMORY_ROM_BEGIN_ = 0x10000000;
_MEMORY_ROM_SIZE_ = 0x800; /* 2KB */
_MEMORY_ROM_END_ = 0x100007FF;
/* Reserved for BTLE stack non volatile memory */
FLASH_NVM_DATASIZE = (4*1024);
/* This configuration is intended for application not supporting OTA firmware upgrade */
/*
BlueNRG-1 standard application memory map
+-----------------------+ 0x20005FFF
| RAM (24K) |
+-----------------------+ 0x20000000
| |
| |
+-----------------------+ 0x10068000
| |
| NVM(4K) |
+-----------------------+ 0x10067000
| |
| User app (156K) |
+-----------------------+ 0x10040000
| |
+-----------------------| 0x100007FF
| ROM (2K) |
+-----------------------+ 0x10000000
*/
MEMORY_FLASH_APP_OFFSET = DEFINED(MEMORY_FLASH_APP_OFFSET) ? (MEMORY_FLASH_APP_OFFSET) : (0) ;
MEMORY_FLASH_APP_SIZE = DEFINED(MEMORY_FLASH_APP_SIZE) ? (MEMORY_FLASH_APP_SIZE) : ( _MEMORY_FLASH_SIZE_ - FLASH_NVM_DATASIZE - MEMORY_FLASH_APP_OFFSET);
MEMORY_RAM_APP_OFFSET = DEFINED(MEMORY_RAM_APP_OFFSET) ? (MEMORY_RAM_APP_OFFSET) : (0x2CC) ;
RESET_MANAGER_SIZE = DEFINED(RESET_MANAGER_SIZE) ? RESET_MANAGER_SIZE : 0x800 ;
/*
*****************************
* ST_OTA_HIGHER_APPLICATION *
*****************************
*/
/* This configuration is intended for application supporting OTA firmware upgrade with 2-app scheme (app in the upper part of memory map) */
/*
BlueNRG-1 OTA firmware upgrade support for higher application memory map
+-----------------------+ 0x20005FFF
| RAM (24K-4) |
+-----------------------+ 0x20000004
| |
| |
+-----------------------+ 0x10068000
| |
| NVM(4K) |
+-----------------------+ 0x10066800
| |
| Higher app (76K) |
+-----------------------+ 0x10053800
| |
| Lower app (76K) |
+-----------------------| 0x10040800
| Reset Manager (2K) |
+-----------------------+ 0x10040000
| |
+-----------------------| 0x100007FF
| ROM (2K) |
+-----------------------+ 0x10000000
*/
MEMORY_FLASH_APP_SIZE = DEFINED(ST_OTA_HIGHER_APPLICATION) ? (((_MEMORY_FLASH_SIZE_ - RESET_MANAGER_SIZE - FLASH_NVM_DATASIZE) / 2) / 2048) * 2048 : MEMORY_FLASH_APP_SIZE ;
MEMORY_FLASH_APP_OFFSET = DEFINED(ST_OTA_HIGHER_APPLICATION) ? (RESET_MANAGER_SIZE + MEMORY_FLASH_APP_SIZE) : MEMORY_FLASH_APP_OFFSET ;
/*
*****************************
* ST_OTA_LOWER_APPLICATION *
*****************************
*/
/* This configuration is intended for application supporting OTA firmware upgrade with 2-app scheme (app in the lower part of memory map) */
/*
BlueNRG-1 OTA firmware upgrade support for lower application memory map
+-----------------------+ 0x20005FFF
| RAM (24K-4) |
+-----------------------+ 0x20000004
| |
| |
+-----------------------+ 0x10068000
| |
| NVM(4K) |
+-----------------------+ 0x10066800
| |
| Higher app (76K) |
+-----------------------+ 0x10053800
| |
| Lower app (76K) |
+-----------------------| 0x10040800
| Reset Manager (2K) |
+-----------------------+ 0x10040000
| |
+-----------------------| 0x100007FF
| ROM (2K) |
+-----------------------+ 0x10000000
*/
MEMORY_FLASH_APP_SIZE = DEFINED(ST_OTA_LOWER_APPLICATION) ? (((_MEMORY_FLASH_SIZE_ - RESET_MANAGER_SIZE - FLASH_NVM_DATASIZE) / 2) / 2048) * 2048 : MEMORY_FLASH_APP_SIZE ;
MEMORY_FLASH_APP_OFFSET = DEFINED(ST_OTA_LOWER_APPLICATION) ? (RESET_MANAGER_SIZE) : MEMORY_FLASH_APP_OFFSET ;
/*
******************************************
* ST_USE_OTA_SERVICE_MANAGER_APPLICATION *
******************************************
*/
/* This configuration is intended for application supporting OTA firmware upgrade with independent OTA firmware upgrade service manager
(app in the upper part of memory map) */
/*
BlueNRG-1 OTA firmware upgrade support for service manager application memory map
+-----------------------+ 0x20005FFF
| RAM (24K-4) |
+-----------------------+ 0x20000004
| |
| |
+-----------------------+ 0x10068000
| |
| NVM(4K) |
+-----------------------+ 0x10067000
| |
| User app (88K) |
+-----------------------+ 0x10051000
| OTA Service |
| Manager (68K) |
+-----------------------+ 0x10040000
| |
+-----------------------| 0x100007FF
| ROM (2K) |
+-----------------------+ 0x10000000
*/
SERVICE_MANAGER_SIZE = 0x11000;
MEMORY_FLASH_APP_SIZE = DEFINED(ST_USE_OTA_SERVICE_MANAGER_APPLICATION) ? (_MEMORY_FLASH_SIZE_ - SERVICE_MANAGER_SIZE - FLASH_NVM_DATASIZE) : MEMORY_FLASH_APP_SIZE ;
MEMORY_FLASH_APP_OFFSET = DEFINED(ST_USE_OTA_SERVICE_MANAGER_APPLICATION) ? (SERVICE_MANAGER_SIZE) : MEMORY_FLASH_APP_OFFSET ;
/* Entry Point */
ENTRY(RESET_HANDLER)
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x0; /* required amount of heap */
_Min_Stack_Size = 0xC00; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
REGION_RAM (xrw) : ORIGIN = _MEMORY_RAM_BEGIN_, LENGTH = _MEMORY_RAM_SIZE_
REGION_FLASH_BOOTLOADER (rx) : ORIGIN = _MEMORY_FLASH_BEGIN_, LENGTH = MEMORY_FLASH_APP_OFFSET
REGION_FLASH (rx) : ORIGIN = _MEMORY_FLASH_BEGIN_ + MEMORY_FLASH_APP_OFFSET, LENGTH = MEMORY_FLASH_APP_SIZE
REGION_NVM (rx) : ORIGIN = _MEMORY_FLASH_END_ + 1 - FLASH_NVM_DATASIZE, LENGTH = FLASH_NVM_DATASIZE
REGION_ROM (rx) : ORIGIN = _MEMORY_ROM_BEGIN_, LENGTH = _MEMORY_ROM_SIZE_
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.bootloader (ORIGIN(REGION_FLASH_BOOTLOADER)) :
{
. = ALIGN(4);
KEEP(*(.bootloader)) /* Startup code */
. = ALIGN(4);
} >REGION_FLASH_BOOTLOADER
/* The startup code goes first into FLASH */
.intvec (ORIGIN(REGION_FLASH)) :
{
. = ALIGN(4);
KEEP(*(.intvec)) /* Startup code */
. = ALIGN(4);
} >REGION_FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
KEEP(*(.cmd_call_table))
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(i.*) /* i.* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.constdata)
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
. = ALIGN(4);
_etext = .;
} >REGION_FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* used by the startup to initialize data */
_sidata2 = LOADADDR(.ram_preamble);
/* RAM preamble no init */
.ram_preamble_noinit 0x20000000 (NOLOAD) :
{
. = ALIGN(4);
. = 0x04 ; /* There is a waste of RAM here */
KEEP(*(.ota_sw_activation))
} >REGION_RAM
/* RAM preamble initialized */
.ram_preamble 0x20000008 /*(NOLOAD)*/ :
{
_sdata2 = .; /* create a global symbol at data start */
/* This is used by the startup in order to initialize the .bss section */
KEEP(*(.savedMSP))
. = 0x04 ;
KEEP(*(.wakeupFromSleepFlag))
. = 0x08 ;
KEEP(*(.app_base))
. = 0x0C ;
KEEP(*(.flash_sw_lock))
. = 0x10;
KEEP(*(.rfTimeout))
. = 0x14 ;
KEEP(*(.BOR_config))
. = 0x28 ;
KEEP(*(.__blueflag_RAM))
_edata2 = .; /* create a global symbol at data end (.__crash_RAM is skipped since it must not be initialized) */
} >REGION_RAM AT> REGION_FLASH
/* RAM preamble no init */
.ram_preamble_noinit2 0x20000034 (NOLOAD) :
{
KEEP(*(.__crash_RAM))
} >REGION_RAM
/* Uninitialized data section */
.bss.blueRAM 0x200000C0 :
{
. = ALIGN(4);
_sbssblue = .; /* define a global symbol at .bss.blueRAM start */
KEEP(*(.bss.__blue_RAM))
. = ALIGN(4);
_ebssblue = .; /* define a global symbol at .bss.blueRAM end */
. = 0x20c + MEMORY_RAM_APP_OFFSET - 0x2cc;
} >REGION_RAM
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start */
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
} >REGION_RAM
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >REGION_RAM AT> REGION_FLASH
/* Data section that will not be initialized to any value. */
.noinit (NOLOAD):
{
. = ALIGN(4);
*(.noinit)
. = ALIGN(4);
} >REGION_RAM
/**
* Last two sectors of FLASH are reserved for BLE Stack. The BLE Host
* stores its security database and other non-volatile information in this area.
* The linker needs to make sure this area is left empty.
*/
BLOCK_STACKLIB_FLASH_DATA (_MEMORY_FLASH_END_ - FLASH_NVM_DATASIZE + 1) (NOLOAD) :
{
. = ALIGN(2048);
KEEP(*(.noinit.stacklib_flash_data))
KEEP(*(.noinit.stacklib_stored_device_id_data))
} >REGION_NVM
/* This is to emulate place at end of IAR linker */
CSTACK (ORIGIN(REGION_RAM) + LENGTH(REGION_RAM) - _Min_Stack_Size) (NOLOAD) :
{
. = ALIGN(4);
_estack = . + _Min_Stack_Size; /* define a global symbol at bss end */
. = ALIGN(4);
} > REGION_RAM
.rom_info (NOLOAD) :
{
. = ALIGN(4);
KEEP(*(.rom_info))
. = ALIGN(4);
} >REGION_ROM
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}