Skip to content

Commit

Permalink
boards/arduino-nano: Refactor avrdude conf
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
maribu committed Feb 10, 2020
1 parent 88b90ee commit c1c25b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
15 changes: 2 additions & 13 deletions boards/arduino-nano/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 24 additions & 2 deletions boards/arduino-nano/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
*/

0 comments on commit c1c25b0

Please sign in to comment.