Skip to content

Commit fa9f5da

Browse files
committed
Merge pull request #141 from arebert/lpc4088
[LPC4088] RAM size fix for ARM_GCC. Added possibility to reserve stack space
2 parents 210cead + e8b09cb commit fa9f5da

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_ARM_STD/sys.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extern "C" {
1111

1212
#include <rt_misc.h>
1313
#include <stdint.h>
14+
#include "sys_helper.h"
1415

1516
extern char Image$$RW_IRAM1$$ZI$$Limit[];
1617

@@ -22,7 +23,7 @@ extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_
2223

2324
struct __initial_stackheap r;
2425
r.heap_base = zi_limit;
25-
r.heap_limit = sp_limit;
26+
r.heap_limit = sp_limit - __reserved_stack_size();
2627
return r;
2728
}
2829

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* mbed Microcontroller Library - stackheap
2+
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
3+
*
4+
*/
5+
6+
#include "sys_helper.h"
7+
8+
/* This function specifies the amount of memory of the internal RAM to
9+
reserve for the stack. The default implementation will reserve 0 bytes
10+
which gives the normal behaviour where the stack and heap share all the
11+
internal RAM.
12+
13+
You can override this function in your code to reserve a number of bytes
14+
for the stack.
15+
*/
16+
extern "C" __attribute__((weak)) uint32_t __reserved_stack_size();
17+
extern "C" __attribute__((weak)) uint32_t __reserved_stack_size() {
18+
return 0; // return 0 to indicate that nothing is reserved
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef SYS_HELPER_H
2+
#define SYS_HELPER_H
3+
4+
#include <stdint.h>
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
uint32_t __reserved_stack_size();
11+
12+
#ifdef __cplusplus
13+
}
14+
#endif
15+
16+
#endif

libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_GCC_ARM/LPC4088.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
MEMORY
55
{
66
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K
7-
RAM (rwx) : ORIGIN = 0x100000E8, LENGTH = (32K - 0xE8)
7+
RAM (rwx) : ORIGIN = 0x100000E8, LENGTH = (64K - 0xE8)
88

99
USB_RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 16K
1010
ETH_RAM(rwx) : ORIGIN = 0x20004000, LENGTH = 16K

workspace_tools/export/uvision4_lpc4088.uvopt.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</DaveTm>
2222

2323
<Target>
24-
<TargetName>mbed NXP LPC1768</TargetName>
24+
<TargetName>mbed NXP LPC4088</TargetName>
2525
<ToolsetNumber>0x4</ToolsetNumber>
2626
<ToolsetName>ARM-ADS</ToolsetName>
2727
<TargetOption>

0 commit comments

Comments
 (0)