-
Notifications
You must be signed in to change notification settings - Fork 0
Board: Arduino Mega2560
The Arduino Mega2560 is one of the larger Arduino boards. It is based on Atmel's AVR architecture and sports an ATmega2560 MCU. It is like many Arduinos extensible by using shields.
NOTE: In case you are wondering if flashing RIOT on your Arduino Mega2560 will overwrite the Arduino bootloader: you can be reassured. After flashing RIOT you can without any intermediate steps just go over to flashing Arduino sketches again.
MCU | ATmega2560 |
---|---|
Family | AVR/ATmega |
Vendor | Atmel |
RAM | 8Kb |
Flash | 256Kb |
Frequency | 16MHz |
Timers | 6 (2x 8bit, 4x 16bit) |
ADCs | 14 analog input pins (10bit resolution |
UARTs | 4 |
SPIs | 1 |
I2Cs | 1 (called TWI) |
Vcc | 5.0V |
Datasheet / Reference Manual | Datasheet and Reference Manual |
Board Manual | Board Manual |
Flashing RIOT on the Arduino Mega2560 is quite straight forward, just connect your Arduino Mega2560 using the programming port to your host computer and type:
make BOARD=arduino-mega2560 flash
This should take care of everything!
We use the open avrdude
tool to write the new code into the ATmega2560's flash
While there is basic support in RIOT, there are still some parts missing:
- Timer implementation needs love (ideally simulate a 32bit timer by adding an overflow counter to the implementation)
- LPM driver missing
- GPIO driver missing
- SPI/I2C/TWI driver missing
- ADC driver missing
- PWM driver missing
The ATmega2560 MCU supports JTAG debugging. To use the JTAG debugging on the Arduino Mega 2560 an external JTAG debugger is required. There are several options for this MCU/board:
There may be other options as well, but I can't comment on how well they work. I tested debugging RIOT on the Arduino Mega 2560 using an AVR Dragon.
Important: To use a JTAG Debugger in conjunction with the ATmega2560 it is required to change the fuses of the MCU. Additionally it seems to be required to overwrite the bootloader on the MCU. Because of that it is a necessity to use an ISP (in system programmer) to do the debugging. This isn't an issue because all of the afore mentioned devices have ISP capabilities, but it requires some additional steps to get back normal operation after debugging:
- flash a new arduino bootloader on the device, e.g. this one
- restore the fuses to the default state.
In contrast to normal use (USB only), for debugging there are two separate wiring changes to do:
- connecting the ISP headers (picture: orange cables).
- connecting the JTAG header to the respective pins on the Arduino (picture: blue cables)
Connecting the ISP headers is straight forward: Pin1 on the Dragon connects to Pin1 on the Arduino Mega2560 and so on. Connecting the JTAG header needs the following pin mapping:
AVR Dragon | Arduino Mega 2560 | Signal |
---|---|---|
JTAG1 | A4 | TCK |
JTAG2 o. 10 | GND | GND |
JTAG3 | A6 | TDO |
JTAG4 | +5V | +5V |
JTAG5 | A5 | TMS |
JTAG9 | A7 | TDI |
Ax refers to the analog in pins on the Arduino Mega 2560. JTAG2 and JTAG10 on the AVR Dragon are both GND, one connection suffices. All other JTAG Pins are not needed for debugging the Arduino Mega2560
Additional information can be found here or here.
default:
Fuse | Setting |
---|---|
Low Fuse | 0xFF |
High Fuse | 0xD8 |
Extended Fuse | 0xFD |
avrdude arguments: -U lfuse:w:0xff:m -U hfuse:w:0xD8:m -U efuse:w:0xfd:m
|
debugging:
Fuse | Setting |
---|---|
Low Fuse | 0xFF |
High Fuse | 0x18 |
Extended Fuse | 0xFD |
(Both OCDEN
and JTAGEN
fuse bits are enabled)
avrdude arguments: -U lfuse:w:0xff:m -U hfuse:w:0x18:m -U efuse:w:0xfd:m
A useful tool to calculate fuse settings yourself is this fuse calculator, which also works with other AVR MCUs.
With PR #1696 merged the following commands should work for debugging:
make BOARD=arduino-mega2560 debug-server
: starts an avarice (avarice needs to be installed) server that avr-gdb
can connect to.
make BOARD=arduino-mega2560 debug
: starts an avarice server and connects avr-gdb
to it.
Note: To flash the board via the ISP while debugging the additional flag PROGRAMMER=dragon_isp
is required.
For a full rebuild and debug cycle use the following command:
make BOARD=arduino-mega2560 PROGRAMMER=dragon_isp clean all flash debug
RIOT - The friendly Operating System for the Internet of Things
Homepage | [GitHub] (https://github.com/RIOT-OS/) | Developers Mailing List | Users Mailing List | Twitter @RIOT_OS
- Family: ARM
- Board: Airfy Beacon
- Board: Arduino Due
- Board: CC2538DK
- Board: HikoB Fox
- Board: IoT LAB M3
- Board: LimiFrog-v1
- Board: mbed_lpc1768
- Board: MSB-IoT
- Board: MSBA2
- Board: Nucleo-L1
- Board: Nucleo-F334
- Board: Nucleo-F303
- Board: Nucleo-F091
- Board: Mulle
- Board: OpenMote
- Board: PCA1000x (nRF51822 Development Kit)
- Board: Phytec phyWAVE-KW22
- Board: RFduino
- Board: Samr21 xpro
- Board: Spark Core
- Board: STM32F0discovery
- Board: STM32F3discovery
- Board: STM32F4discovery
- Board: UDOO
- Board: yunjia-nrf51822
- Family: ATmega
- Board: Arduino Mega2560
- Family: MSP430
- Board: MSB-430H
- Board: TelosB
- Board: WSN430
- Board: Zolertia Z1
- Board: eZ430-Chronos
- Family: native
- Board: native
- Family: x86
- Board: Intel Galileo