diff --git a/boards/arduino-common/Makefile b/boards/arduino-atmega-common/Makefile
similarity index 53%
rename from boards/arduino-common/Makefile
rename to boards/arduino-atmega-common/Makefile
index 233ad5878bf695219b4758fc5d96847ea88415da..b2ec734f93a3e29efbcecea072e48d7ad483f9e1 100644
--- a/boards/arduino-common/Makefile
+++ b/boards/arduino-atmega-common/Makefile
@@ -1,3 +1,3 @@
-MODULE = arduino-common
+MODULE = arduino-atmega-common
 
 include $(RIOTBASE)/Makefile.base
diff --git a/boards/arduino-common/Makefile.dep b/boards/arduino-atmega-common/Makefile.dep
similarity index 100%
rename from boards/arduino-common/Makefile.dep
rename to boards/arduino-atmega-common/Makefile.dep
diff --git a/boards/arduino-common/Makefile.features b/boards/arduino-atmega-common/Makefile.features
similarity index 100%
rename from boards/arduino-common/Makefile.features
rename to boards/arduino-atmega-common/Makefile.features
diff --git a/boards/arduino-atmega-common/Makefile.include b/boards/arduino-atmega-common/Makefile.include
new file mode 100644
index 0000000000000000000000000000000000000000..0f008fcffd89c3fce634ea925fdaa6b55d9c2fff
--- /dev/null
+++ b/boards/arduino-atmega-common/Makefile.include
@@ -0,0 +1,29 @@
+# include optional dependencies
+include $(RIOTBOARD)/arduino-atmega-common/Makefile.dep
+
+# define port used to flash the board
+OS = $(shell uname)
+ifeq ($(OS),Linux)
+  PORT = $(PORT_LINUX)
+else ifeq ($(OS),Darwin)
+  PORT ?= $(PORT_DARWIN)
+else
+  $(info CAUTION: No flash tool for your host system found!)
+  # TODO: fix for building under windows
+endif
+
+export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
+export TERMFLAGS ?= -b 9600 -p $(PORT)
+export FLASHER = avrdude
+export PORT
+export DIST_PATH = $(RIOTBOARD)/$(BOARD)/dist
+export DEBUGSERVER_PORT = 4242
+export DEBUGSERVER = $(DIST_PATH)/debug_srv.sh
+export DEBUGSERVER_FLAGS = "-g -j usb :$(DEBUGSERVER_PORT)"
+export DEBUGGER_FLAGS = "-x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)"
+export DEBUGGER = $(DIST_PATH)/debug.sh $(DEBUGSERVER_FLAGS) $(DIST_PATH) $(DEBUGSERVER_PORT)
+
+export PROGRAMMER_FLAGS = -P $(PORT) -b $(PROGRAMMER_SPEED)
+
+export OFLAGS += -j .text -j .data -O ihex
+export FFLAGS += -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -D -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex
diff --git a/boards/arduino-common/board.c b/boards/arduino-atmega-common/board.c
similarity index 91%
rename from boards/arduino-common/board.c
rename to boards/arduino-atmega-common/board.c
index abca37ac28cc72c6b5a1038ab547a3d2d09d14da..0442c112f8349354a5b2464af05cc735d27fee72 100644
--- a/boards/arduino-common/board.c
+++ b/boards/arduino-atmega-common/board.c
@@ -9,7 +9,7 @@
  */
 
 /**
- * @ingroup     boards_arduino-common
+ * @ingroup     boards_arduino-atmega-common
  * @{
  *
  * @file
@@ -29,6 +29,7 @@
 #include "board.h"
 #include "cpu.h"
 #include "uart_stdio.h"
+#include "periph/gpio.h"
 
 void led_init(void);
 void SystemInit(void);
@@ -46,9 +47,9 @@ void board_init(void)
     /* initialize the CPU */
     cpu_init();
 
-    /* initialize the board LED (connected to pin PB5) */
-    DDRB |= (1 << DDB5);
-    PORTB &= ~(1 << 5);
+    /* initialize the board LED */
+    gpio_init(LED0_PIN, GPIO_OUT);
+    LED0_OFF;
 
     irq_enable();
 }
diff --git a/boards/arduino-common/dist/debug.sh b/boards/arduino-atmega-common/dist/debug.sh
old mode 100755
new mode 100644
similarity index 100%
rename from boards/arduino-common/dist/debug.sh
rename to boards/arduino-atmega-common/dist/debug.sh
diff --git a/boards/arduino-common/dist/debug_srv.sh b/boards/arduino-atmega-common/dist/debug_srv.sh
old mode 100755
new mode 100644
similarity index 100%
rename from boards/arduino-common/dist/debug_srv.sh
rename to boards/arduino-atmega-common/dist/debug_srv.sh
diff --git a/boards/arduino-common/dist/gdb.conf b/boards/arduino-atmega-common/dist/gdb.conf
similarity index 100%
rename from boards/arduino-common/dist/gdb.conf
rename to boards/arduino-atmega-common/dist/gdb.conf
diff --git a/boards/arduino-common/include/arduino_board.h b/boards/arduino-atmega-common/include/arduino_board.h
similarity index 52%
rename from boards/arduino-common/include/arduino_board.h
rename to boards/arduino-atmega-common/include/arduino_board.h
index e589511d3679249d9b279e8af904a2a58530022f..f05d3125898a47a122d265b41c3f4e7bea7e9462 100644
--- a/boards/arduino-common/include/arduino_board.h
+++ b/boards/arduino-atmega-common/include/arduino_board.h
@@ -7,7 +7,7 @@
  */
 
 /**
- * @ingroup     boards_arduino-common
+ * @ingroup     boards_arduino-atmega-common
  * @{
  *
  * @file
@@ -54,7 +54,59 @@ static const gpio_t arduino_pinmap[] = {
     ARDUINO_PIN_16,
     ARDUINO_PIN_17,
     ARDUINO_PIN_18,
-    ARDUINO_PIN_19
+    ARDUINO_PIN_19,
+#ifdef CPU_ATMEGA2560
+    ARDUINO_PIN_20,
+    ARDUINO_PIN_21,
+    ARDUINO_PIN_22,
+    ARDUINO_PIN_23,
+    ARDUINO_PIN_24,
+    ARDUINO_PIN_25,
+    ARDUINO_PIN_26,
+    ARDUINO_PIN_27,
+    ARDUINO_PIN_28,
+    ARDUINO_PIN_29,
+    ARDUINO_PIN_30,
+    ARDUINO_PIN_31,
+    ARDUINO_PIN_32,
+    ARDUINO_PIN_33,
+    ARDUINO_PIN_34,
+    ARDUINO_PIN_35,
+    ARDUINO_PIN_36,
+    ARDUINO_PIN_37,
+    ARDUINO_PIN_38,
+    ARDUINO_PIN_39,
+    ARDUINO_PIN_40,
+    ARDUINO_PIN_41,
+    ARDUINO_PIN_42,
+    ARDUINO_PIN_43,
+    ARDUINO_PIN_44,
+    ARDUINO_PIN_45,
+    ARDUINO_PIN_46,
+    ARDUINO_PIN_47,
+    ARDUINO_PIN_48,
+    ARDUINO_PIN_49,
+    ARDUINO_PIN_50,
+    ARDUINO_PIN_51,
+    ARDUINO_PIN_52,
+    ARDUINO_PIN_53,
+    ARDUINO_PIN_54,
+    ARDUINO_PIN_55,
+    ARDUINO_PIN_56,
+    ARDUINO_PIN_57,
+    ARDUINO_PIN_58,
+    ARDUINO_PIN_59,
+    ARDUINO_PIN_60,
+    ARDUINO_PIN_61,
+    ARDUINO_PIN_62,
+    ARDUINO_PIN_63,
+    ARDUINO_PIN_64,
+    ARDUINO_PIN_65,
+    ARDUINO_PIN_66,
+    ARDUINO_PIN_67,
+    ARDUINO_PIN_68,
+    ARDUINO_PIN_69
+#endif
 };
 
 #ifdef __cplusplus
diff --git a/boards/arduino-mega2560/include/arduino_pinmap.h b/boards/arduino-atmega-common/include/arduino_pinmap.h
similarity index 76%
rename from boards/arduino-mega2560/include/arduino_pinmap.h
rename to boards/arduino-atmega-common/include/arduino_pinmap.h
index 8d5480895b41089c8edd5ef4f5010f6bc4cd2417..30fc88c1cb86bfe088a7d37109082d17221d33f5 100644
--- a/boards/arduino-mega2560/include/arduino_pinmap.h
+++ b/boards/arduino-atmega-common/include/arduino_pinmap.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 Freie Universität Berlin
+ *               2016 Laurent Navet <laurent.navet@gmail.com>
  *
  * This file is subject to the terms and conditions of the GNU Lesser
  * General Public License v2.1. See the file LICENSE in the top level
@@ -7,7 +8,7 @@
  */
 
 /**
- * @ingroup     boards_arduino-mega2560
+ * @ingroup     boards_arduino-atmega-common
  * @{
  *
  * @file
@@ -18,6 +19,7 @@
  *
  * @author      Hauke Petersen <hauke.petersen@fu-berlin.de>
  * @author      Daniel Nordahl <nordahl.d@gmail.com>
+ * @author      Laurent Navet <laurent.navet@gmail.com>
  */
 
 #ifndef ARDUINO_PINMAP_H
@@ -32,6 +34,40 @@ extern "C" {
  *
  * @note    ISCP pins are not mapped.
  */
+
+/* Digital pins */
+#ifdef CPU_ATMEGA328P
+#define ARDUINO_PIN_0           GPIO_PIN(PORT_D, 0)
+#define ARDUINO_PIN_1           GPIO_PIN(PORT_D, 1)
+#define ARDUINO_PIN_2           GPIO_PIN(PORT_D, 2)
+#define ARDUINO_PIN_3           GPIO_PIN(PORT_D, 3)
+#define ARDUINO_PIN_4           GPIO_PIN(PORT_D, 4)
+#define ARDUINO_PIN_5           GPIO_PIN(PORT_D, 5)
+#define ARDUINO_PIN_6           GPIO_PIN(PORT_D, 6)
+#define ARDUINO_PIN_7           GPIO_PIN(PORT_D, 7)
+#define ARDUINO_PIN_8           GPIO_PIN(PORT_B, 0)
+#define ARDUINO_PIN_9           GPIO_PIN(PORT_B, 1)
+#define ARDUINO_PIN_10          GPIO_PIN(PORT_B, 2)
+#define ARDUINO_PIN_11          GPIO_PIN(PORT_B, 3)
+#define ARDUINO_PIN_12          GPIO_PIN(PORT_B, 4)
+#define ARDUINO_PIN_13          GPIO_PIN(PORT_B, 5)
+/* Analog pins */
+#define ARDUINO_PIN_14          GPIO_PIN(PORT_C, 0)
+#define ARDUINO_PIN_15          GPIO_PIN(PORT_C, 1)
+#define ARDUINO_PIN_16          GPIO_PIN(PORT_C, 2)
+#define ARDUINO_PIN_17          GPIO_PIN(PORT_C, 3)
+#define ARDUINO_PIN_18          GPIO_PIN(PORT_C, 4)
+#define ARDUINO_PIN_19          GPIO_PIN(PORT_C, 5)
+/* Analog input */
+#define ARDUINO_PIN_A0          ARDUINO_PIN_14
+#define ARDUINO_PIN_A1          ARDUINO_PIN_15
+#define ARDUINO_PIN_A2          ARDUINO_PIN_16
+#define ARDUINO_PIN_A3          ARDUINO_PIN_17
+#define ARDUINO_PIN_A4          ARDUINO_PIN_18
+#define ARDUINO_PIN_A5          ARDUINO_PIN_19
+#endif
+
+#ifdef CPU_ATMEGA2560
 #define ARDUINO_PIN_0           GPIO_PIN(PORT_E, 0)
 #define ARDUINO_PIN_1           GPIO_PIN(PORT_E, 1)
 #define ARDUINO_PIN_2           GPIO_PIN(PORT_E, 4)
@@ -118,6 +154,8 @@ extern "C" {
 #define ARDUINO_PIN_A13         ARDUINO_PIN_67
 #define ARDUINO_PIN_A14         ARDUINO_PIN_68
 #define ARDUINO_PIN_A15         ARDUINO_PIN_69
+#endif
+
 /** @ */
 
 #ifdef __cplusplus
diff --git a/boards/arduino-common/include/board.h b/boards/arduino-atmega-common/include/board.h
similarity index 80%
rename from boards/arduino-common/include/board.h
rename to boards/arduino-atmega-common/include/board.h
index 72f7fa933a89dacbe2bc115cab73ae912e8ff2ce..256e732d4afaf10babb97cd68fae637e1bbad63a 100644
--- a/boards/arduino-common/include/board.h
+++ b/boards/arduino-atmega-common/include/board.h
@@ -8,7 +8,7 @@
  */
 
 /**
- * @defgroup    boards_arduino-common Arduino common
+ * @defgroup    boards_arduino-atmega-common Arduino common
  * @ingroup     boards
  * @brief       Board specific files for the arduino Uno and
  * @brief       Duemilanove boards.
@@ -44,9 +44,15 @@ extern "C" {
  * @brief   LED pin definitions and handlers
  * @{
  */
+#ifdef CPU_ATMEGA328P
 #define LED0_PIN            GPIO_PIN(1, 5)
-
 #define LED0_MASK           (1 << DDB5)
+#endif
+
+#ifdef CPU_ATMEGA2560
+#define LED0_PIN            GPIO_PIN(1, 7)
+#define LED0_MASK           (1 << DDB7)
+#endif
 
 #define LED0_ON             (PORTB |=  LED0_MASK)
 #define LED0_OFF            (PORTB &= ~LED0_MASK)
@@ -58,6 +64,7 @@ extern "C" {
  ** Setup to use PC5 which is pin change interrupt 13 (PCINT13)
  ** This emulates a software triggered interrupt
  ***/
+#ifdef CPU_ATMEGA328P
 #define AVR_CONTEXT_SWAP_INIT do { \
             DDRC |= (1 << PC5); \
             PCICR |= (1 << PCIE1); \
@@ -65,7 +72,17 @@ extern "C" {
 } while (0)
 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT  PCINT1_vect
 #define AVR_CONTEXT_SWAP_TRIGGER   PORTC ^= (1 << PC5)
+#endif
 
+#ifdef CPU_ATMEGA2560
+#define AVR_CONTEXT_SWAP_INIT do { \
+    DDRJ |= (1 << PJ6); \
+    PCICR |= (1 << PCIE1); \
+    PCMSK1 |= (1 << PCINT15); \
+} while (0)
+#define AVR_CONTEXT_SWAP_INTERRUPT_VECT  PCINT1_vect
+#define AVR_CONTEXT_SWAP_TRIGGER   PORTJ ^= (1 << PJ6)
+#endif
 
 /**
  * @brief xtimer configuration values
diff --git a/boards/arduino-common/include/gpio_params.h b/boards/arduino-atmega-common/include/gpio_params.h
similarity index 94%
rename from boards/arduino-common/include/gpio_params.h
rename to boards/arduino-atmega-common/include/gpio_params.h
index bb502a0c2e60c7f13a4bff8596ab7c13388b9c5c..6f61915ff43e4b8f694932daf42660305b77fb72 100644
--- a/boards/arduino-common/include/gpio_params.h
+++ b/boards/arduino-atmega-common/include/gpio_params.h
@@ -7,7 +7,7 @@
  */
 
 /**
- * @ingroup   boards_arduino-common
+ * @ingroup   boards_arduino-atmega-common
  * @{
  *
  * @file
diff --git a/boards/arduino-mega2560/include/periph_conf.h b/boards/arduino-atmega-common/include/periph_conf.h
similarity index 63%
rename from boards/arduino-mega2560/include/periph_conf.h
rename to boards/arduino-atmega-common/include/periph_conf.h
index 45c1e89d3ffb37c1ca7a32172997a491c81185c0..a485208392799cc7ec056ec79a19fba6d198929b 100644
--- a/boards/arduino-mega2560/include/periph_conf.h
+++ b/boards/arduino-atmega-common/include/periph_conf.h
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2014-2016 Freie Universität Berlin
- *               2014 Hinnerk van Bruinehsen
+ * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
+ *               2016 Laurent Navet <laurent.navet@gmail.com>
  *
  * This file is subject to the terms and conditions of the GNU Lesser
  * General Public License v2.1. See the file LICENSE in the top level
@@ -8,13 +8,15 @@
  */
 
 /**
- * @ingroup     boards_arduino-mega2560
+ * @ingroup     boards_arduino-atmega-common
  * @{
  *
  * @file
- * @brief       Peripheral MCU configuration for the Arduino Mega 2560 board
+ * @brief       Peripheral MCU configuration for the arduino Uno and
+ * @brief       Dumilanove boards.
  *
  * @author      Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
+ * @author      Laurent Navet <laurent.navet@gmail.com>
  * @author      Hauke Petersen <hauke.petersen@fu-berlin.de>
  */
 
@@ -35,11 +37,27 @@ extern "C" {
 /**
  * @name   Timer configuration
  *
+ * arduino uno and arduino duemilanove:
+ * The timer driver only supports the 16-bit timer (Timer1)
+ * so this is the only one we can use here.
+ *
+ * arduino mega2560:
  * The timer driver only supports the four 16-bit timers (Timer1, Timer3,
  * Timer4, Timer5), so those are the only onces we can use here.
  *
  * @{
  */
+#ifdef CPU_ATMEGA328P
+#define TIMER_NUMOF         (2U)
+
+#define TIMER_0             MEGA_TIMER1
+#define TIMER_0_MASK        &TIMSK1
+#define TIMER_0_FLAG        &TIFR1
+#define TIMER_0_ISRA        TIMER1_COMPA_vect
+#define TIMER_0_ISRB        TIMER1_COMPB_vect
+#endif
+
+#ifdef CPU_ATMEGA2560
 #define TIMER_NUMOF         (2U)
 
 #define TIMER_0             MEGA_TIMER1
@@ -55,6 +73,9 @@ extern "C" {
 #define TIMER_1_ISRA        TIMER4_COMPA_vect
 #define TIMER_1_ISRB        TIMER4_COMPB_vect
 #define TIMER_1_ISRC        TIMER4_COMPC_vect
+#endif
+
+
 /** @} */
 
 /**
@@ -66,6 +87,14 @@ extern "C" {
  *
  * @{
  */
+#ifdef CPU_ATMEGA328P
+#define UART_NUMOF          (1U)
+
+#define UART_0              MEGA_UART0
+#define UART_0_ISR          USART_RX_vect
+#endif
+
+#ifdef CPU_ATMEGA2560
 #define UART_NUMOF          (4U)
 
 #define UART_0              MEGA_UART0
@@ -79,6 +108,7 @@ extern "C" {
 
 #define UART_3              MEGA_UART3
 #define UART_3_ISR          USART3_RX_vect
+#endif
 /** @} */
 
 /**
@@ -87,7 +117,13 @@ extern "C" {
  * The atmega2560 has only one hardware SPI with fixed pin configuration, so all
  * we can do here, is to enable or disable it...
  *
- * The fixed pins used, are:
+ * The fixed pins for arduino uno and duemilanove are:
+ * MOSI - PB3 (Arduino pin 11)
+ * MISO - PB4 (Arduino pin 12)
+ * SCK  - PB5 (Arduino pin 13)
+ * SS   - PB2 (Arduino pin 10) -> this pin is configured as output, but not used
+ *
+ * The fixed pins for arduino mega2560 are:
  * MOSI - PB2 (Arduino pin 51)
  * MISO - PB3 (Arduino pin 50)
  * SCK  - PB1 (Arduino pin 52)
@@ -96,7 +132,14 @@ extern "C" {
  * @{
  */
 #define SPI_NUMOF           1           /* set to 0 to disable SPI */
+
+#ifdef CPU_ATMEGA328P
+#define MEGA_PRR            PRR         /* Power Reduction Register is PRR */
+#endif
+
+#ifdef CPU_ATMEGA2560
 #define MEGA_PRR            PRR0        /* Power Reduction Register is PRR0 */
+#endif
 /** @} */
 
 #ifdef __cplusplus
diff --git a/boards/arduino-common/Makefile.include b/boards/arduino-common/Makefile.include
deleted file mode 100644
index 753113bd17bf074f6fe6ce3977a84ac0a252c433..0000000000000000000000000000000000000000
--- a/boards/arduino-common/Makefile.include
+++ /dev/null
@@ -1,47 +0,0 @@
-# define the cpu used by the arduino uno and duemilanove boards
-export CPU = atmega328p
-
-# include optional dependencies
-include $(RIOTBOARD)/arduino-common/Makefile.dep
-
-# define port used to flash the board
-OS = $(shell uname)
-ifeq ($(OS),Linux)
-		PORT = $(LINUX_PORT)
-else ifeq ($(OS),Darwin)
-  PORT ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
-else
-  $(info CAUTION: No flash tool for your host system found!)
-  # TODO: fix for building under windows
-endif
-
-export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
-export TERMFLAGS = -b 9600 -p $(PORT)
-export FLASHER = avrdude
-export PORT
-export DIST_PATH = $(RIOTBOARD)/$(BOARD)/dist
-export DEBUGSERVER_PORT = 4242
-export DEBUGSERVER = $(DIST_PATH)/debug_srv.sh
-export DEBUGSERVER_FLAGS = "-g -j usb :$(DEBUGSERVER_PORT)"
-export DEBUGGER_FLAGS = "-x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)"
-export DEBUGGER = $(DIST_PATH)/debug.sh $(DEBUGSERVER_FLAGS) $(DIST_PATH) $(DEBUGSERVER_PORT)
-
-# PROGRAMMER defaults to arduino which is the internal flasher via USB. Can be
-# overridden for debugging (which requires changes that require to use an ISP)
-export PROGRAMMER ?= arduino
-
-ifeq ($(PROGRAMMER), arduino)
-  export PROGRAMMER_FLAGS = -P $(PORT) -b $(PROGRAMMER_SPEED)
-endif
-
-# define build specific options
-export CFLAGS_CPU   = -mmcu=atmega328p  $(CFLAGS_FPU)
-export CFLAGS_LINK  = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
-export CFLAGS_DBG  ?= -ggdb -g3
-export CFLAGS_OPT  ?= -Os
-
-export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
-export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
-export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler
-export OFLAGS += -j .text -j .data -O ihex
-export FFLAGS += -p atmega328p -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -D -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex
diff --git a/boards/arduino-common/include/arduino_pinmap.h b/boards/arduino-common/include/arduino_pinmap.h
deleted file mode 100644
index 67e40677140e83f4adbb278af0ff68f3b0ca919c..0000000000000000000000000000000000000000
--- a/boards/arduino-common/include/arduino_pinmap.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2015 Freie Universität Berlin
- *               2016 Laurent Navet <laurent.navet@gmail.com>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- */
-
-/**
- * @ingroup     boards_arduino-common
- * @{
- *
- * @file
- * @brief       Mapping from MCU pins to Arduino pins
- *
- * You can use the defines in this file for simplified interaction with the
- * Arduino specific pin numbers.
- *
- * @author      Hauke Petersen <hauke.petersen@fu-berlin.de>
- * @author      Daniel Nordahl <nordahl.d@gmail.com>
- * @author      Laurent Navet <laurent.navet@gmail.com>
- */
-
-#ifndef ARDUINO_PINMAP_H
-#define ARDUINO_PINMAP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief   Mapping of MCU pins to Arduino pins
- *
- * @note    ISCP pins are not mapped.
- */
-
-/* Digital pins */
-#define ARDUINO_PIN_0           GPIO_PIN(PORT_D, 0)
-#define ARDUINO_PIN_1           GPIO_PIN(PORT_D, 1)
-#define ARDUINO_PIN_2           GPIO_PIN(PORT_D, 2)
-#define ARDUINO_PIN_3           GPIO_PIN(PORT_D, 3)
-#define ARDUINO_PIN_4           GPIO_PIN(PORT_D, 4)
-#define ARDUINO_PIN_5           GPIO_PIN(PORT_D, 5)
-#define ARDUINO_PIN_6           GPIO_PIN(PORT_D, 6)
-#define ARDUINO_PIN_7           GPIO_PIN(PORT_D, 7)
-#define ARDUINO_PIN_8           GPIO_PIN(PORT_B, 0)
-#define ARDUINO_PIN_9           GPIO_PIN(PORT_B, 1)
-#define ARDUINO_PIN_10          GPIO_PIN(PORT_B, 2)
-#define ARDUINO_PIN_11          GPIO_PIN(PORT_B, 3)
-#define ARDUINO_PIN_12          GPIO_PIN(PORT_B, 4)
-#define ARDUINO_PIN_13          GPIO_PIN(PORT_B, 5)
-/* Analog pins */
-#define ARDUINO_PIN_14          GPIO_PIN(PORT_C, 0)
-#define ARDUINO_PIN_15          GPIO_PIN(PORT_C, 1)
-#define ARDUINO_PIN_16          GPIO_PIN(PORT_C, 2)
-#define ARDUINO_PIN_17          GPIO_PIN(PORT_C, 3)
-#define ARDUINO_PIN_18          GPIO_PIN(PORT_C, 4)
-#define ARDUINO_PIN_19          GPIO_PIN(PORT_C, 5)
-/* Analog input */
-#define ARDUINO_PIN_A0          ARDUINO_PIN_14
-#define ARDUINO_PIN_A1          ARDUINO_PIN_15
-#define ARDUINO_PIN_A2          ARDUINO_PIN_16
-#define ARDUINO_PIN_A3          ARDUINO_PIN_17
-#define ARDUINO_PIN_A4          ARDUINO_PIN_18
-#define ARDUINO_PIN_A5          ARDUINO_PIN_19
-/** @ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ARDUINO_PINMAP_H */
-/** @} */
diff --git a/boards/arduino-common/include/periph_conf.h b/boards/arduino-common/include/periph_conf.h
deleted file mode 100644
index d19d20b914bcbb667d80168bf3c9548f011be336..0000000000000000000000000000000000000000
--- a/boards/arduino-common/include/periph_conf.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
- *               2016 Laurent Navet <laurent.navet@gmail.com>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- */
-
-/**
- * @ingroup     boards_arduino-common
- * @{
- *
- * @file
- * @brief       Peripheral MCU configuration for the arduino Uno and
- * @brief       Dumilanove boards.
- *
- * @author      Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
- * @author      Laurent Navet <laurent.navet@gmail.com>
- */
-
-#ifndef PERIPH_CONF_H
-#define PERIPH_CONF_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief   Clock configuration
- * @{
- */
-#define CLOCK_CORECLOCK     (16000000L)
-/** @} */
-
-/**
- * @name   Timer configuration
- *
- * The timer driver only supports the 16-bit timer (Timer1)
- * so this is the only one we can use here.
- *
- * @{
- */
-#define TIMER_NUMOF         (2U)
-
-#define TIMER_0             MEGA_TIMER1
-#define TIMER_0_MASK        &TIMSK1
-#define TIMER_0_FLAG        &TIFR1
-#define TIMER_0_ISRA        TIMER1_COMPA_vect
-#define TIMER_0_ISRB        TIMER1_COMPB_vect
-/** @} */
-
-/**
- * @name   UART configuration
- *
- * Uno has only one UART, look in atmega_common
- * This is where magic happens
- *
- * @{
- */
-#define UART_NUMOF          (1U)
-
-#define UART_0              MEGA_UART0
-#define UART_0_ISR          USART_RX_vect
-/** @} */
-
-/**
- * @name   SPI configuration
- *
- * The atmega2560 has only one hardware SPI with fixed pin configuration, so all
- * we can do here, is to enable or disable it...
- *
- * The fixed pins used, are:
- * MOSI - PB3 (Arduino pin 11)
- * MISO - PB4 (Arduino pin 12)
- * SCK  - PB5 (Arduino pin 13)
- * SS   - PB2 (Arduino pin 10) -> this pin is configured as output, but not used
- *
- * @{
- */
-#define SPI_NUMOF           1           /* set to 0 to disable SPI */
-#define MEGA_PRR            PRR         /* Power Reduction Register is PRR */
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PERIPH_CONF_H */
diff --git a/boards/arduino-duemilanove/Makefile b/boards/arduino-duemilanove/Makefile
index 070aba9f1a0091cb63bcf628e5594bbd1a703618..b597cd662a6ff3933f96f819ddea9ccef91a05d9 100644
--- a/boards/arduino-duemilanove/Makefile
+++ b/boards/arduino-duemilanove/Makefile
@@ -1,5 +1,5 @@
 MODULE = board
 
-DIRS = $(RIOTBOARD)/arduino-common
+DIRS = $(RIOTBOARD)/arduino-atmega-common
 
 include $(RIOTBASE)/Makefile.base
diff --git a/boards/arduino-duemilanove/Makefile.features b/boards/arduino-duemilanove/Makefile.features
index da28e25dba0175a52f37eae3d32c83ee76bccd58..f76efd160e503067247486a8e01523a0ffe85971 100644
--- a/boards/arduino-duemilanove/Makefile.features
+++ b/boards/arduino-duemilanove/Makefile.features
@@ -1 +1 @@
-include $(RIOTBOARD)/arduino-common/Makefile.features
+include $(RIOTBOARD)/arduino-atmega-common/Makefile.features
diff --git a/boards/arduino-duemilanove/Makefile.include b/boards/arduino-duemilanove/Makefile.include
index e8e3236dbc0642c7fdbd0d9afd6d3080e33b090e..45a8b2c9f7c8f7f7e1de1601e9e43de3f7d31ab8 100644
--- a/boards/arduino-duemilanove/Makefile.include
+++ b/boards/arduino-duemilanove/Makefile.include
@@ -1,10 +1,20 @@
-USEMODULE += arduino-common
+# define the cpu used by the ardudino duemilanove board
+export CPU = atmega328p
 
-# add arduino-common include path
-INCLUDES += -I$(RIOTBOARD)/arduino-common/include
+USEMODULE += arduino-atmega-common
+
+# add arduino-atmega-common include path
+INCLUDES += -I$(RIOTBOARD)/arduino-atmega-common/include
 
 #export needed for flash rule
-export LINUX_PORT = /dev/ttyUSB0
-export PROGRAMMER_SPEED = 57600
+export PORT_LINUX ?= /dev/ttyUSB0
+export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
+export PROGRAMMER_SPEED ?= 57600
+
+export FFLAGS += -p m328p
+
+# PROGRAMMER defaults to arduino which is the internal flasher via USB. Can be
+# overridden for debugging (which requires changes that require to use an ISP)
+export PROGRAMMER ?= arduino
 
-include $(RIOTBOARD)/arduino-common/Makefile.include
+include $(RIOTBOARD)/arduino-atmega-common/Makefile.include
diff --git a/boards/arduino-mega2560/Makefile b/boards/arduino-mega2560/Makefile
index f8fcbb53a06595771dae356338a7bf2c0673734d..b597cd662a6ff3933f96f819ddea9ccef91a05d9 100644
--- a/boards/arduino-mega2560/Makefile
+++ b/boards/arduino-mega2560/Makefile
@@ -1,3 +1,5 @@
 MODULE = board
 
+DIRS = $(RIOTBOARD)/arduino-atmega-common
+
 include $(RIOTBASE)/Makefile.base
diff --git a/boards/arduino-mega2560/Makefile.features b/boards/arduino-mega2560/Makefile.features
index 8131d940b21417109116d8b7af0b9593be92f616..f76efd160e503067247486a8e01523a0ffe85971 100644
--- a/boards/arduino-mega2560/Makefile.features
+++ b/boards/arduino-mega2560/Makefile.features
@@ -1,10 +1 @@
-# Put defined MCU peripherals here (in alphabetical order)
-FEATURES_PROVIDED += periph_gpio
-FEATURES_PROVIDED += periph_spi
-FEATURES_PROVIDED += periph_timer
-FEATURES_PROVIDED += periph_uart
-
-# Various other features (if any)
-
-# The board MPU family (used for grouping by the CI system)
-FEATURES_MCU_GROUP = avr8
+include $(RIOTBOARD)/arduino-atmega-common/Makefile.features
diff --git a/boards/arduino-mega2560/Makefile.include b/boards/arduino-mega2560/Makefile.include
index 601a6b2a4a5f313348ad7ad3db419ebe29b9ce91..de5cc950488ed72e3cce32e15a254eae1eb196b0 100644
--- a/boards/arduino-mega2560/Makefile.include
+++ b/boards/arduino-mega2560/Makefile.include
@@ -1,53 +1,20 @@
 # define the cpu used by the arduino mega2560 board
 export CPU = atmega2560
 
-export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
-export TERMFLAGS = -b 9600 -p $(PORT)
+USEMODULE += arduino-atmega-common
 
-#define the flash-tool and default port depending on the host operating system
-OS = $(shell uname)
-ifeq ($(OS),Linux)
-  PORT ?= /dev/ttyACM0
-  FLASHER = avrdude
-else ifeq ($(OS),Darwin)
-  PORT ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
-  FLASHER = avrdude
-else
-  $(info CAUTION: No flash tool for your host system found!)
-  # TODO: fix for building under windows
-endif
-export FLASHER
-export PORT
-export DIST_PATH = $(RIOTBOARD)/$(BOARD)/dist
-export DEBUGSERVER_PORT = 4242
-export DEBUGSERVER = $(DIST_PATH)/debug_srv.sh
-export DEBUGSERVER_FLAGS = "-g -j usb :$(DEBUGSERVER_PORT)"
-export DEBUGGER_FLAGS = "-x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)"
-export DEBUGGER = $(DIST_PATH)/debug.sh $(DEBUGSERVER_FLAGS) $(DIST_PATH) $(DEBUGSERVER_PORT)
+# add arduino-atmega-common include path
+INCLUDES += -I$(RIOTBOARD)/arduino-atmega-common/include
+
+#export needed for flash rule
+export PORT_LINUX ?= /dev/ttyACM0
+export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
+export PROGRAMMER_SPEED ?= 115200
+
+export FFLAGS += -p m2560
 
 # PROGRAMMER defaults to stk500v2 which is the internal flasher via USB. Can be
 # overridden for debugging (which requires changes that require to use an ISP)
 export PROGRAMMER ?= stk500v2
 
-ifeq ($(PROGRAMMER), stk500v2)
-    export PROGRAMMER_FLAGS = -P $(PORT) -b 115200
-endif
-
-# define build specific options
-export CFLAGS_CPU   = -mmcu=atmega2560  $(CFLAGS_FPU)
-export CFLAGS_LINK  = -fno-builtin -fshort-enums
-export CFLAGS_DBG  ?= -ggdb -g3
-export CFLAGS_OPT  ?= -Os
-
-export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
-export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
-export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -e reset_handler
-export OFLAGS += -j .text -j .data -O ihex
-export FFLAGS += -p m2560 -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -D -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex
-
-ifeq ($(LTO),1)
-  # avr-gcc <4.8.3 has a bug when using LTO which causes a warning to be printed always:
-  # '_vector_25' appears to be a misspelled signal handler [enabled by default]
-  # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
-  export LINKFLAGS += -Wno-error
-endif
+include $(RIOTBOARD)/arduino-atmega-common/Makefile.include
\ No newline at end of file
diff --git a/boards/arduino-mega2560/board.c b/boards/arduino-mega2560/board.c
deleted file mode 100644
index c9166e967d789c42e0a5d36a5bfbbf09421e895c..0000000000000000000000000000000000000000
--- a/boards/arduino-mega2560/board.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
- *               2015 Kaspar Schleiser <kaspar@schleiser.de>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- */
-
-/**
- * @ingroup     boards_arduino-mega2560
- * @{
- *
- * @file
- * @brief       Board specific implementations for the Arduino Mega 2560 board
- *
- * @author      Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
- * @author      Kaspar Schleiser <kaspar@schleiser.de>
- *
- * @}
- */
-
-#include <stdio.h>
-#include <avr/io.h>
-
-#include "board.h"
-#include "cpu.h"
-#include "uart_stdio.h"
-
-void led_init(void);
-void SystemInit(void);
-static int uart_putchar(char c, FILE *stream);
-static int uart_getchar(FILE *stream);
-
-static FILE uart_stdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);
-static FILE uart_stdin = FDEV_SETUP_STREAM(NULL, uart_getchar, _FDEV_SETUP_READ);
-
-void board_init(void)
-{
-    /* initialize stdio via USART_0 */
-    SystemInit();
-
-    /* initialize the CPU */
-    cpu_init();
-
-    /* initialize the board LED (connected to pin PB7) */
-    DDRB |= (1 << DDB7);
-    PORTB &= ~(1 << 7);
-
-    irq_enable();
-}
-
-/**
- * @brief Initialize the System, initialize IO via UART_0
- */
-void SystemInit(void)
-{
-    /* initialize UART_0 for use as stdout */
-    uart_stdio_init();
-
-    stdout = &uart_stdout;
-    stdin = &uart_stdin;
-
-    /* Flush stdout */
-    puts("\f");
-}
-
-static int uart_putchar(char c, FILE *stream)
-{
-    (void) stream;
-    uart_stdio_write(&c, 1);
-    return 0;
-}
-
-int uart_getchar(FILE *stream)
-{
-    (void) stream;
-    char c;
-    uart_stdio_read(&c, 1);
-    return (int)c;
-}
diff --git a/boards/arduino-mega2560/dist/debug.sh b/boards/arduino-mega2560/dist/debug.sh
deleted file mode 100755
index 0b10852f20c0dacf071b40d8a98ccce09e7722ac..0000000000000000000000000000000000000000
--- a/boards/arduino-mega2560/dist/debug.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-sleep 2
-setsid -w avarice $1 &
-#sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4
-sleep 3 && avr-gdb -ex "target remote localhost:$3" $4
-
-# avarice exits with 1 if the connection is released, therefore we always exit with 0
-exit 0
diff --git a/boards/arduino-mega2560/dist/debug_srv.sh b/boards/arduino-mega2560/dist/debug_srv.sh
deleted file mode 100755
index 8e7de053ab36eb5fa12252d3a8184fc7d89be82f..0000000000000000000000000000000000000000
--- a/boards/arduino-mega2560/dist/debug_srv.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-sleep 2
-avarice $1
-
-# avarice exits with 1 if the connection is released, therefore we always exit with 0
-exit 0
diff --git a/boards/arduino-mega2560/dist/gdb.conf b/boards/arduino-mega2560/dist/gdb.conf
deleted file mode 100644
index ca68eb344c3f4a9e6f7eeecd2331c36110ac4c10..0000000000000000000000000000000000000000
--- a/boards/arduino-mega2560/dist/gdb.conf
+++ /dev/null
@@ -1 +0,0 @@
-set $pc=0x00
diff --git a/boards/arduino-mega2560/include/board.h b/boards/arduino-mega2560/include/board.h
deleted file mode 100644
index 1aee0c2cc8a9b9ab1740e6cd48699df765efc17a..0000000000000000000000000000000000000000
--- a/boards/arduino-mega2560/include/board.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- */
-
-/**
- * @defgroup    boards_arduino-mega2560 Arduino Mega 2560
- * @ingroup     boards
- * @brief       Board specific files for the Arduino Mega 2560 board.
- * @{
- *
- * @file
- * @brief       Board specific definitions for the Arduino Mega 2560 board.
- *
- * @author      Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
- */
-
-#ifndef BOARD_H
-#define BOARD_H
-
-#include "cpu.h"
-#include "arduino_pinmap.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-* @brief As the CPU is too slow to handle 115200 baud, we set the default
-*        baudrate to 9600 for this board
-*/
-#define UART_STDIO_BAUDRATE (9600U)
-
-/**
- * @brief   LED pin definitions and handlers
- * @{
- */
-#define LED0_PIN            GPIO_PIN(1, 7)
-
-#define LED0_MASK           (1 << DDB7)
-
-#define LED0_ON             (PORTB |=  LED0_MASK)
-#define LED0_OFF            (PORTB &= ~LED0_MASK)
-#define LED0_TOGGLE         (PORTB ^=  LED0_MASK)
-/** @} */
-
-
-/**
- * Context swap defines
- * Setup to use PJ6 which is pin change interrupt 15 (PCINT15)
- * This emulates a software triggered interrupt
- **/
-#define AVR_CONTEXT_SWAP_INIT do { \
-    DDRJ |= (1 << PJ6); \
-    PCICR |= (1 << PCIE1); \
-    PCMSK1 |= (1 << PCINT15); \
-} while (0)
-#define AVR_CONTEXT_SWAP_INTERRUPT_VECT  PCINT1_vect
-#define AVR_CONTEXT_SWAP_TRIGGER   PORTJ ^= (1 << PJ6)
-
-
-
-/**
- * @brief xtimer configuration values
- * @{
- */
-#define XTIMER_WIDTH                (16)
-#define XTIMER_SHIFT                (2)
-#define XTIMER_HZ                   (250000UL)
-#define XTIMER_BACKOFF              (40)
-/** @} */
-
-/**
- * @brief Initialize board specific hardware, including clock, LEDs and std-IO
- */
-void board_init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BOARD_H */
-/** @} */
diff --git a/boards/arduino-uno/Makefile b/boards/arduino-uno/Makefile
index 070aba9f1a0091cb63bcf628e5594bbd1a703618..b597cd662a6ff3933f96f819ddea9ccef91a05d9 100644
--- a/boards/arduino-uno/Makefile
+++ b/boards/arduino-uno/Makefile
@@ -1,5 +1,5 @@
 MODULE = board
 
-DIRS = $(RIOTBOARD)/arduino-common
+DIRS = $(RIOTBOARD)/arduino-atmega-common
 
 include $(RIOTBASE)/Makefile.base
diff --git a/boards/arduino-uno/Makefile.features b/boards/arduino-uno/Makefile.features
index da28e25dba0175a52f37eae3d32c83ee76bccd58..f76efd160e503067247486a8e01523a0ffe85971 100644
--- a/boards/arduino-uno/Makefile.features
+++ b/boards/arduino-uno/Makefile.features
@@ -1 +1 @@
-include $(RIOTBOARD)/arduino-common/Makefile.features
+include $(RIOTBOARD)/arduino-atmega-common/Makefile.features
diff --git a/boards/arduino-uno/Makefile.include b/boards/arduino-uno/Makefile.include
index f2d017c519a56dfb255c2bce9de8c9dee2a67cb7..4f30ca91d2e499056fc59f3faf19c932d1f6936c 100644
--- a/boards/arduino-uno/Makefile.include
+++ b/boards/arduino-uno/Makefile.include
@@ -1,10 +1,20 @@
-USEMODULE += arduino-common
+# define the cpu used by the arduino uno board
+export CPU = atmega328p
 
-# add arduino-common include path
-INCLUDES += -I$(RIOTBOARD)/arduino-common/include
+USEMODULE += arduino-atmega-common
+
+# add arduino-atmega-common include path
+INCLUDES += -I$(RIOTBOARD)/arduino-atmega-common/include
 
 # export needed for flash rule
-export LINUX_PORT = /dev/ttyACM0
-export PROGRAMMER_SPEED = 115200
+export PORT_LINUX ?= /dev/ttyACM0
+export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
+export PROGRAMMER_SPEED ?= 115200
+
+export FFLAGS += -p m328p
+
+# PROGRAMMER defaults to arduino which is the internal flasher via USB. Can be
+# overridden for debugging (which requires changes that require to use an ISP)
+export PROGRAMMER ?= arduino
 
-include $(RIOTBOARD)/arduino-common/Makefile.include
+include $(RIOTBOARD)/arduino-atmega-common/Makefile.include
diff --git a/boards/arduino-zero/Makefile.include b/boards/arduino-zero/Makefile.include
index bbe96c8178f5f25605d2ab42b69cf6a18212665e..83a0716a484fc8d72a6eaa053074181c5bd4837b 100644
--- a/boards/arduino-zero/Makefile.include
+++ b/boards/arduino-zero/Makefile.include
@@ -3,8 +3,8 @@ export CPU = samd21
 export CPU_MODEL = samd21g18a
 
 # set default port depending on operating system
-PORT_LINUX ?= /dev/ttyACM0
-PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
+export PORT_LINUX ?= /dev/ttyACM0
+export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
 
 # setup serial terminal
 include $(RIOTBOARD)/Makefile.include.serial
diff --git a/boards/waspmote-pro/Makefile.include b/boards/waspmote-pro/Makefile.include
index 54a9bb1d2d542d22b99dedb5878afad391db95c1..cc7d74747c318667b4824470b65e0c5fb5289a03 100644
--- a/boards/waspmote-pro/Makefile.include
+++ b/boards/waspmote-pro/Makefile.include
@@ -43,14 +43,5 @@ ifeq ($(PROGRAMMER), stk500v1)
     export PROGRAMMER_FLAGS = -P $(PORT) -b 115200
 endif
 
-# define build specific options
-export CFLAGS_CPU   = -mmcu=atmega1281  $(CFLAGS_FPU)
-export CFLAGS_LINK  = -fno-builtin -fshort-enums
-export CFLAGS_DBG  ?= -ggdb -g3
-export CFLAGS_OPT  ?= -Os
-
-export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
-export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
-export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -e reset_handler
 export OFLAGS += -j .text -j .data -O ihex
 export FFLAGS += -p m1281 -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex
diff --git a/cpu/atmega_common/Makefile.include b/cpu/atmega_common/Makefile.include
index 9bfa137a0a46321e3ed294777b2f5b275063b5a7..5cbfe7ae7630cbda67a1e3acec55dd6634bc50d9 100644
--- a/cpu/atmega_common/Makefile.include
+++ b/cpu/atmega_common/Makefile.include
@@ -1,14 +1,14 @@
 # Target architecture for the build. Use avr if you are unsure.
 export TARGET_ARCH ?= avr
 
-# define build specific options
-CFLAGS_LINK  = -ffunction-sections -fdata-sections
+export CFLAGS_CPU = -mmcu=$(CPU) $(CFLAGS_FPU)
+export CFLAGS_LINK  = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
+export CFLAGS_DBG  ?= -ggdb -g3
+export CFLAGS_OPT  ?= -Os
 
-# export compiler flags
-export CFLAGS += $(CFLAGS_LINK)
-
-# export linker flags
-export LINKFLAGS += -Wl,--gc-sections -static -lgcc
+export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
+export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
+export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler -Wl,--gc-sections
 
 # export the peripheral drivers to be linked into the final binary
 export USEMODULE += periph
@@ -19,3 +19,10 @@ export USEMODULE += uart_stdio
 
 # include module specific includes
 export INCLUDES += -I$(RIOTCPU)/atmega_common/include -isystem$(RIOTCPU)/atmega_common/avr-libc-extra
+
+ifeq ($(LTO),1)
+  # avr-gcc <4.8.3 has a bug when using LTO which causes a warning to be printed always:
+  # '_vector_25' appears to be a misspelled signal handler [enabled by default]
+  # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
+  export LINKFLAGS += -Wno-error
+endif