diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/LPC2368.ld b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/LPC2368.ld index 8d93d6e9d3..d632d65b40 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/LPC2368.ld +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/LPC2368.ld @@ -48,7 +48,7 @@ SECTIONS .text : { __privileged_code_start__ = . ; KEEP( *( .vectors ) ) - *( .privileged_code ) + KEEP( *( .privileged_code ) ) __privileged_code_end__ = .; @@ -142,6 +142,7 @@ SECTIONS /* Heap starts here and grows up in memory */ . = ALIGN( 8 ) ; __heap_start__ = . ; + end = . ; .stab 0 (NOLOAD) : { *(.stab) } .stabstr 0 (NOLOAD) : { *(.stabstr) } diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_functions.s b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_functions.s index 0751c50591..8b4eba394d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_functions.s +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_functions.s @@ -1,180 +1,149 @@ -# 1 "vector_functions.s" -# 1 "" -# 1 "" -# 1 "vector_functions.s" -; -; -; +/* .include "vector_defns.h" */ -# 1 "vector_defns.h" 1 -# 6 "vector_functions.s" 2 + + +.section .plivileged_code, "ax" +.arm + + +.weak __mbed_fiq +.weak __mbed_undef +.weak __mbed_prefetch_abort +.weak __mbed_data_abort +.weak __mbed_irq +.weak __mbed_swi +.weak __mbed_dcc_irq +.weak __mbed_reset +.global __mbed_init_realmonitor +/* .global __mbed_init */ - - - .section VECFUNCS, "ax" - .arm - - - .weak __mbed_fiq - .weak __mbed_undef - .weak __mbed_prefetch_abort - .weak __mbed_data_abort - .weak __mbed_irq - .weak __mbed_swi - .weak __mbed_dcc_irq - .weak __mbed_reset - .global __mbed_init_realmonitor - .global __mbed_init - -; -; __mbed_fiq: B __mbed_fiq - -; -; __mbed_undef: LDR PC, =0x7fffffa0 - -; -; __mbed_prefetch_abort: LDR PC, =0x7fffffb0 - -; -; __mbed_data_abort: LDR PC, =0x7fffffc0 - -; -; -; -; -; -; -; -; -; __mbed_irq: - ; MSR CPSR_c, #0x1F|0x80|0x40 - - ; + STMDB sp!, {r0-r3,r12,lr} - - ; + MOV r0, #0xFFFFFF00 LDR r0, [r0] - - ; + MOV lr, pc BX r0 - - ; + MOV r0, #0xFFFFFF00 - STR r0, [r0] ; - - ; + STR r0, [r0] + LDMFD sp!,{r0-r3,r12,lr} - - ; + MSR CPSR_c, #0x12|0x80|0x40 - - ; + SUBS pc, lr, #4 - -; -; -; -; __mbed_swi: - ; - ; STMFD sp!, {a4, r4, ip, lr} - - ; + LDR r4, =0x40000040 - - ; - ; + LDR a4, =0x00940000 LDR PC, =0x7ffff820 - -; -; -; -; __mbed_dcc_irq: - - ; - - ; LDMFD sp!,{r0-r3,r12,lr} - - ; + MSR CPSR_c, #0x12|0x80|0x40 - - ; - - ; - SUB lr, lr, #4 ; - STMFD sp!, {ip,lr} ; - - ; + + SUB lr, lr, #4 + STMFD sp!, {ip,lr} + LDR LR, =0xfffff000 STR LR, [LR, #0xf00] - - ; - ; - ; - ; + LDR PC, =0x7fffffe0 +/* + __mbed_reset is called after reset + we setup the stacks and realmonitor, then call Reset_Handler like on M3 +*/ + +.section .text, "ax" +.arm +.global Reset_handler +Reset_Handler: + .extern __libc_init_array + .extern SystemInit + .extern __wrap_main + LDR R0, =SystemInit + MOV LR, PC + BX R0 + + LDR R0, =__libc_init_array + MOV LR, PC + BX R0 + + LDR R0, =__wrap_main + BX R0 -; -; __mbed_reset: - - ; - - LDR R0, =(0x40000000 + 0x8000) - - ; + LDR R0, =( __SRAM_segment_end__ ) + MSR CPSR_c, #0x1B|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x17|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x11|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000000 - - ; + MSR CPSR_c, #0x12|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x13|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x10 MOV SP, R0 + +/* Relocate .data section (Copy from ROM to RAM) */ + LDR R1, =__text_end__ /* _etext */ + LDR R2, =__data_start__ /* _data */ + LDR R3, =__data_end__ /* _edata */ + CMP R2, R3 + BEQ DataIsEmpty +LoopRel: CMP R2, R3 + LDRLO R0, [R1], #4 + STRLO R0, [R2], #4 + BLO LoopRel +DataIsEmpty: - ; +/* Clear .bss section (Zero init) */ + MOV R0, #0 + LDR R1, =__bss_start__ + LDR R2, =__bss_end__ + CMP R1,R2 + BEQ BSSIsEmpty +LoopZI: CMP R1, R2 + STRLO R0, [R1], #4 + BLO LoopZI +BSSIsEmpty: + + +/* Init realmonitor */ LDR R0, =__mbed_init_realmonitor MOV LR, PC BX R0 - - ; - LDR R0, =__mbed_init + +/* Go to Reset_Handler */ + LDR R0, =Reset_Handler BX R0 diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_table.s b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_table.s index 281e7a9bd4..d797c3794d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_table.s +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_table.s @@ -18,7 +18,7 @@ - .section VECTOR_TABLE, "ax" + .section .vectors, "ax" .arm @@ -34,7 +34,7 @@ ; -__main: +_start: LDR PC, =__mbed_reset LDR PC, =__mbed_undef LDR PC, =__mbed_swi diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/LPC2368.ld b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/LPC2368.ld index a30d07bbb6..007b1d6a1d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/LPC2368.ld +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/LPC2368.ld @@ -2,7 +2,7 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(vectors) -GROUP(-lsupc++ -lm -lc -lgcc) +GROUP( libgcc.a libc.a libm.a libcr_newlib_nohost.a crti.o crtn.o crtbegin.o crtend.o ) /* Memory Definitions: */ MEMORY @@ -50,7 +50,7 @@ SECTIONS .text : { __privileged_code_start__ = . ; KEEP( *( .vectors ) ) - *( .privileged_code ) + KEEP( *( .privileged_code ) ) __privileged_code_end__ = .; @@ -144,6 +144,8 @@ SECTIONS /* Heap starts here and grows up in memory */ . = ALIGN( 8 ) ; __heap_start__ = . ; + _pvHeapStart = . ; + end = . ; .stab 0 (NOLOAD) : { *(.stab) } .stabstr 0 (NOLOAD) : { *(.stabstr) } diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_functions.s b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_functions.s index 0751c50591..8b4eba394d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_functions.s +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_functions.s @@ -1,180 +1,149 @@ -# 1 "vector_functions.s" -# 1 "" -# 1 "" -# 1 "vector_functions.s" -; -; -; +/* .include "vector_defns.h" */ -# 1 "vector_defns.h" 1 -# 6 "vector_functions.s" 2 + + +.section .plivileged_code, "ax" +.arm + + +.weak __mbed_fiq +.weak __mbed_undef +.weak __mbed_prefetch_abort +.weak __mbed_data_abort +.weak __mbed_irq +.weak __mbed_swi +.weak __mbed_dcc_irq +.weak __mbed_reset +.global __mbed_init_realmonitor +/* .global __mbed_init */ - - - .section VECFUNCS, "ax" - .arm - - - .weak __mbed_fiq - .weak __mbed_undef - .weak __mbed_prefetch_abort - .weak __mbed_data_abort - .weak __mbed_irq - .weak __mbed_swi - .weak __mbed_dcc_irq - .weak __mbed_reset - .global __mbed_init_realmonitor - .global __mbed_init - -; -; __mbed_fiq: B __mbed_fiq - -; -; __mbed_undef: LDR PC, =0x7fffffa0 - -; -; __mbed_prefetch_abort: LDR PC, =0x7fffffb0 - -; -; __mbed_data_abort: LDR PC, =0x7fffffc0 - -; -; -; -; -; -; -; -; -; __mbed_irq: - ; MSR CPSR_c, #0x1F|0x80|0x40 - - ; + STMDB sp!, {r0-r3,r12,lr} - - ; + MOV r0, #0xFFFFFF00 LDR r0, [r0] - - ; + MOV lr, pc BX r0 - - ; + MOV r0, #0xFFFFFF00 - STR r0, [r0] ; - - ; + STR r0, [r0] + LDMFD sp!,{r0-r3,r12,lr} - - ; + MSR CPSR_c, #0x12|0x80|0x40 - - ; + SUBS pc, lr, #4 - -; -; -; -; __mbed_swi: - ; - ; STMFD sp!, {a4, r4, ip, lr} - - ; + LDR r4, =0x40000040 - - ; - ; + LDR a4, =0x00940000 LDR PC, =0x7ffff820 - -; -; -; -; __mbed_dcc_irq: - - ; - - ; LDMFD sp!,{r0-r3,r12,lr} - - ; + MSR CPSR_c, #0x12|0x80|0x40 - - ; - - ; - SUB lr, lr, #4 ; - STMFD sp!, {ip,lr} ; - - ; + + SUB lr, lr, #4 + STMFD sp!, {ip,lr} + LDR LR, =0xfffff000 STR LR, [LR, #0xf00] - - ; - ; - ; - ; + LDR PC, =0x7fffffe0 +/* + __mbed_reset is called after reset + we setup the stacks and realmonitor, then call Reset_Handler like on M3 +*/ + +.section .text, "ax" +.arm +.global Reset_handler +Reset_Handler: + .extern __libc_init_array + .extern SystemInit + .extern __wrap_main + LDR R0, =SystemInit + MOV LR, PC + BX R0 + + LDR R0, =__libc_init_array + MOV LR, PC + BX R0 + + LDR R0, =__wrap_main + BX R0 -; -; __mbed_reset: - - ; - - LDR R0, =(0x40000000 + 0x8000) - - ; + LDR R0, =( __SRAM_segment_end__ ) + MSR CPSR_c, #0x1B|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x17|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x11|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000000 - - ; + MSR CPSR_c, #0x12|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x13|0x80|0x40 MOV SP, R0 SUB R0, R0, #0x00000040 - - ; + MSR CPSR_c, #0x10 MOV SP, R0 + +/* Relocate .data section (Copy from ROM to RAM) */ + LDR R1, =__text_end__ /* _etext */ + LDR R2, =__data_start__ /* _data */ + LDR R3, =__data_end__ /* _edata */ + CMP R2, R3 + BEQ DataIsEmpty +LoopRel: CMP R2, R3 + LDRLO R0, [R1], #4 + STRLO R0, [R2], #4 + BLO LoopRel +DataIsEmpty: - ; +/* Clear .bss section (Zero init) */ + MOV R0, #0 + LDR R1, =__bss_start__ + LDR R2, =__bss_end__ + CMP R1,R2 + BEQ BSSIsEmpty +LoopZI: CMP R1, R2 + STRLO R0, [R1], #4 + BLO LoopZI +BSSIsEmpty: + + +/* Init realmonitor */ LDR R0, =__mbed_init_realmonitor MOV LR, PC BX R0 - - ; - LDR R0, =__mbed_init + +/* Go to Reset_Handler */ + LDR R0, =Reset_Handler BX R0 diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_table.s b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_table.s index 281e7a9bd4..d797c3794d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_table.s +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_CR/vector_table.s @@ -18,7 +18,7 @@ - .section VECTOR_TABLE, "ax" + .section .vectors, "ax" .arm @@ -34,7 +34,7 @@ ; -__main: +_start: LDR PC, =__mbed_reset LDR PC, =__mbed_undef LDR PC, =__mbed_swi diff --git a/libraries/tests/mbed/ticker/main.cpp b/libraries/tests/mbed/ticker/main.cpp index 5c7082ddfb..09eb230d12 100644 --- a/libraries/tests/mbed/ticker/main.cpp +++ b/libraries/tests/mbed/ticker/main.cpp @@ -13,7 +13,7 @@ void flip_1() { Ticker flipper_2; -#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC4088) || defined(TARGET_LPC1114) +#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC4088) || defined(TARGET_LPC1114) || defined(TARGET_LPC2368) # define LED_NAME LED2 #elif defined(TARGET_KL05Z) # define LED_NAME LED2 diff --git a/workspace_tools/targets.py b/workspace_tools/targets.py index 0134c734b2..4bc73becdc 100644 --- a/workspace_tools/targets.py +++ b/workspace_tools/targets.py @@ -59,7 +59,7 @@ class LPC2368(Target): self.extra_labels = ['NXP', 'LPC23XX'] - self.supported_toolchains = ["ARM"] + self.supported_toolchains = ["ARM","GCC_ARM","GCC_CR"] class LPC1768(Target):