From bb6d0e304caa1981f3ea30fa8a961ae6af15f4b1 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 28 May 2018 22:32:44 +0200 Subject: [PATCH] boards: Added module boards_common_stm32f103c8 & refactored bluepill - Moved common code for STM32F103C8 based boards to the new module - Updated board `bluepill` to use the new module --- boards/bluepill/Makefile | 2 ++ boards/bluepill/Makefile.dep | 1 + boards/bluepill/Makefile.features | 14 +------- boards/bluepill/Makefile.include | 34 ++----------------- boards/bluepill/dist/openocd.cfg | 5 +-- boards/bluepill/include/gpio_params.h | 2 +- boards/common/stm32f103c8/Makefile | 3 ++ boards/common/stm32f103c8/Makefile.dep | 0 boards/common/stm32f103c8/Makefile.features | 13 +++++++ boards/common/stm32f103c8/Makefile.include | 34 +++++++++++++++++++ boards/common/stm32f103c8/dist/openocd.cfg | 4 +++ .../stm32f103c8}/include/periph_conf.h | 2 +- 12 files changed, 63 insertions(+), 51 deletions(-) mode change 100644 => 120000 boards/bluepill/dist/openocd.cfg create mode 100644 boards/common/stm32f103c8/Makefile create mode 100644 boards/common/stm32f103c8/Makefile.dep create mode 100644 boards/common/stm32f103c8/Makefile.features create mode 100644 boards/common/stm32f103c8/Makefile.include create mode 100644 boards/common/stm32f103c8/dist/openocd.cfg rename boards/{bluepill => common/stm32f103c8}/include/periph_conf.h (99%) diff --git a/boards/bluepill/Makefile b/boards/bluepill/Makefile index f8fcbb53a0..7d218baad8 100644 --- a/boards/bluepill/Makefile +++ b/boards/bluepill/Makefile @@ -1,3 +1,5 @@ MODULE = board +DIRS = $(RIOTBOARD)/common/stm32f103c8 + include $(RIOTBASE)/Makefile.base diff --git a/boards/bluepill/Makefile.dep b/boards/bluepill/Makefile.dep index 5472bf8b8d..587675d912 100644 --- a/boards/bluepill/Makefile.dep +++ b/boards/bluepill/Makefile.dep @@ -1,3 +1,4 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio endif +include $(RIOTBOARD)/common/stm32f103c8/Makefile.dep diff --git a/boards/bluepill/Makefile.features b/boards/bluepill/Makefile.features index dd5163b8a7..ef95df38ad 100644 --- a/boards/bluepill/Makefile.features +++ b/boards/bluepill/Makefile.features @@ -1,13 +1 @@ -# Put defined MCU peripherals here (in alphabetical order) -FEATURES_PROVIDED += periph_adc -FEATURES_PROVIDED += periph_gpio -FEATURES_PROVIDED += periph_i2c -FEATURES_PROVIDED += periph_pwm -FEATURES_PROVIDED += periph_spi -FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart - -# The board MPU family (used for grouping by the CI system) -FEATURES_MCU_GROUP = cortex_m3_2 - --include $(RIOTCPU)/stm32f1/Makefile.features +-include $(RIOTBOARD)/common/stm32f103c8/Makefile.features diff --git a/boards/bluepill/Makefile.include b/boards/bluepill/Makefile.include index cd5c8686af..60e5ff25b5 100644 --- a/boards/bluepill/Makefile.include +++ b/boards/bluepill/Makefile.include @@ -1,32 +1,2 @@ -## the cpu to build for -export CPU = stm32f1 -export CPU_MODEL = stm32f103c8 - -# define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) - -# setup serial terminal -include $(RIOTMAKE)/tools/serial.inc.mk - -# optionally, use dfu-util to flash via usb -# note: needs a bootloader flashed before, config below is compatible -# with blackmagic_dfu, see https://github.com/blacksphere/blackmagic/ -# To stop bootloader from loading an existing firmware, pull down -# (ground) GPIO B1. -ifeq ($(PROGRAMMER),dfu-util) - export ROM_OFFSET ?= 0x2000 # Skip the space needed by the embedded bootloader - export FLASHER = dfu-util - export DEBUGGER = # no debugger - export RESET = # dfu-util has no support for resetting the device - - HEXFILE = $(BINFILE) - export FFLAGS = -d 1d50:6017 -s 0x08002000:leave -D "$(HEXFILE)" -else - -# this board uses openocd by default -export DEBUG_ADAPTER ?= stlink -export STLINK_VERSION ?= 2 - -include $(RIOTMAKE)/tools/openocd.inc.mk -endif +USEMODULE += boards_common_stm32f103c8 +include $(RIOTBOARD)/common/stm32f103c8/Makefile.include diff --git a/boards/bluepill/dist/openocd.cfg b/boards/bluepill/dist/openocd.cfg deleted file mode 100644 index ad3f024bf1..0000000000 --- a/boards/bluepill/dist/openocd.cfg +++ /dev/null @@ -1,4 +0,0 @@ -source [find target/stm32f1x.cfg] -reset_config none separate - -$_TARGETNAME configure -rtos auto diff --git a/boards/bluepill/dist/openocd.cfg b/boards/bluepill/dist/openocd.cfg new file mode 120000 index 0000000000..c5149f81f5 --- /dev/null +++ b/boards/bluepill/dist/openocd.cfg @@ -0,0 +1 @@ +../../common/stm32f103c8/dist/openocd.cfg \ No newline at end of file diff --git a/boards/bluepill/include/gpio_params.h b/boards/bluepill/include/gpio_params.h index a198c68c4e..a9f8b46172 100644 --- a/boards/bluepill/include/gpio_params.h +++ b/boards/bluepill/include/gpio_params.h @@ -7,7 +7,7 @@ */ /** - * @ingroup boards_stm32f130c8t6 + * @ingroup boards_bluepill * @{ * * @file diff --git a/boards/common/stm32f103c8/Makefile b/boards/common/stm32f103c8/Makefile new file mode 100644 index 0000000000..43083909ed --- /dev/null +++ b/boards/common/stm32f103c8/Makefile @@ -0,0 +1,3 @@ +MODULE = boards_common_stm32f103c8 + +include $(RIOTBASE)/Makefile.base diff --git a/boards/common/stm32f103c8/Makefile.dep b/boards/common/stm32f103c8/Makefile.dep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/common/stm32f103c8/Makefile.features b/boards/common/stm32f103c8/Makefile.features new file mode 100644 index 0000000000..dd5163b8a7 --- /dev/null +++ b/boards/common/stm32f103c8/Makefile.features @@ -0,0 +1,13 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc +FEATURES_PROVIDED += periph_gpio +FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_pwm +FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart + +# The board MPU family (used for grouping by the CI system) +FEATURES_MCU_GROUP = cortex_m3_2 + +-include $(RIOTCPU)/stm32f1/Makefile.features diff --git a/boards/common/stm32f103c8/Makefile.include b/boards/common/stm32f103c8/Makefile.include new file mode 100644 index 0000000000..9d4c7f1a26 --- /dev/null +++ b/boards/common/stm32f103c8/Makefile.include @@ -0,0 +1,34 @@ +## the cpu to build for +export CPU = stm32f1 +export CPU_MODEL = stm32f103c8 + +# define the default port depending on the host OS +PORT_LINUX ?= /dev/ttyUSB0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) + +# setup serial terminal +include $(RIOTMAKE)/tools/serial.inc.mk + +# optionally, use dfu-util to flash via usb +# note: needs a bootloader flashed before, config below is compatible +# with blackmagic_dfu, see https://github.com/blacksphere/blackmagic/ +# To stop bootloader from loading an existing firmware, pull down +# (ground) GPIO B1. +ifeq ($(PROGRAMMER),dfu-util) + export ROM_OFFSET ?= 0x2000 # Skip the space needed by the embedded bootloader + export FLASHER = dfu-util + export DEBUGGER = # no debugger + export RESET = # dfu-util has no support for resetting the device + + HEXFILE = $(BINFILE) + export FFLAGS = -d 1d50:6017 -s 0x08002000:leave -D "$(HEXFILE)" +else + +# this board uses openocd by default +export DEBUG_ADAPTER ?= stlink +export STLINK_VERSION ?= 2 + +include $(RIOTMAKE)/tools/openocd.inc.mk + +INCLUDES += -I$(RIOTBOARD)/common/stm32f103c8/include +endif diff --git a/boards/common/stm32f103c8/dist/openocd.cfg b/boards/common/stm32f103c8/dist/openocd.cfg new file mode 100644 index 0000000000..ad3f024bf1 --- /dev/null +++ b/boards/common/stm32f103c8/dist/openocd.cfg @@ -0,0 +1,4 @@ +source [find target/stm32f1x.cfg] +reset_config none separate + +$_TARGETNAME configure -rtos auto diff --git a/boards/bluepill/include/periph_conf.h b/boards/common/stm32f103c8/include/periph_conf.h similarity index 99% rename from boards/bluepill/include/periph_conf.h rename to boards/common/stm32f103c8/include/periph_conf.h index 322263cc67..a151cee375 100644 --- a/boards/bluepill/include/periph_conf.h +++ b/boards/common/stm32f103c8/include/periph_conf.h @@ -8,7 +8,7 @@ */ /** - * @ingroup boards_bluepill + * @ingroup boards_common_stm32f103c8 * @{ * * @file