From de15af4c879b841e6032fa4aa24039ce785b3746 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 30 Jan 2018 08:37:56 +0100 Subject: [PATCH] boards/common/stm32-link: add common place for stlink - introduce common place for boards using stlink: same serial, all use openocd - apply this to nucleos --- boards/common/nucleo/Makefile.include | 30 +++---------------- .../openocd-f0.cfg => stm32/dist/stm32f0.cfg} | 0 .../openocd-f1.cfg => stm32/dist/stm32f1.cfg} | 0 .../openocd-f2.cfg => stm32/dist/stm32f2.cfg} | 0 .../openocd-f3.cfg => stm32/dist/stm32f3.cfg} | 0 .../openocd-f4.cfg => stm32/dist/stm32f4.cfg} | 0 .../openocd-f7.cfg => stm32/dist/stm32f7.cfg} | 0 .../openocd-l0.cfg => stm32/dist/stm32l0.cfg} | 0 .../openocd-l1.cfg => stm32/dist/stm32l1.cfg} | 0 .../openocd-l4.cfg => stm32/dist/stm32l4.cfg} | 0 .../tools/openocd-adapters/stlink.inc.mk | 14 +++++++++ 11 files changed, 18 insertions(+), 26 deletions(-) rename boards/common/{nucleo/dist/openocd-f0.cfg => stm32/dist/stm32f0.cfg} (100%) rename boards/common/{nucleo/dist/openocd-f1.cfg => stm32/dist/stm32f1.cfg} (100%) rename boards/common/{nucleo/dist/openocd-f2.cfg => stm32/dist/stm32f2.cfg} (100%) rename boards/common/{nucleo/dist/openocd-f3.cfg => stm32/dist/stm32f3.cfg} (100%) rename boards/common/{nucleo/dist/openocd-f4.cfg => stm32/dist/stm32f4.cfg} (100%) rename boards/common/{nucleo/dist/openocd-f7.cfg => stm32/dist/stm32f7.cfg} (100%) rename boards/common/{nucleo/dist/openocd-l0.cfg => stm32/dist/stm32l0.cfg} (100%) rename boards/common/{nucleo/dist/openocd-l1.cfg => stm32/dist/stm32l1.cfg} (100%) rename boards/common/{nucleo/dist/openocd-l4.cfg => stm32/dist/stm32l4.cfg} (100%) diff --git a/boards/common/nucleo/Makefile.include b/boards/common/nucleo/Makefile.include index 4b6e3db713..63464521dc 100644 --- a/boards/common/nucleo/Makefile.include +++ b/boards/common/nucleo/Makefile.include @@ -8,34 +8,12 @@ INCLUDES += -I$(RIOTBOARD)/common/stm32/include # configure the serial terminal PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) + +# setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -# all Nucleo boards have an on-board ST-link v2-1 adapter +# all Nucleo boards have an on-board ST-link adapter export DEBUG_ADAPTER ?= stlink -export STLINK_VERSION ?= 2-1 -# select OpenOCD configuration depending on CPU type -ifeq (,$(OPENOCD_CONFIG)) - ifeq ($(CPU),stm32f0) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-f0.cfg - else ifeq ($(CPU),stm32f1) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-f1.cfg - else ifeq ($(CPU),stm32f2) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-f2.cfg - else ifeq ($(CPU),stm32f3) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-f3.cfg - else ifeq ($(CPU),stm32f4) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-f4.cfg - else ifeq ($(CPU),stm32f7) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-f7.cfg - else ifeq ($(CPU),stm32l0) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-l0.cfg - else ifeq ($(CPU),stm32l1) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-l1.cfg - else ifeq ($(CPU),stm32l4) - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nucleo/dist/openocd-l4.cfg - endif -endif - -# this board uses openocd +# nucleo boards use openocd include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/common/nucleo/dist/openocd-f0.cfg b/boards/common/stm32/dist/stm32f0.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-f0.cfg rename to boards/common/stm32/dist/stm32f0.cfg diff --git a/boards/common/nucleo/dist/openocd-f1.cfg b/boards/common/stm32/dist/stm32f1.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-f1.cfg rename to boards/common/stm32/dist/stm32f1.cfg diff --git a/boards/common/nucleo/dist/openocd-f2.cfg b/boards/common/stm32/dist/stm32f2.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-f2.cfg rename to boards/common/stm32/dist/stm32f2.cfg diff --git a/boards/common/nucleo/dist/openocd-f3.cfg b/boards/common/stm32/dist/stm32f3.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-f3.cfg rename to boards/common/stm32/dist/stm32f3.cfg diff --git a/boards/common/nucleo/dist/openocd-f4.cfg b/boards/common/stm32/dist/stm32f4.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-f4.cfg rename to boards/common/stm32/dist/stm32f4.cfg diff --git a/boards/common/nucleo/dist/openocd-f7.cfg b/boards/common/stm32/dist/stm32f7.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-f7.cfg rename to boards/common/stm32/dist/stm32f7.cfg diff --git a/boards/common/nucleo/dist/openocd-l0.cfg b/boards/common/stm32/dist/stm32l0.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-l0.cfg rename to boards/common/stm32/dist/stm32l0.cfg diff --git a/boards/common/nucleo/dist/openocd-l1.cfg b/boards/common/stm32/dist/stm32l1.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-l1.cfg rename to boards/common/stm32/dist/stm32l1.cfg diff --git a/boards/common/nucleo/dist/openocd-l4.cfg b/boards/common/stm32/dist/stm32l4.cfg similarity index 100% rename from boards/common/nucleo/dist/openocd-l4.cfg rename to boards/common/stm32/dist/stm32l4.cfg diff --git a/makefiles/tools/openocd-adapters/stlink.inc.mk b/makefiles/tools/openocd-adapters/stlink.inc.mk index b9ef8d1ee0..c9b12908e0 100644 --- a/makefiles/tools/openocd-adapters/stlink.inc.mk +++ b/makefiles/tools/openocd-adapters/stlink.inc.mk @@ -1,4 +1,7 @@ # ST-Link debug adapter +# Use st-link v2-1 by default +STLINK_VERSION ?= 2-1 + # Use STLINK_VERSION to select which stlink version is used OPENOCD_ADAPTER_INIT ?= \ -c 'source [find interface/stlink-v$(STLINK_VERSION).cfg]' \ @@ -8,3 +11,14 @@ ifneq (,$(DEBUG_ADAPTER_ID)) OPENOCD_ADAPTER_INIT += -c 'hla_serial $(DEBUG_ADAPTER_ID)' endif export OPENOCD_ADAPTER_INIT + +# if no openocd specific configuration file, check for default locations: +# 1. Using the default dist/openocd.cfg (automatically set by openocd.sh) +# 2. Using the common cpu specific config file +ifeq (,$(OPENOCD_CONFIG)) + # if no openocd default configuration is provided by the board, + # use the STM32 common one + ifeq (0,$(words $(wildcard $(RIOTBOARD)/$(BOARD)/dist/openocd.cfg))) + export OPENOCD_CONFIG := $(RIOTBASE)/boards/common/stm32/dist/$(CPU).cfg + endif +endif