From 4abc41a22787f5362bd2b52b1ce2011e9911eb73 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 20 Feb 2019 21:59:06 +0100 Subject: [PATCH] makefiles/tools: Automatically set avrdude target The CPU variable in the boards Makefile.include file already contains the target CPU, so there is no reason to provide it in each board again as avrdude flag. This commit automatically sets the avrdude target from the CPU variable and removes the unneeded flags. --- boards/arduino-duemilanove/Makefile.include | 2 -- boards/arduino-mega2560/Makefile.include | 2 -- boards/arduino-uno/Makefile.include | 2 -- boards/jiminy-mega256rfr2/Makefile.include | 2 -- boards/mega-xplained/Makefile.include | 2 -- boards/waspmote-pro/Makefile.include | 2 -- makefiles/tools/avrdude.inc.mk | 2 ++ 7 files changed, 2 insertions(+), 12 deletions(-) diff --git a/boards/arduino-duemilanove/Makefile.include b/boards/arduino-duemilanove/Makefile.include index b736cb592..0de1385de 100644 --- a/boards/arduino-duemilanove/Makefile.include +++ b/boards/arduino-duemilanove/Makefile.include @@ -12,8 +12,6 @@ BAUD ?= 9600 # using avrdude. Can be overridden for debugging (which requires changes # that require to use an ISP) PROGRAMMER ?= arduino -# set mcu model for avrdude -FFLAGS += -p m328p # configure programmer speed in baud FFLAGS_EXTRA += -b 57600 diff --git a/boards/arduino-mega2560/Makefile.include b/boards/arduino-mega2560/Makefile.include index 676e8dc12..748d6f5f7 100644 --- a/boards/arduino-mega2560/Makefile.include +++ b/boards/arduino-mega2560/Makefile.include @@ -12,8 +12,6 @@ BAUD ?= 9600 # using avrdude. Can be overridden for debugging (which requires changes # that require to use an ISP) PROGRAMMER ?= stk500v2 -# set mcu model for avrdude -FFLAGS += -p m2560 # configure programmer speed in baud FFLAGS_EXTRA += -b 115200 diff --git a/boards/arduino-uno/Makefile.include b/boards/arduino-uno/Makefile.include index 6e0f63b77..1d413161b 100644 --- a/boards/arduino-uno/Makefile.include +++ b/boards/arduino-uno/Makefile.include @@ -12,8 +12,6 @@ BAUD ?= 9600 # using avrdude. Can be overridden for debugging (which requires changes # that require to use an ISP) PROGRAMMER ?= arduino -# set mcu model for avrdude -FFLAGS += -p m328p # configure programmer speed in baud FFLAGS_EXTRA += -b 115200 diff --git a/boards/jiminy-mega256rfr2/Makefile.include b/boards/jiminy-mega256rfr2/Makefile.include index a1b36bccd..7d8b4b7e2 100644 --- a/boards/jiminy-mega256rfr2/Makefile.include +++ b/boards/jiminy-mega256rfr2/Makefile.include @@ -15,8 +15,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk # using avrdude. Can be overridden for debugging (which requires changes # that require to use an ISP) PROGRAMMER ?= wiring -# set mcu model for avrdude (mandatory) -FFLAGS += -p atmega256rfr2 # Serial Baud rate for flasher is configured to 500kBaud # see /usr/include/asm-generic/termbits.h for availabel baudrates on your linux system FFLAGS_EXTRA += -b 0010005 diff --git a/boards/mega-xplained/Makefile.include b/boards/mega-xplained/Makefile.include index 891fb8f5c..c82bb65d2 100644 --- a/boards/mega-xplained/Makefile.include +++ b/boards/mega-xplained/Makefile.include @@ -14,8 +14,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk # PROGRAMMER defaults to the external flasher Bus Pirate ISP using avrdude. PROGRAMMER ?= buspirate -# set mcu model for avrdude -FFLAGS += -p m1284p # set serial port for avrdude with buspirate ifeq ($(OS),Linux) AVRDUDE_PORT ?= /dev/ttyUSB0 diff --git a/boards/waspmote-pro/Makefile.include b/boards/waspmote-pro/Makefile.include index 6a098e05e..bd13a546b 100644 --- a/boards/waspmote-pro/Makefile.include +++ b/boards/waspmote-pro/Makefile.include @@ -17,8 +17,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk # using avrdude. Can be overridden for debugging (which requires changes # that require to use an ISP) PROGRAMMER ?= stk500v1 -# set mcu model for avrdude -FFLAGS += -p m1281 # configure programmer speed in baud FFLAGS_EXTRA += -b 115200 # avoid error if mcu signature doesn't match diff --git a/makefiles/tools/avrdude.inc.mk b/makefiles/tools/avrdude.inc.mk index 148db4c1a..8cde4f33f 100644 --- a/makefiles/tools/avrdude.inc.mk +++ b/makefiles/tools/avrdude.inc.mk @@ -6,6 +6,8 @@ DEBUGSERVER_FLAGS = "-g -j usb :$(DEBUGSERVER_PORT)" DEBUGGER_FLAGS = "-x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)" DEBUGGER = $(DIST_PATH)/debug.sh $(DEBUGSERVER_FLAGS) $(DIST_PATH) $(DEBUGSERVER_PORT) +PROGRAMMER_FLAGS = -p $(subst atmega,m,$(CPU)) + # Set flasher port only for programmers that require it ifneq (,$(filter $(PROGRAMMER),arduino buspirate stk500v1 stk500v2 wiring)) # make the flasher port configurable (e.g. with atmelice the port is usb)