Merge pull request #12623 from toyowata/baremetal_lpc1114

LPC1114: baremetal profile support
pull/12981/head
Martin Kojtal 2020-05-15 13:17:52 +02:00 committed by GitHub
commit 6cbe22dc59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 88 additions and 60 deletions

View File

@ -45,6 +45,11 @@ extern uint32_t mbed_stack_isr_size;
#define EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE (4096) #define EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE (4096)
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (EXPECTED_MAIN_THREAD_STACK_SIZE + EXPECTED_ISR_STACK_SIZE))
#error [NOT_SUPPORTED] Insufficient stack for staci_size_unification tests
#endif
/* Test sizes of ISR stack, main thread stack, default user thread stack. /* Test sizes of ISR stack, main thread stack, default user thread stack.
* *
* On some platforms with lower RAM size (e.g. NUCLEO_F070RB - 16 KB RAM) it is impossible * On some platforms with lower RAM size (e.g. NUCLEO_F070RB - 16 KB RAM) it is impossible

View File

@ -28,6 +28,10 @@ using namespace utest::v1;
#define TEST_BLOCK_COUNT 10 #define TEST_BLOCK_COUNT 10
#define TEST_ERROR_MASK 16 #define TEST_ERROR_MASK 16
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= TEST_BLOCK_DEVICE_SIZE)
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
#endif
const struct { const struct {
const char *name; const char *name;
bd_size_t (BlockDevice::*method)() const; bd_size_t (BlockDevice::*method)() const;

View File

@ -27,6 +27,10 @@ using namespace utest::v1;
#define BLOCK_COUNT 16 #define BLOCK_COUNT 16
#define BLOCK_SIZE 512 #define BLOCK_SIZE 512
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
#error [NOT_SUPPORTED] Insufficient heap for mbr block device tests
#endif
HeapBlockDevice bd(BLOCK_COUNT *BLOCK_SIZE, BLOCK_SIZE); HeapBlockDevice bd(BLOCK_COUNT *BLOCK_SIZE, BLOCK_SIZE);
// Testing formatting of master boot record // Testing formatting of master boot record

View File

@ -29,6 +29,10 @@ using namespace utest::v1;
#define BLOCK_COUNT 16 #define BLOCK_COUNT 16
#define BLOCK_SIZE 512 #define BLOCK_SIZE 512
#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
#error [NOT_SUPPORTED] Insufficient heap for util block device tests
#endif
// Simple test which read/writes blocks on a sliced block device // Simple test which read/writes blocks on a sliced block device
void test_slicing() void test_slicing()

View File

@ -1,23 +1,48 @@
#! armcc -E #! armcc -E
#if !defined(MBED_BOOT_STACK_SIZE) #if !defined(MBED_APP_START)
#define MBED_BOOT_STACK_SIZE 0x400 #define MBED_APP_START 0x00000000
#endif #endif
#define Stack_Size MBED_BOOT_STACK_SIZE ; 32K flash
#if !defined(MBED_APP_SIZE)
#define MBED_APP_SIZE 0x8000
#endif
LR_IROM1 0x00000000 0x8000 { ; load region size_region (32k) ; 4KB
ER_IROM1 0x00000000 0x8000 { ; load address = execution address #if !defined(MBED_RAM_START)
#define MBED_RAM_START 0x10000000
#endif
#if !defined(MBED_RAM_SIZE)
#define MBED_RAM_SIZE 0x00001000
#endif
#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#endif
; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0
#define VECTOR_SIZE 0xC0
#define RAM_FIXED_SIZE (MBED_BOOT_STACK_SIZE+VECTOR_SIZE)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
*.o (RESET, +First) *.o (RESET, +First)
*(InRoot$$Sections) *(InRoot$$Sections)
.ANY (+RO) .ANY (+RO)
} }
; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0
; 8KB - 0xC0 = 0xF40 RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
RW_IRAM1 0x100000C0 0xF40-Stack_Size {
.ANY (+RW +ZI) .ANY (+RW +ZI)
} }
ARM_LIB_STACK (0x100000C0+0xF40) EMPTY -Stack_Size { ; stack
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
}
ARM_LIB_STACK (MBED_RAM_START+MBED_RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; stack
} }
} }

View File

@ -46,9 +46,9 @@ SECTIONS
.text : .text :
{ {
KEEP(*(.isr_vector)) KEEP(*(.isr_vector))
*(.text.Reset_Handler) *(.text.Reset_Handler)
*(.text.SystemInit) *(.text.SystemInit)
. = 0x200; . = 0x200;
*(.text*) *(.text*)
KEEP(*(.init)) KEEP(*(.init))
@ -95,24 +95,24 @@ SECTIONS
. = ALIGN(8); . = ALIGN(8);
/* preinit data */ /* preinit data */
PROVIDE (__preinit_array_start = .); PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array)) KEEP(*(.preinit_array))
PROVIDE (__preinit_array_end = .); PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(8); . = ALIGN(8);
/* init data */ /* init data */
PROVIDE (__init_array_start = .); PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*))) KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array)) KEEP(*(.init_array))
PROVIDE (__init_array_end = .); PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(8); . = ALIGN(8);
/* finit data */ /* finit data */
PROVIDE (__fini_array_start = .); PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*))) KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array)) KEEP(*(.fini_array))
PROVIDE (__fini_array_end = .); PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(8); . = ALIGN(8);
/* All data end */ /* All data end */
@ -128,7 +128,7 @@ SECTIONS
__bss_end__ = .; __bss_end__ = .;
} > RAM } > RAM
.heap : .heap (COPY):
{ {
__end__ = .; __end__ = .;
end = __end__; end = __end__;
@ -140,7 +140,7 @@ SECTIONS
/* .stack_dummy section doesn't contains any symbols. It is only /* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign * used for linker to calculate size of stack sections, and assign
* values to stack symbols later */ * values to stack symbols later */
.stack_dummy : .stack_dummy (COPY):
{ {
*(.stack) *(.stack)
} > RAM } > RAM

View File

@ -44,36 +44,7 @@
aborting compilation, it is not the run time limit: aborting compilation, it is not the run time limit:
Heap_Size + Stack_Size = 0x80 + 0x80 = 0x100 Heap_Size + Stack_Size = 0x80 + 0x80 = 0x100
*/ */
.section .stack
.align 3
#ifdef __STACK_SIZE
.equ Stack_Size, __STACK_SIZE
#else
.equ Stack_Size, 0x80
#endif
.globl __StackTop
.globl __StackLimit
__StackLimit:
.space Stack_Size
.size __StackLimit, . - __StackLimit
__StackTop:
.size __StackTop, . - __StackTop
.section .heap
.align 3
#ifdef __HEAP_SIZE
.equ Heap_Size, __HEAP_SIZE
#else
.equ Heap_Size, 0x80
#endif
.globl __HeapBase
.globl __HeapLimit
__HeapBase:
.space Heap_Size
.size __HeapBase, . - __HeapBase
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
.section .isr_vector .section .isr_vector
.align 2 .align 2
.globl __isr_vector .globl __isr_vector
@ -210,7 +181,5 @@ Reset_Handler:
def_irq_default_handler PIOINT2_IRQHandler def_irq_default_handler PIOINT2_IRQHandler
def_irq_default_handler PIOINT1_IRQHandler def_irq_default_handler PIOINT1_IRQHandler
def_irq_default_handler PIOINT0_IRQHandler def_irq_default_handler PIOINT0_IRQHandler
def_irq_default_handler DEF_IRQHandler
.end .end

View File

@ -60,8 +60,9 @@ void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
// Copy and switch to dynamic vectors if first time called // Copy and switch to dynamic vectors if first time called
if((LPC_SYSCON->SYSMEMREMAP & 0x3) != 0x1) { if((LPC_SYSCON->SYSMEMREMAP & 0x3) != 0x1) {
uint32_t *old_vectors = (uint32_t *)0; // FLASH vectors are at 0x0 // Add volatile qualifier to avoid armclang aggressive optimization
volatile uint32_t *old_vectors = (uint32_t *)0; // FLASH vectors are at 0x0
for(i = 0; i < NVIC_NUM_VECTORS; i++) { for(i = 0; i < NVIC_NUM_VECTORS; i++) {
vectors[i] = old_vectors[i]; vectors[i] = old_vectors[i];
} }

View File

@ -23,6 +23,9 @@
int us_ticker_inited = 0; int us_ticker_inited = 0;
void us_ticker_init(void) { void us_ticker_init(void) {
// First, disabled interrupt
US_TICKER_TIMER->MCR &= ~1;
if (us_ticker_inited) return; if (us_ticker_inited) return;
us_ticker_inited = 1; us_ticker_inited = 1;

View File

@ -266,7 +266,7 @@
"LPCTarget" "LPCTarget"
], ],
"core": "Cortex-M0", "core": "Cortex-M0",
"default_toolchain": "uARM", "default_toolchain": "ARM",
"extra_labels": [ "extra_labels": [
"NXP", "NXP",
"LPC11XX_11CXX", "LPC11XX_11CXX",
@ -278,7 +278,6 @@
], ],
"supported_toolchains": [ "supported_toolchains": [
"ARM", "ARM",
"uARM",
"GCC_ARM", "GCC_ARM",
"IAR" "IAR"
], ],
@ -295,12 +294,26 @@
"SLEEP", "SLEEP",
"SPI", "SPI",
"SPISLAVE", "SPISLAVE",
"STDIO_MESSAGES" "STDIO_MESSAGES",
], "USTICKER"
"default_lib": "small",
"release_versions": [
"2"
], ],
"overrides": {
"tickless-from-us-ticker": true,
"boot-stack-size": "0x300"
},
"supported_c_libs": {
"arm": [
"std", "small"
],
"gcc_arm": [
"std", "small"
],
"iar": [
"std"
]
},
"c_lib": "small",
"supported_application_profiles": ["bare-metal"],
"device_name": "LPC1114FN28/102", "device_name": "LPC1114FN28/102",
"detect_code": [ "detect_code": [
"1114" "1114"