Skip to content

Commit 6cbe22d

Browse files
authored
Merge pull request #12623 from toyowata/baremetal_lpc1114
LPC1114: baremetal profile support
2 parents 90a8fef + 58acc4e commit 6cbe22d

File tree

10 files changed

+87
-59
lines changed

10 files changed

+87
-59
lines changed

TESTS/mbed_hal/stack_size_unification/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ extern uint32_t mbed_stack_isr_size;
4545

4646
#define EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE (4096)
4747

48+
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (EXPECTED_MAIN_THREAD_STACK_SIZE + EXPECTED_ISR_STACK_SIZE))
49+
#error [NOT_SUPPORTED] Insufficient stack for staci_size_unification tests
50+
#endif
51+
52+
4853
/* Test sizes of ISR stack, main thread stack, default user thread stack.
4954
*
5055
* On some platforms with lower RAM size (e.g. NUCLEO_F070RB - 16 KB RAM) it is impossible

features/storage/TESTS/blockdevice/heap_block_device/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ using namespace utest::v1;
2828
#define TEST_BLOCK_COUNT 10
2929
#define TEST_ERROR_MASK 16
3030

31+
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= TEST_BLOCK_DEVICE_SIZE)
32+
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
33+
#endif
34+
3135
const struct {
3236
const char *name;
3337
bd_size_t (BlockDevice::*method)() const;

features/storage/TESTS/blockdevice/mbr_block_device/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ using namespace utest::v1;
2727
#define BLOCK_COUNT 16
2828
#define BLOCK_SIZE 512
2929

30+
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
31+
#error [NOT_SUPPORTED] Insufficient heap for mbr block device tests
32+
#endif
33+
3034
HeapBlockDevice bd(BLOCK_COUNT *BLOCK_SIZE, BLOCK_SIZE);
3135

3236
// Testing formatting of master boot record

features/storage/TESTS/blockdevice/util_block_device/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ using namespace utest::v1;
2929
#define BLOCK_COUNT 16
3030
#define BLOCK_SIZE 512
3131

32+
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
33+
#error [NOT_SUPPORTED] Insufficient heap for util block device tests
34+
#endif
35+
3236

3337
// Simple test which read/writes blocks on a sliced block device
3438
void test_slicing()
Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
#! armcc -E
22

3+
#if !defined(MBED_APP_START)
4+
#define MBED_APP_START 0x00000000
5+
#endif
6+
7+
; 32K flash
8+
#if !defined(MBED_APP_SIZE)
9+
#define MBED_APP_SIZE 0x8000
10+
#endif
11+
12+
; 4KB
13+
#if !defined(MBED_RAM_START)
14+
#define MBED_RAM_START 0x10000000
15+
#endif
16+
17+
#if !defined(MBED_RAM_SIZE)
18+
#define MBED_RAM_SIZE 0x00001000
19+
#endif
20+
21+
322
#if !defined(MBED_BOOT_STACK_SIZE)
4-
#define MBED_BOOT_STACK_SIZE 0x400
23+
#define MBED_BOOT_STACK_SIZE 0x400
524
#endif
625

7-
#define Stack_Size MBED_BOOT_STACK_SIZE
26+
; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0
27+
#define VECTOR_SIZE 0xC0
28+
29+
#define RAM_FIXED_SIZE (MBED_BOOT_STACK_SIZE+VECTOR_SIZE)
830

9-
LR_IROM1 0x00000000 0x8000 { ; load region size_region (32k)
10-
ER_IROM1 0x00000000 0x8000 { ; load address = execution address
31+
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
32+
33+
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
1134
*.o (RESET, +First)
1235
*(InRoot$$Sections)
1336
.ANY (+RO)
1437
}
15-
; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0
16-
; 8KB - 0xC0 = 0xF40
17-
RW_IRAM1 0x100000C0 0xF40-Stack_Size {
38+
39+
RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
1840
.ANY (+RW +ZI)
1941
}
20-
ARM_LIB_STACK (0x100000C0+0xF40) EMPTY -Stack_Size { ; stack
42+
43+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
2144
}
22-
}
2345

46+
ARM_LIB_STACK (MBED_RAM_START+MBED_RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; stack
47+
}
48+
}

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/device/TOOLCHAIN_GCC_ARM/TARGET_LPC11XX/LPC1114.ld

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ SECTIONS
4646
.text :
4747
{
4848
KEEP(*(.isr_vector))
49-
*(.text.Reset_Handler)
49+
*(.text.Reset_Handler)
5050
*(.text.SystemInit)
51-
. = 0x200;
51+
. = 0x200;
5252
*(.text*)
5353

5454
KEEP(*(.init))
@@ -95,24 +95,24 @@ SECTIONS
9595

9696
. = ALIGN(8);
9797
/* preinit data */
98-
PROVIDE (__preinit_array_start = .);
98+
PROVIDE_HIDDEN (__preinit_array_start = .);
9999
KEEP(*(.preinit_array))
100-
PROVIDE (__preinit_array_end = .);
100+
PROVIDE_HIDDEN (__preinit_array_end = .);
101101

102102
. = ALIGN(8);
103103
/* init data */
104-
PROVIDE (__init_array_start = .);
104+
PROVIDE_HIDDEN (__init_array_start = .);
105105
KEEP(*(SORT(.init_array.*)))
106106
KEEP(*(.init_array))
107-
PROVIDE (__init_array_end = .);
107+
PROVIDE_HIDDEN (__init_array_end = .);
108108

109109

110110
. = ALIGN(8);
111111
/* finit data */
112-
PROVIDE (__fini_array_start = .);
112+
PROVIDE_HIDDEN (__fini_array_start = .);
113113
KEEP(*(SORT(.fini_array.*)))
114114
KEEP(*(.fini_array))
115-
PROVIDE (__fini_array_end = .);
115+
PROVIDE_HIDDEN (__fini_array_end = .);
116116

117117
. = ALIGN(8);
118118
/* All data end */
@@ -128,7 +128,7 @@ SECTIONS
128128
__bss_end__ = .;
129129
} > RAM
130130

131-
.heap :
131+
.heap (COPY):
132132
{
133133
__end__ = .;
134134
end = __end__;
@@ -140,7 +140,7 @@ SECTIONS
140140
/* .stack_dummy section doesn't contains any symbols. It is only
141141
* used for linker to calculate size of stack sections, and assign
142142
* values to stack symbols later */
143-
.stack_dummy :
143+
.stack_dummy (COPY):
144144
{
145145
*(.stack)
146146
} > RAM

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/device/TOOLCHAIN_GCC_ARM/startup_LPC11xx.S

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,7 @@
4444
aborting compilation, it is not the run time limit:
4545
Heap_Size + Stack_Size = 0x80 + 0x80 = 0x100
4646
*/
47-
.section .stack
48-
.align 3
49-
#ifdef __STACK_SIZE
50-
.equ Stack_Size, __STACK_SIZE
51-
#else
52-
.equ Stack_Size, 0x80
53-
#endif
54-
.globl __StackTop
55-
.globl __StackLimit
56-
__StackLimit:
57-
.space Stack_Size
58-
.size __StackLimit, . - __StackLimit
59-
__StackTop:
60-
.size __StackTop, . - __StackTop
6147

62-
.section .heap
63-
.align 3
64-
#ifdef __HEAP_SIZE
65-
.equ Heap_Size, __HEAP_SIZE
66-
#else
67-
.equ Heap_Size, 0x80
68-
#endif
69-
.globl __HeapBase
70-
.globl __HeapLimit
71-
__HeapBase:
72-
.space Heap_Size
73-
.size __HeapBase, . - __HeapBase
74-
__HeapLimit:
75-
.size __HeapLimit, . - __HeapLimit
76-
7748
.section .isr_vector
7849
.align 2
7950
.globl __isr_vector
@@ -210,7 +181,5 @@ Reset_Handler:
210181
def_irq_default_handler PIOINT2_IRQHandler
211182
def_irq_default_handler PIOINT1_IRQHandler
212183
def_irq_default_handler PIOINT0_IRQHandler
213-
def_irq_default_handler DEF_IRQHandler
214184

215185
.end
216-

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/device/cmsis_nvic.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
6060
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
6161

6262
// Copy and switch to dynamic vectors if first time called
63-
if((LPC_SYSCON->SYSMEMREMAP & 0x3) != 0x1) {
64-
uint32_t *old_vectors = (uint32_t *)0; // FLASH vectors are at 0x0
63+
if((LPC_SYSCON->SYSMEMREMAP & 0x3) != 0x1) {
64+
// Add volatile qualifier to avoid armclang aggressive optimization
65+
volatile uint32_t *old_vectors = (uint32_t *)0; // FLASH vectors are at 0x0
6566
for(i = 0; i < NVIC_NUM_VECTORS; i++) {
6667
vectors[i] = old_vectors[i];
6768
}

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/us_ticker.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
int us_ticker_inited = 0;
2424

2525
void us_ticker_init(void) {
26+
// First, disabled interrupt
27+
US_TICKER_TIMER->MCR &= ~1;
28+
2629
if (us_ticker_inited) return;
2730
us_ticker_inited = 1;
2831

targets/targets.json

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
"LPCTarget"
267267
],
268268
"core": "Cortex-M0",
269-
"default_toolchain": "uARM",
269+
"default_toolchain": "ARM",
270270
"extra_labels": [
271271
"NXP",
272272
"LPC11XX_11CXX",
@@ -278,7 +278,6 @@
278278
],
279279
"supported_toolchains": [
280280
"ARM",
281-
"uARM",
282281
"GCC_ARM",
283282
"IAR"
284283
],
@@ -295,12 +294,26 @@
295294
"SLEEP",
296295
"SPI",
297296
"SPISLAVE",
298-
"STDIO_MESSAGES"
299-
],
300-
"default_lib": "small",
301-
"release_versions": [
302-
"2"
297+
"STDIO_MESSAGES",
298+
"USTICKER"
303299
],
300+
"overrides": {
301+
"tickless-from-us-ticker": true,
302+
"boot-stack-size": "0x300"
303+
},
304+
"supported_c_libs": {
305+
"arm": [
306+
"std", "small"
307+
],
308+
"gcc_arm": [
309+
"std", "small"
310+
],
311+
"iar": [
312+
"std"
313+
]
314+
},
315+
"c_lib": "small",
316+
"supported_application_profiles": ["bare-metal"],
304317
"device_name": "LPC1114FN28/102",
305318
"detect_code": [
306319
"1114"

0 commit comments

Comments
 (0)