From c1c25b0644dca26d7dd741d3132cca37986c574d Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 10 Feb 2020 14:59:24 +0100 Subject: [PATCH] boards/arduino-nano: Refactor avrdude conf - Use the common logic to translate from a bootloader to concrete flasher flags - Extended documentation on how to use optiboot as alternative bootloader, as the stock bootloader is affected by a bug preventing the use of RIOT's pm_reboot() implementation --- boards/arduino-nano/Makefile.include | 15 ++------------- boards/arduino-nano/doc.txt | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/boards/arduino-nano/Makefile.include b/boards/arduino-nano/Makefile.include index 674107ae00..d7ca2b0d9d 100644 --- a/boards/arduino-nano/Makefile.include +++ b/boards/arduino-nano/Makefile.include @@ -3,18 +3,7 @@ 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) +ARDUINO_NANO_BOOTLOADER ?= atmegaboot +BOOTLOADER ?= $(ARDUINO_NANO_BOOTLOADER) include $(RIOTBOARD)/common/arduino-atmega/Makefile.include diff --git a/boards/arduino-nano/doc.txt b/boards/arduino-nano/doc.txt index 22b5877726..a1948ebe7d 100644 --- a/boards/arduino-nano/doc.txt +++ b/boards/arduino-nano/doc.txt @@ -26,7 +26,7 @@ extensible by using shields. | 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 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: @@ -37,6 +37,28 @@ This should take care of everything! We use the open `avrdude` tool to write the new code into the ATmega328p's flash -##Caution +## Using Optiboot + +You can use the [Optiboot](https://github.com/Optiboot/optiboot) bootloader +instead of the stock bootloader for faster programming. Optiboot also is +smaller (512 byte instead of 2 KiB), so that 1.5 KiB more program memory is +available for RIOT. Refer to the project page for instructions on how to +build an flash the bootloader. Don't forgot to also update the fuse settings +to set the bootloader size to 256 words (512 bytes). + +Compile and flash with `make BOARD=arduino-nano BOOTLOADER=optiboot flash` or +use `export ARDUINO_NANO_BOOTLOADER=optiboot` in order to not have to specify +the bootloader during compilation and flashing. + +## Issues + +### RIOT Stuck in Reboot Loop + +If RIOT is stuck in a reboot loop e.g. after restarting the device with the +`reboot` shell command, this is likely caused by an +[issue with the stock bootloader](https://forum.arduino.cc/index.php?topic=150419.0) +that can be solved by using Optiboot as bootloader instead (see above). + +## Caution Don't expect having a working network stack due to very limited resources. */