Skip to content

Commit 1ca4b1a

Browse files
committed
NXP: Fix heap size formula in scatter files
The heap size was incorrectly calculated. This fixes it by subtracting the Stack size, any memory chunks allocated before the start of the application (for vectors and/or crash report), and finally the size of the application from the total RAM size.
1 parent e917282 commit 1ca4b1a

File tree

3 files changed

+12
-6
lines changed
  • targets
    • TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/device/TOOLCHAIN_ARM_MICRO
    • TARGET_NXP
      • TARGET_LPC11XX_11CXX/device/TOOLCHAIN_ARM_STD/TARGET_LPC11XX
      • TARGET_LPC176X/device/TOOLCHAIN_ARM_STD

3 files changed

+12
-6
lines changed

targets/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/device/TOOLCHAIN_ARM_MICRO/MKL25Z4.sct

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define MBED_RAM_SIZE 0x4000
1717
#endif
1818

19+
#define MBED_RAM1_START (MBED_RAM_START+VECTOR_SIZE)
20+
1921

2022
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
2123
# if defined(MBED_BOOT_STACK_SIZE)
@@ -38,11 +40,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
3840
.ANY (+RO)
3941
}
4042

41-
RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
43+
RW_IRAM1 MBED_RAM1_START (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
4244
.ANY (+RW +ZI)
4345
}
4446

45-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
47+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM1_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
4648
}
4749

4850
ARM_LIB_STACK (MBED_RAM_START+MBED_RAM_SIZE) EMPTY -MBED_CONF_TARGET_BOOT_STACK_SIZE { ; stack

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/device/TOOLCHAIN_ARM_STD/TARGET_LPC11XX/LPC1114.sct

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#define RAM_FIXED_SIZE (MBED_CONF_TARGET_BOOT_STACK_SIZE+VECTOR_SIZE)
3434

35+
#define MBED_RAM1_START (MBED_RAM_START+VECTOR_SIZE)
36+
3537
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
3638

3739
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
@@ -40,11 +42,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
4042
.ANY (+RO)
4143
}
4244

43-
RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
45+
RW_IRAM1 MBED_RAM1_START (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
4446
.ANY (+RW +ZI)
4547
}
4648

47-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
49+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM1_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
4850
}
4951

5052
ARM_LIB_STACK (MBED_RAM_START+MBED_RAM_SIZE) EMPTY -MBED_CONF_TARGET_BOOT_STACK_SIZE { ; stack

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#define RAM_FIXED_SIZE (MBED_CONF_TARGET_BOOT_STACK_SIZE+VECTOR_SIZE+0x20)
3434

35+
#define MBED_RAM1_START (MBED_RAM_START+VECTOR_SIZE)
36+
3537
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
3638

3739
ER_IROM0 MBED_APP_START 0x2FC { ; load address = execution address
@@ -49,11 +51,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
4951
}
5052

5153
; 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18
52-
RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE-0x20) { ; RW data
54+
RW_IRAM1 MBED_RAM1_START (MBED_RAM_SIZE-VECTOR_SIZE-0x20) { ; RW data
5355
.ANY (+RW +ZI)
5456
}
5557

56-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
58+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM1_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
5759
}
5860

5961
RW_IRAM2 0x2007C000 0x4000 { ; RW data, USB RAM

0 commit comments

Comments
 (0)