1- /* Linker script for mbed LPC1768 */
2- #if !defined(MBED_APP_START)
3- #define MBED_APP_START 0x00000000
4- #endif
5-
6- #if !defined(MBED_APP_SIZE)
7- #define MBED_APP_SIZE 512K
8- #endif
1+ /* mbed Microcontroller Library
2+ * Copyright (c) 2025 Jamie Smith
3+ * SPDX-License-Identifier: Apache-2.0
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ */
17+
18+ #include " ../cmsis_nvic.h"
919
1020#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
1121 #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
1222#endif
1323
1424STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE;
1525
26+ #define VTORS_NEEDED_SPACE NVIC_NUM_VECTORS * 4
27+
1628/* Linker script to configure memory regions. */
1729MEMORY
1830{
19- FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
20- RAM (rwx) : ORIGIN = 0x100000C8 , LENGTH = (32K - 0xC8 - 32 ) /* topmost 32 bytes used by IAP functions */
21-
22- USB_RAM (rwx) : ORIGIN = 0x2007C000 , LENGTH = 16K
23- ETH_RAM (rwx) : ORIGIN = 0x20080000 , LENGTH = 16K
31+ FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE
32+ RAM (rwx) : ORIGIN = MBED_RAM_BANK_IRAM1_START + VTORS_NEEDED_SPACE, LENGTH = (MBED_RAM_BANK_IRAM1_SIZE - VTORS_NEEDED_SPACE - 32 ) /* topmost 32 bytes used by IAP functions */
33+ AHBSRAM (rwx) : ORIGIN = MBED_RAM_BANK_IRAM2_START, LENGTH = MBED_RAM_BANK_IRAM2_SIZE
2434}
2535
2636/* Linker script to place sections and symbol values. Should be used together
@@ -56,9 +66,13 @@ SECTIONS
5666 .text :
5767 {
5868 KEEP (*(.isr_vector ))
59- /* Code Read Protect data */
69+
70+ #if MBED_CONFIGURED_ROM_BANK_IROM1_START == MBED_ROM_BANK_IROM1_START
71+ /* Code Read Protect data, if this is at the start of flash*/
6072 . = 0x000002FC ;
6173 KEEP (*(.CRPSection ))
74+ #endif
75+
6276 /* End of Code Read Protect */
6377 *(.text *)
6478
@@ -144,14 +158,13 @@ SECTIONS
144158 Image$$RW_IRAM1$$ZI$$Limit = . ;
145159 } > RAM
146160
147-
148- .heap (NOLOAD) :
161+ .heap_0 (NOLOAD) : ALIGN (8 )
149162 {
150163 __end__ = .;
151164 end = __end__;
152- *(. heap *)
153- . = ORIGIN (RAM) + LENGTH (RAM) - STACK_SIZE;
154- __HeapLimit = .;
165+ __mbed_sbrk_start_0 = .;
166+ . = ( ORIGIN (RAM) + LENGTH (RAM) - STACK_SIZE) ;
167+ __mbed_krbs_start_0 = .;
155168 } > RAM
156169
157170 /* .stack_dummy section doesn't contains any symbols. It is only
@@ -169,24 +182,23 @@ SECTIONS
169182 PROVIDE (__stack = __StackTop);
170183
171184 /* Check if data + heap + stack exceeds RAM limit */
172- ASSERT (__StackLimit >= __HeapLimit , " region RAM overflowed with stack" )
185+ ASSERT (__StackLimit >= __end__ , " region RAM overflowed with stack" )
173186
174187
175188 /* Code can explicitly ask for data to be
176- placed in these higher RAM banks where
189+ placed in this higher RAM bank where
177190 they will be left uninitialized.
178191 */
179- .AHBSRAM0 (NOLOAD) :
192+ .AHBSRAM_bss (NOLOAD) :
180193 {
181- Image$$RW_IRAM2$$Base = . ;
182- *(AHBSRAM0)
183- Image$$RW_IRAM2$$ZI$$Limit = .;
184- } > USB_RAM
194+ *(AHBSRAM)
195+ } > AHBSRAM
185196
186- .AHBSRAM1 (NOLOAD) :
197+ /* Fill remaining space in AHBSRAM with additional heap */
198+ .heap (NOLOAD) : ALIGN (8 )
187199 {
188- Image$$RW_IRAM3$$Base = . ;
189- *(AHBSRAM1)
190- Image$$RW_IRAM3$$ZI$$Limit = .;
191- } > ETH_RAM
200+ __mbed_sbrk_start = .;
201+ . = ORIGIN (AHBSRAM) + LENGTH (AHBSRAM);
202+ __mbed_krbs_start = .;
203+ } > AHBSRAM
192204}
0 commit comments