Try STM Nucleo L432 LED.

This commit is contained in:
NIIBE Yutaka
2019-04-11 15:36:51 +09:00
parent e5e46b5de5
commit 054950bc9a
6 changed files with 127 additions and 8 deletions

View File

@@ -1,3 +1,7 @@
2019-04-11 NIIBE Yutaka <gniibe@fsij.org>
* chopstx-cortex-m.c: Support Cortex-M4 (not touching FPU).
2019-04-10 NIIBE Yutaka <gniibe@fsij.org> 2019-04-10 NIIBE Yutaka <gniibe@fsij.org>
* mcu/clk_gpio_init-stm32f.c: Rename from clk_gpio_init-stm32.c. * mcu/clk_gpio_init-stm32f.c: Rename from clk_gpio_init-stm32.c.

View File

@@ -84,7 +84,7 @@ struct chx_stack_regs {
#define CPU_EXCEPTION_PRIORITY_INTERRUPT 0x40 #define CPU_EXCEPTION_PRIORITY_INTERRUPT 0x40
#define CPU_EXCEPTION_PRIORITY_PENDSV 0x80 #define CPU_EXCEPTION_PRIORITY_PENDSV 0x80
#define CPU_EXCEPTION_PRIORITY_SVC 0x80 /* No use in this arch */ #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_SVC 0x30
#define CPU_EXCEPTION_PRIORITY_INHIBIT_SCHED 0x40 #define CPU_EXCEPTION_PRIORITY_INHIBIT_SCHED 0x40
@@ -306,7 +306,7 @@ chx_sched (uint32_t yield)
{ {
register struct chx_thread *tp asm ("r0"); register struct chx_thread *tp asm ("r0");
#if defined(__ARM_ARCH_7M__) #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
asm volatile ( asm volatile (
"svc #0" "svc #0"
: "=r" (tp) : "0" (yield): "memory"); : "=r" (tp) : "0" (yield): "memory");
@@ -648,7 +648,7 @@ preempt (void)
: /* no output */ : "r" (tp) : "memory"); : /* 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. * System call: switch to another thread.
* There are two cases: * There are two cases:

View File

@@ -2,15 +2,20 @@
PROJECT = sample 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-M3 board.
###
### Please change lines started with '###' for Cortex-M0+ board
### (STM32F0 Discovery).
CHOPSTX = .. CHOPSTX = ..
LDSCRIPT= sample.ld LDSCRIPT= sample.ld.m4
### LDSCRIPT= sample.ld
### LDSCRIPT= sample.ld.m3 ### LDSCRIPT= sample.ld.m3
CSRC = sample.c CSRC = sample.c
CHIP=stm32f0 CHIP=stm32l4
USE_SYS = yes USE_SYS = yes
################################### ###################################
@@ -20,7 +25,8 @@ LD = $(CROSS)gcc
OBJCOPY = $(CROSS)objcopy OBJCOPY = $(CROSS)objcopy
### MCU = cortex-m3 ### MCU = cortex-m3
MCU = cortex-m0 ### MCU = cortex-m0
MCU = cortex-m4
CWARN = -Wall -Wextra -Wstrict-prototypes CWARN = -Wall -Wextra -Wstrict-prototypes
DEFS = -DUSE_SYS3 -DFREE_STANDING -DMHZ=48 DEFS = -DUSE_SYS3 -DFREE_STANDING -DMHZ=48
### DEFS = -DFREE_STANDING -DUSE_SYS3 -DBUSY_LOOP -DCHX_FLAGS_MAIN=CHOPSTX_SCHED_RR ### DEFS = -DFREE_STANDING -DUSE_SYS3 -DBUSY_LOOP -DCHX_FLAGS_MAIN=CHOPSTX_SCHED_RR

View File

@@ -1 +1 @@
../board/board-stm32f0-discovery.h ../board/board-st-nucleo-l432.h

View File

@@ -1,6 +1,8 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <chopstx.h> #include <chopstx.h>
#include "board.h"
#include "sys.h" /* for set_led */ #include "sys.h" /* for set_led */
static chopstx_mutex_t mtx; static chopstx_mutex_t mtx;

107
example-led/sample.ld.m4 Normal file
View File

@@ -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__;