Skip to content

Commit

Permalink
Apollo3: Fix run time error due to memory mapping
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hugueskamba committed Feb 12, 2021
1 parent 3174a4c commit cac9d79
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! armclang -E --target=arm-arm-none-eabi -x c -mcpu=cortex-m4

;
; Copyright (c) 2019-2020 SparkFun Electronics
; Copyright (c) 2019-2021 SparkFun Electronics
; SPDX-License-Identifier: MIT
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -40,7 +40,18 @@
#define MBED_RAM0_SIZE 0x100
#define MBED_RAM1_START (MBED_RAM0_START + MBED_RAM0_SIZE)
#define MBED_RAM1_SIZE (MBED_RAM_SIZE - (MBED_RAM0_SIZE))
; This 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
#define STACK_DUMMY_START (MBED_RAM1_START + MBED_RAM1_SIZE)
#define STACK_DUMMY_SIZE 0x8
#define Stack_Start (STACK_DUMMY_START - STACK_DUMMY_SIZE)
#define Stack_Size MBED_CONF_TARGET_BOOT_STACK_SIZE
; The heap dummy section is used to identify the beginning of available dynamic memory.
#define HEAP_DUMMY_SIZE 0x8
#define Heap_Start AlignExpr(+0, 16)
#define Heap_Size (MBED_RAM_SIZE - RAM_FIXED_SIZE + MBED_RAM1_START - AlignExpr(ImageLimit(RW_IRAM1), 16) - HEAP_DUMMY_SIZE)

#define RAM_FIXED_SIZE (MBED_CONF_TARGET_BOOT_STACK_SIZE+MBED_RAM0_SIZE)


Expand All @@ -56,8 +67,8 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
RW_IRAM1 MBED_RAM1_START MBED_RAM1_SIZE {
.ANY (+RW +ZI)
}
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM1_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
ARM_LIB_HEAP Heap_Start EMPTY Heap_Size { ; Heap region growing up
}
ARM_LIB_STACK MBED_RAM1_START+MBED_RAM1_SIZE EMPTY -Stack_Size { ; Stack region growing down
ARM_LIB_STACK Stack_Start EMPTY -Stack_Size { ; Stack region growing down
}
}

0 comments on commit cac9d79

Please sign in to comment.