From ae4d505154c179400475377fa525f3aa684cf947 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 19 Nov 2020 18:07:33 +0100 Subject: [PATCH 1/3] Makefile.include: include programmer logic in common place --- Makefile.include | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.include b/Makefile.include index e3dd7383d3e3..37705ff01ab8 100644 --- a/Makefile.include +++ b/Makefile.include @@ -402,6 +402,9 @@ ifneq (,$(filter emulate,$(MAKECMDGOALS))) -include $(RIOTMAKE)/tools/$(RIOT_EMULATOR).inc.mk endif +# Include common programmer logic if available +-include $(RIOTMAKE)/tools/$(PROGRAMMER).inc.mk + # Assume GCC/GNU as supported toolchain if CPU's Makefile.include doesn't # provide this macro TOOLCHAINS_SUPPORTED ?= gnu From c6ad85a7b0961eb9469b53c56c6c949149613e74 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 19 Nov 2020 18:38:41 +0100 Subject: [PATCH 2/3] boards: don't include programmer logic at board level --- boards/6lowpan-clicker/Makefile.include | 1 - boards/adafruit-clue/Makefile.include | 2 -- boards/arduino-nano-33-ble/Makefile.include | 2 -- boards/atmega1284p/Makefile.include | 2 +- boards/atmega256rfr2-xpro/Makefile.include | 2 +- boards/atmega328p/Makefile.include | 2 +- boards/b-l072z-lrwan1/Makefile.include | 4 +--- boards/b-l475e-iot01a/Makefile.include | 4 +--- boards/calliope-mini/Makefile.include | 1 - boards/cc2650-launchpad/Makefile.include | 2 +- boards/cc2650stk/Makefile.include | 2 +- boards/common/arduino-due/Makefile.include | 2 +- boards/common/arduino-mkr/Makefile.include | 1 - boards/common/atmega/Makefile.include | 21 ++++++++-------- boards/common/cc2538/Makefile.include | 2 -- boards/common/cc26x2_cc13x2/Makefile.include | 6 ----- boards/common/frdm/Makefile.include | 10 ++++---- boards/common/iotlab/Makefile.include | 6 ++--- boards/common/nrf51/Makefile.include | 5 ++-- boards/common/nrf52/Makefile.include | 4 ---- boards/common/particle-mesh/Makefile.include | 2 -- .../Makefile.include | 2 -- boards/common/silabs/Makefile.include | 6 ----- boards/ek-lm4f120xl/Makefile.include | 2 +- boards/feather-m0/Makefile.include | 1 - boards/fox/Makefile.include | 2 +- boards/hamilton/Makefile.include | 3 +-- boards/hifive1/Makefile.include | 2 +- boards/hifive1b/Makefile.include | 2 -- boards/i-nucleo-lrwan1/Makefile.include | 2 +- boards/ikea-tradfri/Makefile.include | 2 +- boards/im880b/Makefile.include | 5 ++-- boards/limifrog-v1/Makefile.include | 5 ++-- boards/lsn50/Makefile.include | 10 ++++---- boards/maple-mini/Makefile.include | 5 ++-- boards/mcb2388/Makefile.include | 3 --- boards/mega-xplained/Makefile.include | 4 ++-- boards/microbit/Makefile.include | 2 -- boards/microduino-corerf/Makefile.include | 4 ++-- boards/msba2/Makefile.include | 1 - boards/mulle/Makefile.include | 24 +++++++++---------- boards/nrf51dk/Makefile.include | 2 -- boards/nrf52832-mdk/Makefile.include | 1 - boards/nrf52840-mdk/Makefile.include | 1 - boards/nz32-sc151/Makefile.include | 2 +- boards/p-l496g-cell02/Makefile.include | 5 ++-- boards/pba-d-01-kw2x/Makefile.include | 6 ++--- boards/pic32-wifire/Makefile.include | 2 -- boards/pinetime/Makefile.include | 1 - boards/pyboard/Makefile.include | 2 +- boards/seeeduino_arch-pro/Makefile.include | 8 +++---- boards/sensebox_samd21/Makefile.include | 12 +++++----- boards/spark-core/Makefile.include | 5 +--- boards/stm32f0discovery/Makefile.include | 5 ++-- boards/stm32f3discovery/Makefile.include | 5 ++-- boards/stm32f429i-disc1/Makefile.include | 5 ++-- boards/stm32f4discovery/Makefile.include | 5 ++-- boards/stm32f723e-disco/Makefile.include | 6 ++--- boards/stm32f769i-disco/Makefile.include | 6 ++--- boards/stm32l0538-disco/Makefile.include | 6 ++--- boards/stm32l476g-disco/Makefile.include | 5 ++-- boards/ublox-c030-u201/Makefile.include | 6 ++--- boards/yunjia-nrf51822/Makefile.include | 3 --- makefiles/boards/sam0.inc.mk | 8 +------ makefiles/boards/stm32.inc.mk | 9 ------- makefiles/tools/avrdude.inc.mk | 14 +++++------ .../tools/{dfu.inc.mk => dfu-util.inc.mk} | 0 67 files changed, 110 insertions(+), 190 deletions(-) rename makefiles/tools/{dfu.inc.mk => dfu-util.inc.mk} (100%) diff --git a/boards/6lowpan-clicker/Makefile.include b/boards/6lowpan-clicker/Makefile.include index 9ac719b33b83..c01275037e29 100644 --- a/boards/6lowpan-clicker/Makefile.include +++ b/boards/6lowpan-clicker/Makefile.include @@ -12,5 +12,4 @@ ifeq ($(PROGRAMMER),pic32prog) # * The triangle `▶` goes into the port number 1 (a hole with a square around it) # opposite side of the JP1 ICSP text. FLASHFILE ?= $(HEXFILE) - include $(RIOTMAKE)/tools/pic32prog.inc.mk endif diff --git a/boards/adafruit-clue/Makefile.include b/boards/adafruit-clue/Makefile.include index c50d8b068674..7878ea050ff4 100644 --- a/boards/adafruit-clue/Makefile.include +++ b/boards/adafruit-clue/Makefile.include @@ -15,8 +15,6 @@ ifeq ($(PROGRAMMER),adafruit-nrfutil) TERM_DELAY = 2 TERMDEPS += term-delay endif - - include $(RIOTMAKE)/tools/adafruit-nrfutil.inc.mk endif term-delay: diff --git a/boards/arduino-nano-33-ble/Makefile.include b/boards/arduino-nano-33-ble/Makefile.include index e92e0f5f9396..bc8ca5a779aa 100644 --- a/boards/arduino-nano-33-ble/Makefile.include +++ b/boards/arduino-nano-33-ble/Makefile.include @@ -11,8 +11,6 @@ ifeq ($(PROGRAMMER),bossa) BOSSA_VERSION = nrf52 BOSSA_ARDUINO_PREFLASH = yes PREFLASH_DELAY = 1 - - include $(RIOTMAKE)/tools/bossa.inc.mk endif TESTRUNNER_CONNECT_DELAY ?= 2 diff --git a/boards/atmega1284p/Makefile.include b/boards/atmega1284p/Makefile.include index bc1a2dfce4de..b8564cf31132 100644 --- a/boards/atmega1284p/Makefile.include +++ b/boards/atmega1284p/Makefile.include @@ -7,7 +7,7 @@ ATMEGA1284P_CLOCK ?= # Allow overwriting programmer via env variables without affecting other boards PROGRAMMER_BOARD_ATMEGA1284P ?= atmelice # ICSP programmer to use for avrdude -PROGRAMMER ?= $(PROGRAMMER_BOARD_ATMEGA1284P) +AVRDUDE_PROGRAMMER ?= $(PROGRAMMER_BOARD_ATMEGA1284P) ifneq (,$(ATMEGA1284P_CLOCK)) CFLAGS += -DCLOCK_CORECLOCK=$(ATMEGA1284P_CLOCK) diff --git a/boards/atmega256rfr2-xpro/Makefile.include b/boards/atmega256rfr2-xpro/Makefile.include index 5323cefc1ec8..9ec62cab0ad6 100644 --- a/boards/atmega256rfr2-xpro/Makefile.include +++ b/boards/atmega256rfr2-xpro/Makefile.include @@ -3,6 +3,6 @@ PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) BAUD ?= 115200 # Use EDBG (xplainedpro) programmer with avrdude -PROGRAMMER ?= xplainedpro +AVRDUDE_PROGRAMMER ?= xplainedpro include $(RIOTBOARD)/common/atmega/Makefile.include diff --git a/boards/atmega328p/Makefile.include b/boards/atmega328p/Makefile.include index c45aba1dfff4..d7bd49b60a2b 100644 --- a/boards/atmega328p/Makefile.include +++ b/boards/atmega328p/Makefile.include @@ -7,7 +7,7 @@ ATMEGA328P_CLOCK ?= # Allow overwriting programmer via env variables without affecting other boards PROGRAMMER_BOARD_ATMEGA328P ?= usbtiny # ICSP programmer to use for avrdude -PROGRAMMER ?= $(PROGRAMMER_BOARD_ATMEGA328P) +AVRDUDE_PROGRAMMER ?= $(PROGRAMMER_BOARD_ATMEGA328P) ifneq (,$(ATMEGA328P_CLOCK)) CFLAGS += -DCLOCK_CORECLOCK=$(ATMEGA328P_CLOCK) diff --git a/boards/b-l072z-lrwan1/Makefile.include b/boards/b-l072z-lrwan1/Makefile.include index 3333b64820a3..8d969c97d0c8 100644 --- a/boards/b-l072z-lrwan1/Makefile.include +++ b/boards/b-l072z-lrwan1/Makefile.include @@ -9,11 +9,9 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # this board has an on-board ST-link adapter +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink # this board can become un-flashable after a hardfault, # use connect_assert_srst to always be able to flash or reset the board. OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/b-l475e-iot01a/Makefile.include b/boards/b-l475e-iot01a/Makefile.include index 8c301d1b748b..ff1e406f4b06 100644 --- a/boards/b-l475e-iot01a/Makefile.include +++ b/boards/b-l475e-iot01a/Makefile.include @@ -9,11 +9,9 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # this board has an on-board ST-link adapter +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink # The board can become un-flashable after some execution, # use connect_assert_srst to always be able to flash or reset the board. OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/calliope-mini/Makefile.include b/boards/calliope-mini/Makefile.include index 0b9303902599..10b281bb7629 100644 --- a/boards/calliope-mini/Makefile.include +++ b/boards/calliope-mini/Makefile.include @@ -11,7 +11,6 @@ else ifeq (pyocd,$(PROGRAMMER)) # PyOCD doesn't recognize automatically the board ID, so target type has to # be passed explicitly FLASH_TARGET_TYPE ?= -t nrf51 - include $(RIOTMAKE)/tools/pyocd.inc.mk endif # include nrf51 boards common configuration diff --git a/boards/cc2650-launchpad/Makefile.include b/boards/cc2650-launchpad/Makefile.include index f51b72716503..2bd3fbe72958 100644 --- a/boards/cc2650-launchpad/Makefile.include +++ b/boards/cc2650-launchpad/Makefile.include @@ -8,4 +8,4 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # configure the flash tool -include $(RIOTMAKE)/tools/uniflash.inc.mk +PROGRAMMER ?= uniflash diff --git a/boards/cc2650stk/Makefile.include b/boards/cc2650stk/Makefile.include index 7fbe50b22085..8630b815dadf 100644 --- a/boards/cc2650stk/Makefile.include +++ b/boards/cc2650stk/Makefile.include @@ -8,4 +8,4 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) include $(RIOTMAKE)/tools/serial.inc.mk # configure the flash tool -include $(RIOTMAKE)/tools/uniflash.inc.mk +PROGRAMMER ?= uniflash diff --git a/boards/common/arduino-due/Makefile.include b/boards/common/arduino-due/Makefile.include index 5c97d52ce4b7..97858d11205c 100644 --- a/boards/common/arduino-due/Makefile.include +++ b/boards/common/arduino-due/Makefile.include @@ -9,6 +9,6 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # setup flasher (using BOSSA) +PROGRAMMER ?= bossa BOSSA_VERSION = 1.8 BOSSA_ARDUINO_PREFLASH = yes -include $(RIOTMAKE)/tools/bossa.inc.mk diff --git a/boards/common/arduino-mkr/Makefile.include b/boards/common/arduino-mkr/Makefile.include index c7485c968484..b49f864d0aa3 100644 --- a/boards/common/arduino-mkr/Makefile.include +++ b/boards/common/arduino-mkr/Makefile.include @@ -8,7 +8,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk ifeq ($(PROGRAMMER),jlink) # in case J-Link is attached to SWD pins, use a plain CPU memory model JLINK_DEVICE = $(MKR_JLINK_DEVICE) - include $(RIOTMAKE)/tools/jlink.inc.mk endif # Include all definitions for flashing with bossa over USB diff --git a/boards/common/atmega/Makefile.include b/boards/common/atmega/Makefile.include index 46e64ec1b31e..787380fdee56 100644 --- a/boards/common/atmega/Makefile.include +++ b/boards/common/atmega/Makefile.include @@ -1,15 +1,18 @@ INCLUDES += -I$(RIOTBOARD)/common/atmega/include -# If programmer is not set, set it based on the bootloader used -ifeq (,$(PROGRAMMER)) +# Use avrdude programmer +PROGRAMMER ?= avrdude + +# If avrdude specific programmer is not set, set it based on the bootloader used +ifeq (,$(AVRDUDE_PROGRAMMER)) ifeq (atmegaboot,$(BOOTLOADER)) - PROGRAMMER = arduino + AVRDUDE_PROGRAMMER = arduino BOOTLOADER_SIZE ?= 2048 BOOTLOADER_BAUD ?= 57600 endif ifeq (optiboot,$(BOOTLOADER)) - PROGRAMMER = arduino + AVRDUDE_PROGRAMMER = arduino ifneq (,$(filter $(CPU), atmega128rfa1 atmega256rfr2 atmega1281 atmega1284p atmega2560)) # The minimum bootloader size on these CPUs is 1 KiB (so 512 Byte are wasted) BOOTLOADER_SIZE ?= 1024 @@ -19,12 +22,12 @@ ifeq (,$(PROGRAMMER)) endif ifeq (stk500v1,$(BOOTLOADER)) - PROGRAMMER = stk500v1 + AVRDUDE_PROGRAMMER = stk500v1 BOOTLOADER_SIZE ?= 8K endif ifeq (stk500v2,$(BOOTLOADER)) - PROGRAMMER = stk500v2 + AVRDUDE_PROGRAMMER = stk500v2 BOOTLOADER_SIZE ?= 8K # Disable auto erase; erasing the flash is done implicitly by the bootloader # and explicit erase is not supported @@ -32,12 +35,12 @@ ifeq (,$(PROGRAMMER)) endif ifeq (avr109,$(BOOTLOADER)) - PROGRAMMER = avr109 + AVRDUDE_PROGRAMMER = avr109 BOOTLOADER_SIZE ?= 4K endif ifeq (derfmega,$(BOOTLOADER)) - PROGRAMMER = wiring + AVRDUDE_PROGRAMMER = wiring BOOTLOADER_SIZE ?= 4K endif @@ -50,5 +53,3 @@ BOOTLOADER_SIZE ?= 0 ROM_RESERVED ?= $(BOOTLOADER_SIZE) include $(RIOTMAKE)/tools/serial.inc.mk -# include avrdude flashing tool -include $(RIOTMAKE)/tools/avrdude.inc.mk diff --git a/boards/common/cc2538/Makefile.include b/boards/common/cc2538/Makefile.include index fc3c1b1feb5b..9912ac002c46 100644 --- a/boards/common/cc2538/Makefile.include +++ b/boards/common/cc2538/Makefile.include @@ -12,14 +12,12 @@ endif ifeq ($(PROGRAMMER),cc2538-bsl) PROG_BAUD ?= 460800 - include $(RIOTMAKE)/tools/cc2538-bsl.inc.mk else ifeq ($(PROGRAMMER),jlink) # Special flashing and reset scripts are required due to board hardware FLASH_ADDR = 0x200000 JLINK_DEVICE = CC2538SF53 JLINK_IF = JTAG JLINK_RESET_FILE = $(RIOTBOARD)/common/cc2538/dist/hw_reset.seg - include $(RIOTMAKE)/tools/jlink.inc.mk endif OFLAGS = --gap-fill 0xff diff --git a/boards/common/cc26x2_cc13x2/Makefile.include b/boards/common/cc26x2_cc13x2/Makefile.include index 8877f48141da..dfa89d7b51d0 100644 --- a/boards/common/cc26x2_cc13x2/Makefile.include +++ b/boards/common/cc26x2_cc13x2/Makefile.include @@ -3,9 +3,3 @@ PROGRAMMER ?= uniflash OPENOCD_CONFIG ?= $(RIOTBOARD)/common/cc26x2_cc13x2/dist/openocd.cfg UNIFLASH_CONFIG ?= $(RIOTBOARD)/common/cc26x2_cc13x2/dist - -ifeq ($(PROGRAMMER),uniflash) - include $(RIOTMAKE)/tools/uniflash.inc.mk -else ifeq ($(PROGRAMMER),openocd) - include $(RIOTMAKE)/tools/openocd.inc.mk -endif diff --git a/boards/common/frdm/Makefile.include b/boards/common/frdm/Makefile.include index bb1c048867f1..1ac4ff1a7513 100644 --- a/boards/common/frdm/Makefile.include +++ b/boards/common/frdm/Makefile.include @@ -2,6 +2,9 @@ PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) +# Use OpenOCD by default +PROGRAMMER ?= openocd + # Use the shared OpenOCD configuration # Using dap or jlink depends on which firmware the OpenSDA debugger is running DEBUG_ADAPTER ?= dap @@ -22,12 +25,9 @@ OPENOCD_CONFIG ?= $(RIOTBOARD)/common/frdm/dist/openocd-$(OPENOCD_KINETIS_FAMILY # Check the flash configuration field before flashing PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield.sh -# setup serial terminal -include $(RIOTMAKE)/tools/serial.inc.mk - # The board can become un-flashable after some execution, # use connect_assert_srst to always be able to flash or reset the board. OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +# setup serial terminal +include $(RIOTMAKE)/tools/serial.inc.mk diff --git a/boards/common/iotlab/Makefile.include b/boards/common/iotlab/Makefile.include index 6f89fa3d85fa..2fdb86424ac2 100644 --- a/boards/common/iotlab/Makefile.include +++ b/boards/common/iotlab/Makefile.include @@ -6,6 +6,9 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial*B))) BAUD ?= 500000 include $(RIOTMAKE)/tools/serial.inc.mk +# Use openocd by default +PROGRAMMER ?= openocd + # Using connect_assert_srst removes errors on flash from invalid state OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 @@ -13,9 +16,6 @@ DEBUG_ADAPTER ?= iotlab OPENOCD_CONFIG ?= $(RIOTBOARD)/common/iotlab/dist/openocd.cfg -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk - # add the common header files to the include path INCLUDES += -I$(RIOTBOARD)/common/stm32/include INCLUDES += -I$(RIOTBOARD)/common/iotlab/include diff --git a/boards/common/nrf51/Makefile.include b/boards/common/nrf51/Makefile.include index 81643dbac034..5683775b2c6f 100644 --- a/boards/common/nrf51/Makefile.include +++ b/boards/common/nrf51/Makefile.include @@ -9,12 +9,13 @@ ifneq (,$(filter nimble,$(USEPKG))) CFLAGS += -DBOARD_NRF51_XTIMER_ALT endif +# Use openocd by default +PROGRAMMER ?= openocd + ifeq ($(PROGRAMMER),openocd) # use common openocd configuration for nrf51 OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf51/dist/openocd.cfg - include $(RIOTMAKE)/tools/openocd.inc.mk else ifeq ($(PROGRAMMER),jlink) # setup JLink for flashing JLINK_DEVICE = nrf51822 - include $(RIOTMAKE)/tools/jlink.inc.mk endif diff --git a/boards/common/nrf52/Makefile.include b/boards/common/nrf52/Makefile.include index cf138ef10699..589b9534d93d 100644 --- a/boards/common/nrf52/Makefile.include +++ b/boards/common/nrf52/Makefile.include @@ -19,7 +19,6 @@ PROGRAMMER ?= jlink ifeq (jlink,$(PROGRAMMER)) # setup JLink for flashing JLINK_DEVICE = nrf52 - include $(RIOTMAKE)/tools/jlink.inc.mk else ifeq (openocd,$(PROGRAMMER)) ifneq (,$(filter $(BOARD),ruuvitag thingy52)) # openocd doesn't fully work with ruuvitag and thingy52 @@ -30,7 +29,4 @@ else ifeq (openocd,$(PROGRAMMER)) # build from source (master > 2018, August the 13rd) is required. DEBUG_ADAPTER ?= jlink OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf52/dist/openocd.cfg - include $(RIOTMAKE)/tools/openocd.inc.mk -else ifeq (bmp,$(PROGRAMMER)) - include $(RIOTMAKE)/tools/bmp.inc.mk endif diff --git a/boards/common/particle-mesh/Makefile.include b/boards/common/particle-mesh/Makefile.include index 683ab4a97254..c7671af52f10 100644 --- a/boards/common/particle-mesh/Makefile.include +++ b/boards/common/particle-mesh/Makefile.include @@ -17,7 +17,6 @@ ifeq (1,$(PARTICLE_MONOFIRMWARE)) # Setting DFU_ARGS won't work as the implied --reset causes errors. FFLAGS = -d 0x2B04:0xD00E -a 0 -s 0x30000:leave -D $(FLASHFILE) PROGRAMMER = dfu-util - include $(RIOTMAKE)/tools/dfu.inc.mk # If CDC-ACM is *not* enabled, any pre-flash resets will just not work -- but # then again nothing can be done in that case anyway, and the preflash # routines fall through without erring. @@ -32,7 +31,6 @@ else # The board is not recognized automatically by pyocd, so the CPU target # option is passed explicitly FLASH_TARGET_TYPE ?= -t nrf52840 - include $(RIOTMAKE)/tools/pyocd.inc.mk else ifeq (openocd,$(PROGRAMMER)) DEBUG_ADAPTER ?= dap endif diff --git a/boards/common/samd21-arduino-bootloader/Makefile.include b/boards/common/samd21-arduino-bootloader/Makefile.include index 56325baf68cc..b632b2d8517f 100644 --- a/boards/common/samd21-arduino-bootloader/Makefile.include +++ b/boards/common/samd21-arduino-bootloader/Makefile.include @@ -8,6 +8,4 @@ ifeq ($(PROGRAMMER),bossa) # such bootloader. ROM_OFFSET ?= 0x2000 BOSSA_ARDUINO_PREFLASH = yes - - include $(RIOTMAKE)/tools/bossa.inc.mk endif diff --git a/boards/common/silabs/Makefile.include b/boards/common/silabs/Makefile.include index de7502dbc31c..a89b39136361 100644 --- a/boards/common/silabs/Makefile.include +++ b/boards/common/silabs/Makefile.include @@ -5,9 +5,3 @@ PROGRAMMER ?= jlink JLINK_DEVICE ?= ${CPU_MODEL} OPENOCD_CONFIG ?= board/efm32.cfg - -ifeq ($(PROGRAMMER),jlink) - include $(RIOTMAKE)/tools/jlink.inc.mk -else ifeq ($(PROGRAMMER),openocd) - include $(RIOTMAKE)/tools/openocd.inc.mk -endif diff --git a/boards/ek-lm4f120xl/Makefile.include b/boards/ek-lm4f120xl/Makefile.include index f2ca52974bdc..be82c7a3580c 100644 --- a/boards/ek-lm4f120xl/Makefile.include +++ b/boards/ek-lm4f120xl/Makefile.include @@ -6,4 +6,4 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +PROGRAMMER ?= openocd diff --git a/boards/feather-m0/Makefile.include b/boards/feather-m0/Makefile.include index 4a1da523b4c4..e7db298a16d6 100644 --- a/boards/feather-m0/Makefile.include +++ b/boards/feather-m0/Makefile.include @@ -8,7 +8,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk ifeq ($(PROGRAMMER),jlink) # in case J-Link is attached to SWD pins, use a plain CPU memory model JLINK_DEVICE = atsamd21 - include $(RIOTMAKE)/tools/jlink.inc.mk endif # Include all definitions for flashing with bossa over USB diff --git a/boards/fox/Makefile.include b/boards/fox/Makefile.include index 59dcb087cea7..46c2c5416f9c 100644 --- a/boards/fox/Makefile.include +++ b/boards/fox/Makefile.include @@ -9,4 +9,4 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial*))) include $(RIOTMAKE)/tools/serial.inc.mk # this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +PROGRAMMER ?= openocd diff --git a/boards/hamilton/Makefile.include b/boards/hamilton/Makefile.include index 003c4219b4d3..ad8fc5663598 100644 --- a/boards/hamilton/Makefile.include +++ b/boards/hamilton/Makefile.include @@ -1,4 +1,5 @@ # debugger config +PROGRAMMER ?= jlink JLINK_DEVICE = atsamr21e18a OBJDUMPFLAGS += --disassemble --source --disassembler-options=force-thumb OFLAGS := --gap-fill 0xff @@ -6,5 +7,3 @@ OFLAGS := --gap-fill 0xff # use JLink Segger RTT by default RIOT_TERMINAL ?= jlink include $(RIOTMAKE)/tools/serial.inc.mk - -include $(RIOTMAKE)/tools/jlink.inc.mk diff --git a/boards/hifive1/Makefile.include b/boards/hifive1/Makefile.include index c77573986180..aeae4d23813c 100644 --- a/boards/hifive1/Makefile.include +++ b/boards/hifive1/Makefile.include @@ -6,8 +6,8 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # this board uses openocd with a custom reset command +PROGRAMMER ?= openocd OPENOCD_CMD_RESET_RUN =-c _reset -include $(RIOTMAKE)/tools/openocd.inc.mk # use our own openocd script to flash since HiFive1 has reset problems. FLASHER = $(RIOTBASE)/boards/hifive1/dist/flasher.sh diff --git a/boards/hifive1b/Makefile.include b/boards/hifive1b/Makefile.include index 5a385e615fb9..90bd58f5509b 100644 --- a/boards/hifive1b/Makefile.include +++ b/boards/hifive1b/Makefile.include @@ -12,13 +12,11 @@ ifeq (openocd,$(PROGRAMMER)) DEBUG_ADAPTER = jlink OPENOCD_TRANSPORT = jtag OPENOCD_PRE_FLASH_CMDS += "-c flash protect 0 1 last off" - include $(RIOTMAKE)/tools/openocd.inc.mk else ifeq (jlink,$(PROGRAMMER)) # setup JLink for flashing JLINK_DEVICE = FE310 JLINK_IF = JTAG FLASH_ADDR = 0x20010000 - include $(RIOTMAKE)/tools/jlink.inc.mk else $(error Programmer '$(PROGRAMMER)' not supported for board '$(BOARD)') endif diff --git a/boards/i-nucleo-lrwan1/Makefile.include b/boards/i-nucleo-lrwan1/Makefile.include index 75b3e98cd957..776a82e3a8cc 100644 --- a/boards/i-nucleo-lrwan1/Makefile.include +++ b/boards/i-nucleo-lrwan1/Makefile.include @@ -16,4 +16,4 @@ DEBUG_ADAPTER ?= stlink OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 # this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +PROGRAMMER ?= openocd diff --git a/boards/ikea-tradfri/Makefile.include b/boards/ikea-tradfri/Makefile.include index c614bff12ea8..2d2ef9911899 100644 --- a/boards/ikea-tradfri/Makefile.include +++ b/boards/ikea-tradfri/Makefile.include @@ -3,9 +3,9 @@ PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup JLink for flashing +PROGRAMMER ?= jlink JLINK_DEVICE = EFR32MG1PxxxF256 JLINK_PRE_FLASH = r -include $(RIOTMAKE)/tools/jlink.inc.mk # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk diff --git a/boards/im880b/Makefile.include b/boards/im880b/Makefile.include index af98ff23c0e7..ce909e3c169c 100644 --- a/boards/im880b/Makefile.include +++ b/boards/im880b/Makefile.include @@ -8,10 +8,9 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -DEBUG_ADAPTER ?= stlink - CFLAGS+=-DSX127X_TX_SWITCH CFLAGS+=-DSX127X_RX_SWITCH # this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +PROGRAMMER ?= openocd +DEBUG_ADAPTER ?= stlink diff --git a/boards/limifrog-v1/Makefile.include b/boards/limifrog-v1/Makefile.include index cbb09c40f140..0db09eac692c 100644 --- a/boards/limifrog-v1/Makefile.include +++ b/boards/limifrog-v1/Makefile.include @@ -8,8 +8,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd with st-link +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink STLINK_VERSION ?= 2 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/lsn50/Makefile.include b/boards/lsn50/Makefile.include index 3c735348baef..3a7458812368 100644 --- a/boards/lsn50/Makefile.include +++ b/boards/lsn50/Makefile.include @@ -8,12 +8,10 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -# By default, flash this board using an ST-link adapter -DEBUG_ADAPTER ?= stlink - +# this board uses openocd +PROGRAMMER ?= openocd # this board can become un-flashable after a hardfault, # use connect_assert_srst to always be able to flash or reset the boards. OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +# By default, flash this board using an ST-link adapter +DEBUG_ADAPTER ?= stlink diff --git a/boards/maple-mini/Makefile.include b/boards/maple-mini/Makefile.include index 09912771ba6d..93dcf09dd90f 100644 --- a/boards/maple-mini/Makefile.include +++ b/boards/maple-mini/Makefile.include @@ -8,7 +8,6 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd with st-link +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/mcb2388/Makefile.include b/boards/mcb2388/Makefile.include index 03862334e00e..b562bade294c 100644 --- a/boards/mcb2388/Makefile.include +++ b/boards/mcb2388/Makefile.include @@ -1,9 +1,6 @@ # FLASHER will be lpc2k_pgm still DEBUG_ADAPTER ?= dap -PROGRAMMER ?= openocd - JLINK_DEVICE := LPC2388 OPENOCD_TRANSPORT := jtag include $(RIOTBOARD)/common/msba2/Makefile.include -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/mega-xplained/Makefile.include b/boards/mega-xplained/Makefile.include index 7bb1a39f28b4..2b6c726706c3 100644 --- a/boards/mega-xplained/Makefile.include +++ b/boards/mega-xplained/Makefile.include @@ -8,8 +8,8 @@ ifneq (,$(AVRDUDE_PORT)) PROG_DEV ?= $(AVRDUDE_PORT) endif -# PROGRAMMER defaults to the external flasher Bus Pirate ISP using avrdude. -PROGRAMMER ?= buspirate +# Avrdude programmer defaults to the external flasher Bus Pirate ISP. +AVRDUDE_PROGRAMMER ?= buspirate # set serial port for avrdude with buspirate ifeq ($(OS),Linux) PROG_DEV ?= /dev/ttyUSB0 diff --git a/boards/microbit/Makefile.include b/boards/microbit/Makefile.include index 388569066b8c..723e24aef053 100644 --- a/boards/microbit/Makefile.include +++ b/boards/microbit/Makefile.include @@ -7,8 +7,6 @@ PROGRAMMER ?= openocd ifeq (openocd,$(PROGRAMMER)) DEBUG_ADAPTER = dap -else ifeq (pyocd,$(PROGRAMMER)) - include $(RIOTMAKE)/tools/pyocd.inc.mk endif # QEMU 4.0 added microbit system emulation. diff --git a/boards/microduino-corerf/Makefile.include b/boards/microduino-corerf/Makefile.include index af834a1a0dbc..d4d97640ba18 100644 --- a/boards/microduino-corerf/Makefile.include +++ b/boards/microduino-corerf/Makefile.include @@ -3,9 +3,9 @@ PORT_LINUX ?= /dev/ttyUSB0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) BAUD ?= 115200 -# PROGRAMMER defaults to UM232H which is a FT232H breakout board +# Avrdude programmer defaults to UM232H which is a FT232H breakout board # externally connected using wires PROGRAMMER_MICRODUINO_CORERF ?= UM232H -PROGRAMMER ?= $(PROGRAMMER_MICRODUINO_CORERF) +AVRDUDE_PROGRAMMER ?= $(PROGRAMMER_MICRODUINO_CORERF) include $(RIOTBOARD)/common/atmega/Makefile.include diff --git a/boards/msba2/Makefile.include b/boards/msba2/Makefile.include index 11f3351be173..15bd4578825d 100644 --- a/boards/msba2/Makefile.include +++ b/boards/msba2/Makefile.include @@ -1,2 +1 @@ include $(RIOTBOARD)/common/msba2/Makefile.include -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/mulle/Makefile.include b/boards/mulle/Makefile.include index aa2eb19d7461..8438f2acf8c7 100644 --- a/boards/mulle/Makefile.include +++ b/boards/mulle/Makefile.include @@ -3,19 +3,12 @@ ifdef MULLE_SERIAL CFLAGS += -DMULLE_SERIAL=$(MULLE_SERIAL) endif +# this board uses openocd +PROGRAMMER ?= openocd + # Default debug adapter choice is to use the Mulle programmer board DEBUG_ADAPTER ?= mulle -# Fall back to PROGRAMMER_SERIAL for backwards compatibility -DEBUG_ADAPTER_ID ?= $(PROGRAMMER_SERIAL) - -# Define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial*))) - -# setup serial terminal -include $(RIOTMAKE)/tools/serial.inc.mk - # We need special handling of the watchdog if we want to speed up the flash # verification by using the MCU to compute the image checksum after flashing. # wdog-disable.bin is a precompiled binary which will disable the watchdog and @@ -25,5 +18,12 @@ OPENOCD_PRE_VERIFY_CMDS += \ -c 'resume 0x20000000' PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield.sh -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +# Fall back to PROGRAMMER_SERIAL for backwards compatibility +DEBUG_ADAPTER_ID ?= $(PROGRAMMER_SERIAL) + +# Define the default port depending on the host OS +PORT_LINUX ?= /dev/ttyUSB0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial*))) + +# setup serial terminal +include $(RIOTMAKE)/tools/serial.inc.mk diff --git a/boards/nrf51dk/Makefile.include b/boards/nrf51dk/Makefile.include index e92673947eb4..97b74cb6a4b4 100644 --- a/boards/nrf51dk/Makefile.include +++ b/boards/nrf51dk/Makefile.include @@ -8,8 +8,6 @@ PROGRAMMER ?= openocd # dap debug adapter is required for openocd ifeq (openocd,$(PROGRAMMER)) DEBUG_ADAPTER = dap -else ifeq (pyocd, $(PROGRAMMER)) # this boards is also supported by PyOCD - include $(RIOTMAKE)/tools/pyocd.inc.mk endif # include nrf51 boards common configuration diff --git a/boards/nrf52832-mdk/Makefile.include b/boards/nrf52832-mdk/Makefile.include index c66a1e75636a..0d88a31228e5 100644 --- a/boards/nrf52832-mdk/Makefile.include +++ b/boards/nrf52832-mdk/Makefile.include @@ -7,7 +7,6 @@ ifeq (pyocd,$(PROGRAMMER)) # The board is not recognized automatically by pyocd, so the CPU target # option is passed explicitly FLASH_TARGET_TYPE ?= -t $(CPU) - include $(RIOTMAKE)/tools/pyocd.inc.mk else ifeq (openocd,$(PROGRAMMER)) DEBUG_ADAPTER = dap endif diff --git a/boards/nrf52840-mdk/Makefile.include b/boards/nrf52840-mdk/Makefile.include index b23420152699..c8c05b64b26b 100644 --- a/boards/nrf52840-mdk/Makefile.include +++ b/boards/nrf52840-mdk/Makefile.include @@ -7,7 +7,6 @@ ifeq (pyocd,$(PROGRAMMER)) # The board is not recognized automatically by pyocd, so the CPU target # option is passed explicitly FLASH_TARGET_TYPE ?= -t nrf52840 - include $(RIOTMAKE)/tools/pyocd.inc.mk else ifeq (openocd,$(PROGRAMMER)) DEBUG_ADAPTER = dap endif diff --git a/boards/nz32-sc151/Makefile.include b/boards/nz32-sc151/Makefile.include index b0c3f20059ff..289abdad4958 100644 --- a/boards/nz32-sc151/Makefile.include +++ b/boards/nz32-sc151/Makefile.include @@ -6,8 +6,8 @@ PORT_LINUX ?= /dev/ttyUSB0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # this board is flashed using DFU +PROGRAMMER ?= dfu-util DFU_USB_ID = 0483:df11 -include $(RIOTMAKE)/tools/dfu.inc.mk # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk diff --git a/boards/p-l496g-cell02/Makefile.include b/boards/p-l496g-cell02/Makefile.include index 12830047ede4..ca0735a91584 100644 --- a/boards/p-l496g-cell02/Makefile.include +++ b/boards/p-l496g-cell02/Makefile.include @@ -8,7 +8,6 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd with st-link +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/pba-d-01-kw2x/Makefile.include b/boards/pba-d-01-kw2x/Makefile.include index 2226f62b7597..9a80abc5d031 100644 --- a/boards/pba-d-01-kw2x/Makefile.include +++ b/boards/pba-d-01-kw2x/Makefile.include @@ -18,6 +18,9 @@ endif # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd +PROGRAMMER ?= openocd + # We need special handling of the watchdog if we want to speed up the flash # verification by using the MCU to compute the image checksum after flashing. # wdog-disable.bin is a precompiled binary which will disable the watchdog and @@ -32,6 +35,3 @@ DEBUG_ADAPTER ?= dap # The board can become un-flashable after some firmware, use connect_assert_srst # to always be able to flash or reset the board. OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/pic32-wifire/Makefile.include b/boards/pic32-wifire/Makefile.include index 0317c1edc6f4..62686ed9f889 100644 --- a/boards/pic32-wifire/Makefile.include +++ b/boards/pic32-wifire/Makefile.include @@ -15,10 +15,8 @@ ifeq ($(PROGRAMMER),pic32prog) # * The triangle `▶` goes into the port number 1 (a hole with a square around it) # opposite side of the JP1 ICSP text. FLASHFILE ?= $(HEXFILE) - include $(RIOTMAKE)/tools/pic32prog.inc.mk else ifeq ($(PROGRAMMER),jlink) FLASHFILE ?= $(HEXFILE) JLINK_DEVICE = PIC32MZ2048EFG100 JLINK_IF = JTAG - include $(RIOTMAKE)/tools/jlink.inc.mk endif diff --git a/boards/pinetime/Makefile.include b/boards/pinetime/Makefile.include index 34a9c038434e..2cefa7c712fd 100644 --- a/boards/pinetime/Makefile.include +++ b/boards/pinetime/Makefile.include @@ -5,7 +5,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk # define pyocd as programmer to program with stlink ifeq (pyocd,$(PROGRAMMER)) FLASH_TARGET_TYPE ?= -t $(CPU) - include $(RIOTMAKE)/tools/pyocd.inc.mk endif # use shared Makefile.include diff --git a/boards/pyboard/Makefile.include b/boards/pyboard/Makefile.include index a06daf87c879..2d3278640204 100644 --- a/boards/pyboard/Makefile.include +++ b/boards/pyboard/Makefile.include @@ -9,6 +9,6 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) include $(RIOTMAKE)/tools/serial.inc.mk # this board is flashed using DFU +PROGRAMMER ?= dfu-util DFU_USB_ID = 1d50:607f FFLAGS_OPTS = --reset -include $(RIOTMAKE)/tools/dfu.inc.mk diff --git a/boards/seeeduino_arch-pro/Makefile.include b/boards/seeeduino_arch-pro/Makefile.include index af2a408e0045..a2ded0a9f619 100644 --- a/boards/seeeduino_arch-pro/Makefile.include +++ b/boards/seeeduino_arch-pro/Makefile.include @@ -5,6 +5,10 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk + +# this board uses openocd with an HEXFILE +PROGRAMMER ?= openocd +FLASHFILE ?= $(HEXFILE) DEBUG_ADAPTER ?= dap # generate image checksum from hex file @@ -12,7 +16,3 @@ PRE_FLASH_CHECK_SCRIPT = lpc_checksum --format hex # remap flash to address 0x0, otherwise it verifies the rom bootloader OPENOCD_PRE_VERIFY_CMDS += '-c reset init' - -# this board uses openocd with an HEXFILE -FLASHFILE ?= $(HEXFILE) -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/sensebox_samd21/Makefile.include b/boards/sensebox_samd21/Makefile.include index 0139d90fb5c7..7498bd70e300 100644 --- a/boards/sensebox_samd21/Makefile.include +++ b/boards/sensebox_samd21/Makefile.include @@ -4,17 +4,17 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# by default, we use BOSSA to flash this board to take into account the +# pre-flashed Arduino bootloader +PROGRAMMER ?= bossa + # setup the flash tool used ifeq ($(PROGRAMMER),jlink) # in case J-Link is attached to SWD pins, use a plain CPU memory model JLINK_DEVICE = atsamd21 - include $(RIOTMAKE)/tools/jlink.inc.mk -else - # by default, we use BOSSA to flash this board to take into account the - # pre-flashed Arduino bootloader. ROM_OFFSET skips the space taken by - # such bootloader. +else ifeq ($(PROGRAMMER),bossa) + # ROM_OFFSET skips the space taken by the pre-flashed Arduino bootloader. ROM_OFFSET ?= 0x2000 - include $(RIOTMAKE)/tools/bossa.inc.mk endif # setup the boards dependencies diff --git a/boards/spark-core/Makefile.include b/boards/spark-core/Makefile.include index 06c8e18cda9e..5150889ad6a1 100644 --- a/boards/spark-core/Makefile.include +++ b/boards/spark-core/Makefile.include @@ -11,8 +11,5 @@ include $(RIOTMAKE)/tools/serial.inc.mk ROM_OFFSET ?= 0x5000 # this board is flashed using DFU +PROGRAMMER ?= dfu-util DFU_USB_ID = 1d50:607f -include $(RIOTMAKE)/tools/dfu.inc.mk - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/stm32f0discovery/Makefile.include b/boards/stm32f0discovery/Makefile.include index 4bb429e4f140..d7b0d948faab 100644 --- a/boards/stm32f0discovery/Makefile.include +++ b/boards/stm32f0discovery/Makefile.include @@ -8,8 +8,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink STLINK_VERSION ?= 2 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/stm32f3discovery/Makefile.include b/boards/stm32f3discovery/Makefile.include index cf7a23963dab..a8e44865fdc8 100644 --- a/boards/stm32f3discovery/Makefile.include +++ b/boards/stm32f3discovery/Makefile.include @@ -8,12 +8,11 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink STLINK_VERSION ?= 2 # The board can become un-flashable after some execution, # use connect_assert_srst to always be able to flash or reset the board. OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/stm32f429i-disc1/Makefile.include b/boards/stm32f429i-disc1/Makefile.include index 1c1c84ed83ef..c7fcb2908ef6 100644 --- a/boards/stm32f429i-disc1/Makefile.include +++ b/boards/stm32f429i-disc1/Makefile.include @@ -8,8 +8,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd +PROGRAMMER ?= openocd # this board has an on-board ST-link adapter DEBUG_ADAPTER ?= stlink - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/stm32f4discovery/Makefile.include b/boards/stm32f4discovery/Makefile.include index 00abe5fd9858..cd82b7ff17d2 100644 --- a/boards/stm32f4discovery/Makefile.include +++ b/boards/stm32f4discovery/Makefile.include @@ -8,8 +8,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd with st-link +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink STLINK_VERSION ?= 2 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/stm32f723e-disco/Makefile.include b/boards/stm32f723e-disco/Makefile.include index 1c1c84ed83ef..6f489f83ed56 100644 --- a/boards/stm32f723e-disco/Makefile.include +++ b/boards/stm32f723e-disco/Makefile.include @@ -8,8 +8,8 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd +PROGRAMMER ?= openocd + # this board has an on-board ST-link adapter DEBUG_ADAPTER ?= stlink - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/stm32f769i-disco/Makefile.include b/boards/stm32f769i-disco/Makefile.include index 1c1c84ed83ef..4f6e0d4dd371 100644 --- a/boards/stm32f769i-disco/Makefile.include +++ b/boards/stm32f769i-disco/Makefile.include @@ -8,8 +8,8 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd with st-link +PROGRAMMER ?= openocd + # this board has an on-board ST-link adapter DEBUG_ADAPTER ?= stlink - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/stm32l0538-disco/Makefile.include b/boards/stm32l0538-disco/Makefile.include index b02b2e36c33f..4c306645ccc6 100644 --- a/boards/stm32l0538-disco/Makefile.include +++ b/boards/stm32l0538-disco/Makefile.include @@ -8,7 +8,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -DEBUG_ADAPTER ?= stlink +# this board uses openocd with st-link +PROGRAMMER ?= openocd -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk +DEBUG_ADAPTER ?= stlink diff --git a/boards/stm32l476g-disco/Makefile.include b/boards/stm32l476g-disco/Makefile.include index 12830047ede4..ca0735a91584 100644 --- a/boards/stm32l476g-disco/Makefile.include +++ b/boards/stm32l476g-disco/Makefile.include @@ -8,7 +8,6 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd with st-link +PROGRAMMER ?= openocd DEBUG_ADAPTER ?= stlink - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/ublox-c030-u201/Makefile.include b/boards/ublox-c030-u201/Makefile.include index 1f308959a0e9..a309ac1f9961 100644 --- a/boards/ublox-c030-u201/Makefile.include +++ b/boards/ublox-c030-u201/Makefile.include @@ -8,8 +8,8 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk +# this board uses openocd with st-link +PROGRAMMER ?= openocd + DEBUG_ADAPTER ?= stlink STLINK_VERSION ?= 2-1 - -# this board uses openocd -include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/yunjia-nrf51822/Makefile.include b/boards/yunjia-nrf51822/Makefile.include index 4d2684bf1374..914df9248500 100644 --- a/boards/yunjia-nrf51822/Makefile.include +++ b/boards/yunjia-nrf51822/Makefile.include @@ -6,8 +6,5 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) DEBUG_ADAPTER ?= stlink STLINK_VERSION ?= 2 -# use openocd to program this board -PROGRAMMER = openocd - # import nrf51 boards common configuration include $(RIOTBOARD)/common/nrf51/Makefile.include diff --git a/makefiles/boards/sam0.inc.mk b/makefiles/boards/sam0.inc.mk index 8948d6545e7d..fec2026a48af 100644 --- a/makefiles/boards/sam0.inc.mk +++ b/makefiles/boards/sam0.inc.mk @@ -43,14 +43,8 @@ ifeq ($(PROGRAMMER),) endif ifeq ($(PROGRAMMER),edbg) - # use edbg for flashing + # use edbg for flashing. must be included before openocd include $(RIOTMAKE)/tools/edbg.inc.mk # use openocd for debugging include $(RIOTMAKE)/tools/openocd.inc.mk -else ifeq ($(PROGRAMMER),jlink) - # this board uses J-Link for debug and possibly flashing - include $(RIOTMAKE)/tools/jlink.inc.mk -else ifeq ($(PROGRAMMER),openocd) - # this board uses openocd for debug and possibly flashing - include $(RIOTMAKE)/tools/openocd.inc.mk endif diff --git a/makefiles/boards/stm32.inc.mk b/makefiles/boards/stm32.inc.mk index 0ba48978d3e5..37fb5453783e 100644 --- a/makefiles/boards/stm32.inc.mk +++ b/makefiles/boards/stm32.inc.mk @@ -28,18 +28,10 @@ ifeq (openocd,$(PROGRAMMER)) # For STM32 boards the ST-link adapter is the default adapter, e.g. all # Nucleo boards have an on-board ST-link adapter DEBUG_ADAPTER ?= stlink - - # RIOT uses openocd by default - include $(RIOTMAKE)/tools/openocd.inc.mk -endif - -ifeq (bmp,$(PROGRAMMER)) - include $(RIOTMAKE)/tools/bmp.inc.mk endif ifeq (jlink,$(PROGRAMMER)) JLINK_DEVICE ?= $(CPU_MODEL) - include $(RIOTMAKE)/tools/jlink.inc.mk endif ifeq (dfu-util,$(PROGRAMMER)) @@ -51,7 +43,6 @@ ifeq (dfu-util,$(PROGRAMMER)) ifeq (,$(DFU_USB_ID)) $(error DFU_USB_ID is not set) endif - include $(RIOTMAKE)/tools/dfu.inc.mk endif ifeq (stm32flash,$(PROGRAMMER)) diff --git a/makefiles/tools/avrdude.inc.mk b/makefiles/tools/avrdude.inc.mk index 6d6003d8a4fd..85bb78492f49 100644 --- a/makefiles/tools/avrdude.inc.mk +++ b/makefiles/tools/avrdude.inc.mk @@ -19,22 +19,22 @@ DEBUGSERVER_FLAGS = "$(AVR_DEBUGDEVICE) $(DEBUGPROTO) :$(DEBUGSERVER_PORT)" DEBUGGER_FLAGS = "-x $(AVARICE_PATH)/gdb.conf $(ELFFILE)" DEBUGGER = "$(AVARICE_PATH)/debug.sh" $(DEBUGSERVER_FLAGS) $(AVARICE_PATH) $(DEBUGSERVER_PORT) -PROGRAMMER_FLAGS = -p $(subst atmega,m,$(CPU)) +AVRDUDE_PROGRAMMER_FLAGS = -p $(subst atmega,m,$(CPU)) # Set flasher port only for programmers that require it -ifneq (,$(filter $(PROGRAMMER),arduino avr109 buspirate stk500v1 stk500v2 wiring)) +ifneq (,$(filter $(AVRDUDE_PROGRAMMER),arduino avr109 buspirate stk500v1 stk500v2 wiring)) # make the flasher port configurable (e.g. with atmelice the port is usb) # defaults to terminal's serial port if not configured - PROGRAMMER_FLAGS += -P $(PROG_DEV) + AVRDUDE_PROGRAMMER_FLAGS += -P $(PROG_DEV) endif -PROGRAMMER_FLAGS += $(FFLAGS_EXTRA) +AVRDUDE_PROGRAMMER_FLAGS += $(FFLAGS_EXTRA) # don't force to flash HEXFILE, but set it as default FLASHFILE ?= $(HEXFILE) -FFLAGS += -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -U flash:w:$(FLASHFILE) +FFLAGS += -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PROGRAMMER_FLAGS) -U flash:w:$(FLASHFILE) -ifeq (,$(filter $(PROGRAMMER),arduino avr109 stk500v1 stk500v2 wiring)) +ifeq (,$(filter $(AVRDUDE_PROGRAMMER),arduino avr109 stk500v1 stk500v2 wiring)) # Use avrdude to trigger a reset, if programming is not done via UART and a # bootloader. - RESET ?= $(FLASHER) -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) + RESET ?= $(FLASHER) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PROGRAMMER_FLAGS) endif diff --git a/makefiles/tools/dfu.inc.mk b/makefiles/tools/dfu-util.inc.mk similarity index 100% rename from makefiles/tools/dfu.inc.mk rename to makefiles/tools/dfu-util.inc.mk From 3bafb6e2bce51cda8419519c09a5352320d0a8a2 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 24 Nov 2020 14:47:05 +0100 Subject: [PATCH 3/3] makefiles/edbg: include openocd.inc.mk to define debug vars --- makefiles/boards/sam0.inc.mk | 7 ------- makefiles/tools/edbg.inc.mk | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/makefiles/boards/sam0.inc.mk b/makefiles/boards/sam0.inc.mk index fec2026a48af..debdebe33d73 100644 --- a/makefiles/boards/sam0.inc.mk +++ b/makefiles/boards/sam0.inc.mk @@ -41,10 +41,3 @@ ifeq ($(PROGRAMMER),) PROGRAMMER ?= openocd endif endif - -ifeq ($(PROGRAMMER),edbg) - # use edbg for flashing. must be included before openocd - include $(RIOTMAKE)/tools/edbg.inc.mk - # use openocd for debugging - include $(RIOTMAKE)/tools/openocd.inc.mk -endif diff --git a/makefiles/tools/edbg.inc.mk b/makefiles/tools/edbg.inc.mk index 472146567e81..2fe20b108412 100644 --- a/makefiles/tools/edbg.inc.mk +++ b/makefiles/tools/edbg.inc.mk @@ -31,3 +31,7 @@ define edbg-flash-recipe endef flash-recipe = $(edbg-flash-recipe) + +# use openocd for debugging, must be included at the end so FLASHER/RESET +# variables are already set for edbg. +include $(RIOTMAKE)/tools/openocd.inc.mk