Skip to content

Commit cac9d79

Browse files
committed
Apollo3: Fix run time error due to memory mapping
The Appollo3 targets require dummy sections in stack and heap regions. The stack dummy section does not contain any symbols. It is only used for the linker to calculate the size of the stack sections and assign values to stack symbols later. The heap dummy region is used to identify the beginning of available dynamic memory.
1 parent 3174a4c commit cac9d79

File tree

1 file changed

+14
-3
lines changed
  • targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TOOLCHAIN_ARM_STD

1 file changed

+14
-3
lines changed

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TOOLCHAIN_ARM_STD/AMA3B1KK.sct

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! armclang -E --target=arm-arm-none-eabi -x c -mcpu=cortex-m4
22

33
;
4-
; Copyright (c) 2019-2020 SparkFun Electronics
4+
; Copyright (c) 2019-2021 SparkFun Electronics
55
; SPDX-License-Identifier: MIT
66
;
77
; Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -40,7 +40,18 @@
4040
#define MBED_RAM0_SIZE 0x100
4141
#define MBED_RAM1_START (MBED_RAM0_START + MBED_RAM0_SIZE)
4242
#define MBED_RAM1_SIZE (MBED_RAM_SIZE - (MBED_RAM0_SIZE))
43+
; This section does not contain any symbols. It is only used for the linker
44+
; to calculate the size of the stack sections and assign values to stack
45+
; symbols later
46+
#define STACK_DUMMY_START (MBED_RAM1_START + MBED_RAM1_SIZE)
47+
#define STACK_DUMMY_SIZE 0x8
48+
#define Stack_Start (STACK_DUMMY_START - STACK_DUMMY_SIZE)
4349
#define Stack_Size MBED_CONF_TARGET_BOOT_STACK_SIZE
50+
; The heap dummy section is used to identify the beginning of available dynamic memory.
51+
#define HEAP_DUMMY_SIZE 0x8
52+
#define Heap_Start AlignExpr(+0, 16)
53+
#define Heap_Size (MBED_RAM_SIZE - RAM_FIXED_SIZE + MBED_RAM1_START - AlignExpr(ImageLimit(RW_IRAM1), 16) - HEAP_DUMMY_SIZE)
54+
4455
#define RAM_FIXED_SIZE (MBED_CONF_TARGET_BOOT_STACK_SIZE+MBED_RAM0_SIZE)
4556

4657

@@ -56,8 +67,8 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
5667
RW_IRAM1 MBED_RAM1_START MBED_RAM1_SIZE {
5768
.ANY (+RW +ZI)
5869
}
59-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM1_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
70+
ARM_LIB_HEAP Heap_Start EMPTY Heap_Size { ; Heap region growing up
6071
}
61-
ARM_LIB_STACK MBED_RAM1_START+MBED_RAM1_SIZE EMPTY -Stack_Size { ; Stack region growing down
72+
ARM_LIB_STACK Stack_Start EMPTY -Stack_Size { ; Stack region growing down
6273
}
6374
}

0 commit comments

Comments
 (0)