diff --git a/ChangeLog b/ChangeLog index fc35cbc..af6977f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-04-11 NIIBE Yutaka + + * chopstx-cortex-m.c: Support Cortex-M4 (not touching FPU). + 2019-04-10 NIIBE Yutaka * mcu/clk_gpio_init-stm32f.c: Rename from clk_gpio_init-stm32.c. diff --git a/chopstx-cortex-m.c b/chopstx-cortex-m.c index b8991db..c6d1b3e 100644 --- a/chopstx-cortex-m.c +++ b/chopstx-cortex-m.c @@ -84,7 +84,7 @@ struct chx_stack_regs { #define CPU_EXCEPTION_PRIORITY_INTERRUPT 0x40 #define CPU_EXCEPTION_PRIORITY_PENDSV 0x80 #define CPU_EXCEPTION_PRIORITY_SVC 0x80 /* No use in this arch */ -#elif defined(__ARM_ARCH_7M__) +#elif defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) #define CPU_EXCEPTION_PRIORITY_SVC 0x30 #define CPU_EXCEPTION_PRIORITY_INHIBIT_SCHED 0x40 @@ -306,7 +306,7 @@ chx_sched (uint32_t yield) { register struct chx_thread *tp asm ("r0"); -#if defined(__ARM_ARCH_7M__) +#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) asm volatile ( "svc #0" : "=r" (tp) : "0" (yield): "memory"); @@ -648,7 +648,7 @@ preempt (void) : /* no output */ : "r" (tp) : "memory"); } -#if defined(__ARM_ARCH_7M__) +#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) /* * System call: switch to another thread. * There are two cases: diff --git a/example-led/Makefile b/example-led/Makefile index d7d978c..77fab3d 100644 --- a/example-led/Makefile +++ b/example-led/Makefile @@ -2,15 +2,20 @@ PROJECT = sample -### Currently, it's for STM32F0 Discovery. +### Currently, it is for STM32 Nucleo L432 +### ### Please change lines started with '###' for Cortex-M3 board. +### +### Please change lines started with '###' for Cortex-M0+ board +### (STM32F0 Discovery). CHOPSTX = .. -LDSCRIPT= sample.ld +LDSCRIPT= sample.ld.m4 +### LDSCRIPT= sample.ld ### LDSCRIPT= sample.ld.m3 CSRC = sample.c -CHIP=stm32f0 +CHIP=stm32l4 USE_SYS = yes ################################### @@ -20,7 +25,8 @@ LD = $(CROSS)gcc OBJCOPY = $(CROSS)objcopy ### MCU = cortex-m3 -MCU = cortex-m0 +### MCU = cortex-m0 +MCU = cortex-m4 CWARN = -Wall -Wextra -Wstrict-prototypes DEFS = -DUSE_SYS3 -DFREE_STANDING -DMHZ=48 ### DEFS = -DFREE_STANDING -DUSE_SYS3 -DBUSY_LOOP -DCHX_FLAGS_MAIN=CHOPSTX_SCHED_RR diff --git a/example-led/board.h b/example-led/board.h index 25f9e69..8075a6c 120000 --- a/example-led/board.h +++ b/example-led/board.h @@ -1 +1 @@ -../board/board-stm32f0-discovery.h \ No newline at end of file +../board/board-st-nucleo-l432.h \ No newline at end of file diff --git a/example-led/sample.c b/example-led/sample.c index 7e7bcff..567eea2 100644 --- a/example-led/sample.c +++ b/example-led/sample.c @@ -1,6 +1,8 @@ #include #include #include + +#include "board.h" #include "sys.h" /* for set_led */ static chopstx_mutex_t mtx; diff --git a/example-led/sample.ld.m4 b/example-led/sample.ld.m4 new file mode 100644 index 0000000..e4b2548 --- /dev/null +++ b/example-led/sample.ld.m4 @@ -0,0 +1,107 @@ +/* + * ST32L4 memory setup. + */ +MEMORY +{ + flash : org = 0x08000000, len = 256k + ram : org = 0x20000000, len = 48k +} + +__ram_start__ = ORIGIN(ram); +__ram_size__ = 20k; +__ram_end__ = __ram_start__ + __ram_size__; + +SECTIONS +{ + . = 0; + + _text = .; + + .startup : ALIGN(128) SUBALIGN(128) + { + KEEP(*(.startup.vectors)) + . = ALIGN(16); + _sys = .; + . = ALIGN(16); + KEEP(*(.sys.version)) + KEEP(*(.sys.board_id)) + KEEP(*(.sys.board_name)) + build/sys-*.o(.text) + build/sys-*.o(.text.*) + build/sys-*.o(.rodata) + build/sys-*.o(.rodata.*) + . = ALIGN(1024); + } > flash =0xffffffff + + .text : ALIGN(16) SUBALIGN(16) + { + *(.text.startup.*) + *(.text) + *(.text.*) + *(.rodata) + *(.rodata.*) + *(.glue_7t) + *(.glue_7) + *(.gcc*) + . = ALIGN(8); + } > flash + + .ARM.extab : {*(.ARM.extab* .gnu.linkonce.armextab.*)} > flash + + .ARM.exidx : { + PROVIDE(__exidx_start = .); + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + PROVIDE(__exidx_end = .); + } > flash + + .eh_frame_hdr : {*(.eh_frame_hdr)} > flash + + .eh_frame : ONLY_IF_RO {*(.eh_frame)} > flash + + .textalign : ONLY_IF_RO { . = ALIGN(8); } > flash + + _etext = .; + _textdata = _etext; + + .stacks (NOLOAD) : + { + *(.main_stack) + *(.process_stack.0) + *(.process_stack.1) + *(.process_stack.2) + *(.process_stack.3) + . = ALIGN(8); + } > ram + + .data : + { + . = ALIGN(4); + PROVIDE(_data = .); + *(.data) + . = ALIGN(4); + *(.data.*) + . = ALIGN(4); + *(.ramtext) + . = ALIGN(4); + PROVIDE(_edata = .); + } > ram AT > flash + + .bss : + { + . = ALIGN(4); + PROVIDE(_bss_start = .); + *(.bss) + . = ALIGN(4); + *(.bss.*) + . = ALIGN(4); + *(COMMON) + . = ALIGN(4); + PROVIDE(_bss_end = .); + } > ram + + PROVIDE(end = .); + _end = .; +} + +__heap_base__ = _end; +__heap_end__ = __ram_end__;