2 * Copyright (c) 2019, The OpenThread Authors.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the copyright holder nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
31 * GCC linker script for K32W061.
34 OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
37 * stack size for the boot rom during warm boot and application
38 * 256 is sufficient (pwrm_test) but keep it large to 1024
40 BOOT_RESUME_STACK_SIZE = 1024;
42 /* Set Stack size to 4K minus 32Bytes reserved for ROM code at end of BANK7 so
43 the stack fits in BANK7. In practice the active stack size at the time of
44 going to sleep is more important than the total available stack size */
45 STACK_SIZE = (4096 - 32);
47 MEM_RAM0_BASE = 0x4000400;
48 MEM_RAM0_SIZE = 0x0015c00;
52 /* Define each memory region. RAM0 definition leaves the first 1kB for the
54 Flash640 (rx) : ORIGIN = 0, LENGTH = 0x00a0000 /* 640K bytes (alias Flash) */
55 RAM0 (rwx) : ORIGIN = 0x4000400, LENGTH = 0x0015c00 /* 87K bytes (alias RAM) */
56 RAM1 (rwx) : ORIGIN = 0x4020000, LENGTH = 0x10000 /* 64K bytes (alias RAM2) */
59 /* Define a symbol for the top of each memory region */
60 __top_RAM0 = MEM_RAM0_BASE + MEM_RAM0_SIZE; /* 87K bytes */
62 /* To be improved. At this moment the second RAM bank is dedicated entirely to heap. */
63 HEAP_SIZE = DEFINED(HEAP_SIZE) ? HEAP_SIZE : 0xF000;
65 /*** flash memory characteristics definitions required for OTA ***/
66 m_flash_start = 0x00000000;
67 m_flash_end = 0x0009FFFF;
68 m_flash_size = 0x000A0000;
70 m_fsl_prodInfo_size = m_sector_size;
72 m_fsl_prodInfo_end = m_flash_size - 17 * m_sector_size - 1;
73 m_fsl_prodInfo_start = m_fsl_prodInfo_end - m_fsl_prodInfo_size + 1;
75 NV_STORAGE_MAX_SECTORS = 16;
76 NV_STORAGE_SIZE = NV_STORAGE_MAX_SECTORS * m_sector_size;
77 NV_STORAGE_START_ADDRESS = m_fsl_prodInfo_start - 1;
78 NV_STORAGE_END_ADDRESS = NV_STORAGE_START_ADDRESS - NV_STORAGE_SIZE + 1;
80 INT_STORAGE_END = NV_STORAGE_START_ADDRESS - 1;
81 INT_STORAGE_START = 0x48000;
82 INT_STORAGE_SIZE = INT_STORAGE_END - INT_STORAGE_START;
84 FREESCALE_PROD_DATA_BASE_ADDR = m_fsl_prodInfo_start;
85 INT_STORAGE_SECTOR_SIZE = m_sector_size;
86 m_app_size = 0xA0000; /* 640K: to accommodate all libs in debug */
88 __ram_vector_table__ = 1;
89 vector_table_size = 0x120;
90 M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? vector_table_size : 0x0;
96 /* MAIN TEXT SECTION */
99 _flash_start = ABSOLUTE(.);
100 _flash_beg = ABSOLUTE(.);
103 __vectors_start__ = ABSOLUTE(.) ;
107 /* Global Section Table */
109 __section_table_start = .;
110 __data_section_table = .;
111 LONG(LOADADDR(.data));
113 LONG( SIZEOF(.data));
114 __data_section_table_end = .;
115 __bss_section_table = .;
118 __bss_section_table_end = .;
119 __section_table_end = . ;
120 /* End of Global Section Table */
126 .ro_nonce : ALIGN(0x10)
128 _FlsNonceStart = ABSOLUTE(.);
129 *(.ro_nonce) /* nonce value is 16 bytes.*/
134 .ro_ota_header : ALIGN(0x10)
136 _enc_start = ABSOLUTE(.);
137 _enc_offset = (_enc_start & 0x0000000F);
138 _FlsOtaHeader = ABSOLUTE(.);
139 *(.ro_ota_header) /* Ota Header 69 bytes*/
144 .ro_se_lnkKey (ALIGN((. - _enc_offset), 16) + _enc_offset):
146 _FlsLinkKey = ABSOLUTE(.);
147 *(.ro_se_lnkKey) /* Link Key 16 bytes*/
172 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
179 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
183 *(.rodata .rodata.* .constdata .constdata.*)
188 * for exception handling/unwind - some Newlib functions (in common
189 * with C++ and STDC++) use this.
191 .ARM.extab : ALIGN(4)
194 *(.ARM.extab* .gnu.linkonce.armextab.*)
198 .ARM.exidx : ALIGN(4)
201 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
219 .interrupts_ram : ALIGN(0x200)
223 __interrupts_ram_start__ = .; /* Create a global symbol at data start */
224 *(.m_interrupts_ram) /* This is a user defined section */
225 . += M_VECTOR_RAM_SIZE;
227 __interrupts_ram_end__ = .; /* Define a global symbol at data end */
230 /* MAIN DATA SECTION */
231 .uninit_RESERVED : ALIGN(4)
233 KEEP(*(.bss.$RESERVED*))
235 _end_uninit_RESERVED = .;
238 /* Main DATA section (RAM0) */
249 PROVIDE_HIDDEN (__preinit_array_start = .);
250 KEEP(*(.preinit_array))
251 PROVIDE_HIDDEN (__preinit_array_end = .);
255 __init_array_start = . ;
256 KEEP(*(SORT(.init_array.*)))
258 __init_array_end = . ;
262 PROVIDE_HIDDEN (__fini_array_start = .);
263 KEEP(*(SORT(.fini_array.*)))
265 PROVIDE_HIDDEN (__fini_array_end = .);
273 __VECTOR_RAM = __VECTOR_RAM__;
274 __RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;
276 /* MAIN BSS SECTION */
277 .bss (NOLOAD) : ALIGN(4)
282 *(g_u32NwkFrameCounter)
289 /* BSS section for MAC buffers */
290 .bss_MAC (NOLOAD) : ALIGN(4)
292 /* MAC buffer section: must be within 128kB block. __mac_buffer_base is
293 defined further down to be on 128kB alignment */
294 __mac_buffer_start = .;
297 . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
300 /* DEFAULT NOINIT SECTION */
301 .noinit (NOLOAD): ALIGN(4)
309 /* stack for rom boot during warm resume */
310 .boot_resume_stack (NOLOAD): ALIGN(4)
312 _boot_resume_stack = .;
313 *(.boot_resume_stack*)
314 . += BOOT_RESUME_STACK_SIZE;
316 _end_boot_resume_stack = .;
319 __nv_storage_end_address = NV_STORAGE_END_ADDRESS;
320 __nv_storage_start_address = NV_STORAGE_START_ADDRESS;
322 PROVIDE(_vStackTop = __top_RAM0 - 32);
323 PROVIDE(__mac_buffer_base = (__mac_buffer_start & 0xfffe0000));
324 PROVIDE(BOOT_GetStartPowerMode = 0x03000e9d);
325 PROVIDE(ROM_GetFlash = 0x03000e0d);
326 PROVIDE(pmc_reset_get_cause = 0x030046e9);
327 PROVIDE(psector_ReadIeee802_15_4_MacId1 = 0x030053b1);
328 PROVIDE(Chip_LOWPOWER_ChipSoftwareReset = 0x03003fa1);
330 __StackLimit = _vStackTop - STACK_SIZE;
331 ASSERT(__StackLimit >= _end_boot_resume_stack, "Possible stack corruption with data/bss/boot_stack")