From e4ebbaf59f6c6c4bd38b4568bea3a1332c300cee Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 4 Jul 2018 22:26:10 +0200 Subject: [PATCH] boards: Add support for the Arduino Nano The Arduino Nano board is the cheapest member of the Arduino family and used the same MCU as the Arduino Uno. It differs in the form factor (the Nano is much smaller), it uses an integrated FT232RL TTL adapter instead of an ATmega16u2 to provide access to the serial console via USB, and it uses a different bootloader (which occupies 2 KiB of the 32 KiB flash instead of 0.5 KiB occupied on the Arduino Uno). This commit mostly copy pastes code from the Arduino Uno. --- boards/arduino-nano/Makefile | 5 ++++ boards/arduino-nano/Makefile.dep | 3 ++ boards/arduino-nano/Makefile.features | 3 ++ boards/arduino-nano/Makefile.include | 23 +++++++++++++++ boards/arduino-nano/doc.txt | 42 +++++++++++++++++++++++++++ boards/arduino-nano/include/board.h | 33 +++++++++++++++++++++ 6 files changed, 109 insertions(+) create mode 100644 boards/arduino-nano/Makefile create mode 100644 boards/arduino-nano/Makefile.dep create mode 100644 boards/arduino-nano/Makefile.features create mode 100644 boards/arduino-nano/Makefile.include create mode 100644 boards/arduino-nano/doc.txt create mode 100644 boards/arduino-nano/include/board.h diff --git a/boards/arduino-nano/Makefile b/boards/arduino-nano/Makefile new file mode 100644 index 0000000000..8c6f44eb53 --- /dev/null +++ b/boards/arduino-nano/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/common/arduino-atmega + +include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-nano/Makefile.dep b/boards/arduino-nano/Makefile.dep new file mode 100644 index 0000000000..580e800f2f --- /dev/null +++ b/boards/arduino-nano/Makefile.dep @@ -0,0 +1,3 @@ +USEMODULE += boards_common_arduino-atmega + +include $(RIOTBOARD)/common/arduino-atmega/Makefile.dep diff --git a/boards/arduino-nano/Makefile.features b/boards/arduino-nano/Makefile.features new file mode 100644 index 0000000000..b3d37cc98b --- /dev/null +++ b/boards/arduino-nano/Makefile.features @@ -0,0 +1,3 @@ +include $(RIOTBOARD)/common/arduino-atmega/Makefile.features + +include $(RIOTCPU)/atmega328p/Makefile.features diff --git a/boards/arduino-nano/Makefile.include b/boards/arduino-nano/Makefile.include new file mode 100644 index 0000000000..c6908754f3 --- /dev/null +++ b/boards/arduino-nano/Makefile.include @@ -0,0 +1,23 @@ +# define the cpu used by the Arduino Nano board +export CPU = atmega328p + +# configure the terminal program +PORT_LINUX ?= /dev/ttyUSB0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) +BAUD ?= 9600 + +PROGRAMMER ?= arduino + +ifeq (arduino,$(PROGRAMMER)) + # the Arduino Nano bootloader is 2KiB in size + BOOTLOADER_SIZE ?= 2048 + # the Nano's bootloader uses 57600 baud for programming + FFLAGS_EXTRA += -b 57600 +else + # not using the bootloader for programming, thus the whole flash can be used + BOOTLOADER_SIZE ?= 0 +endif + +ROM_RESERVED ?= $(BOOTLOADER_SIZE) + +include $(RIOTBOARD)/common/arduino-atmega/Makefile.include diff --git a/boards/arduino-nano/doc.txt b/boards/arduino-nano/doc.txt new file mode 100644 index 0000000000..22b5877726 --- /dev/null +++ b/boards/arduino-nano/doc.txt @@ -0,0 +1,42 @@ +/** +@defgroup boards_arduino-nano Arduino Nano +@ingroup boards +@brief Support for the Arduino Nano board + +## Overview + +The Arduino Nano is the cheapest member of the Arduino family. It is based on +Atmel's AVR architecture and sports an ATmega328p MCU. It is like many Arduinos +extensible by using shields. + +### MCU +| MCU | ATmega328p | +|:------------- |:--------------------------------------------- | +| Family | AVR/ATmega | +| Vendor | Atmel | +| RAM | 2 KiB | +| Flash | 32 KiB (2 KiB reserved for the bootloader) | +| Frequency | 16 MHz | +| Timers | 3 (2x 8bit, 1x 16bit) | +| ADCs | 6 analog input pins | +| UARTs | 1 | +| SPIs | 1 | +| I2Cs | 1 (called TWI) | +| Vcc | 5.0V | +| MCU Datasheet | [ATmega328p datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf) | +| Board Manual | [Board Manual](https://www.arduino.cc/en/uploads/Main/ArduinoNanoManual23.pdf) | + +## Flashing the device +Flashing RIOT on the Arduino Nano is quite straight forward, just connect your +Arduino Nano via the USB connector to your host computer and type: + +`make BOARD=arduino-nano flash` + +This should take care of everything! + +We use the open `avrdude` tool to write the new code into the ATmega328p's +flash + +##Caution +Don't expect having a working network stack due to very limited resources. + */ diff --git a/boards/arduino-nano/include/board.h b/boards/arduino-nano/include/board.h new file mode 100644 index 0000000000..caf484f4f3 --- /dev/null +++ b/boards/arduino-nano/include/board.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 Freie Universität Berlin + * + * 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-nano + * @{ + * + * @file + * @brief Board specific definitions for the Arduino Uno board + * + * @author Martine Lenders + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "board_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */