Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 120 additions & 0 deletions Documentation/platforms/avr/atmega/boards/elegoo-mega2560r3/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
====================
Elegoo Mega2560 Rev3
====================

.. tags:: chip:atmega2560, chip:atmega, arch:avr, vendor:elegoo, experimental

.. figure:: elegoo-mega2560r3.jpg
:scale: 40 %
:align: center
:alt: The Elegoo Mega2560 Rev3 board with its included USB cable

The Elegoo Mega2560 Rev3 board with its included USB cable

This board is a variant of the `Arduino Mega2560 Rev3 board
<https://docs.arduino.cc/hardware/mega-2560/>`_ designed by Elegoo. The `product
listing can be found here
<https://us.elegoo.com/products/elegoo-mega-2560-r3-board>`_.

Features
========

* Atmel ATMega2560 chip
* 54 digital pins
* 16 analog inputs
* 4 serial ports
* 4KB EEPROM

.. warning::

The ATMega2560 chip supported is limited, and thus this board does not
support many peripherals. If you would like to help improve support for this
board and other ATMega2560-based boards, please see the :doc:`contributing
guidelines </contributing/index>`.

Buttons and LEDs
================

The board has a large RESET button, which is not user controllable.

There are 4 LEDs on-board the Elegoo Mega2560 Rev3:

* ON: indicates active power, connected directly to the power supply
* TX: indicates transmitting data
* RX: indicates receiving data
* TEST: board controllable LED, near "PWM" label. Turns on to indicate that
NuttX started, and flashes at 1Hz to indicate panic.

Pin Mapping
===========

The full pin-out of this board is the same as the Arduino Mega2560r3 pinout,
which can be found `here <https://docs.arduino.cc/hardware/mega-2560/>`_.

Power Supply
============

This board uses 5V logic. It has on-board power regulation to provide 5V and
3.3V rails to the user. The 3.3V rail can only supply 50mA.

The board can be powered a few different ways:

* Via the USB connection at 5V
* Via external power supply to the barrel jack (center-positive) at 7V - 12V

Installation
============

You will need the ``avrdude`` utility to flash this board. For instructions on
how to install the AVR toolchain, consult the main documentation for the AVR
architecture.

Building NuttX
==============

In order to build NuttX, you can follow the regular process of using
``./tools/configure.sh`` and ``make``.

.. code:: console

$ ./tools/configure.sh elegoo-mega2560r3:nsh
$ make

The build system will generate a ``.hex`` file along with the typical ELF file.
If not, enable the ``CONFIG_INTELHEX_BINARY`` option.

.. warning::

Beware of the small memory size of this board's chip when choosing what to
include in your NuttX image.

Flashing
========

Then, to flash the board, connect it via USB to the host computer and run the
following command:

.. code:: console

$ avrdude -c stk500v2 -p m2560 -P /dev/ttyACM0 -U flash:w:nuttx.hex -v -D

This command assumes that the board USB connection is available on ``ttyACM0``,
but you should verify the file path to its connection. You can use ``lsusb`` on
Linux to look for "Arduino SA Mega 2560 R3".

If you want to reduce the console output of the command, remove the ``-v`` flag.

The board uses the STK500v2 programmer type through the on-board programmer,
hence the argument to ``-c``. The argument to ``-p`` specifies the AVR device to
be the ATMega2560. The ``-U`` argument tells the program to write the
``nuttx.hex`` image to flash.

Configurations
==============

nsh
---

Very basic configuration with the ``nsh`` shell on the UART0 pins at a baud
rate of 38400. You can also access UART0 through the USB connector on your host
machine.
12 changes: 12 additions & 0 deletions boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ config ARCH_BOARD_ARDUINO_MEGA2560
This option selects the Arduino Mega 2560 board featuring the Atmel
Atmega2560 MCU running at 16 MHz.

config ARCH_BOARD_ELEGOO_MEGA2560R3
bool "Elegoo Mega 2560r3"
depends on ARCH_CHIP_ATMEGA2560
select ARCH_HAVE_LEDS
---help---
This option selects the Elegoo Mega 2560 board featuring the Atmel
Atmega2560 MCU running at 16 MHz.

config ARCH_BOARD_ARDUINO_DUE
bool "Arduino Due"
depends on ARCH_CHIP_ATSAM3X8E
Expand Down Expand Up @@ -3450,6 +3458,7 @@ config ARCH_BOARD
default "efm32-g8xx-stk" if ARCH_BOARD_EFM32G8XXSTK
default "efm32gg-stk3700" if ARCH_BOARD_EFM32GG_STK3700
default "ekk-lm3s9b96" if ARCH_BOARD_EKKLM3S9B96
default "elegoo-mega2560r3" if ARCH_BOARD_ELEGOO_MEGA2560R3
default "emw3162" if ARCH_BOARD_EMW3162
default "quickfeather" if ARCH_BOARD_QUICKFEATHER
default "esp32-audio-kit" if ARCH_BOARD_ESP32_AUDIO_KIT
Expand Down Expand Up @@ -4597,6 +4606,9 @@ endif
if ARCH_BOARD_ARDUINO_MEGA2560
source "boards/avr/atmega/arduino-mega2560/Kconfig"
endif
if ARCH_BOARD_ELEGOO_MEGA2560R3
source "boards/avr/atmega/elegoo-mega2560r3/Kconfig"
endif
if ARCH_BOARD_MOTEINO_MEGA
source "boards/avr/atmega/moteino-mega/Kconfig"
endif
Expand Down
4 changes: 4 additions & 0 deletions boards/avr/atmega/elegoo-mega2560r3/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
42 changes: 42 additions & 0 deletions boards/avr/atmega/elegoo-mega2560r3/configs/nsh/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DEBUG_OPT_UNUSED_SECTIONS is not set
CONFIG_ARCH="avr"
CONFIG_ARCH_AVR=y
CONFIG_ARCH_BOARD="elegoo-mega2560r3"
CONFIG_ARCH_BOARD_ELEGOO_MEGA2560R3=y
CONFIG_ARCH_CHIP="atmega"
CONFIG_ARCH_CHIP_ATMEGA2560=y
CONFIG_ARCH_CHIP_ATMEGA=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_AVR_LINUXGCC_TOOLCHAIN=y
CONFIG_AVR_USART0=y
CONFIG_BOARD_LOOPSPERMSEC=800
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_IDLETHREAD_STACKSIZE=128
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=768
CONFIG_INTELHEX_BINARY=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=768
CONFIG_PTHREAD_STACK_DEFAULT=128
CONFIG_PTHREAD_STACK_MIN=128
CONFIG_RAM_SIZE=8192
CONFIG_RAM_START=0x800200
CONFIG_START_DAY=16
CONFIG_START_MONTH=6
CONFIG_START_YEAR=2011
CONFIG_STDIO_BUFFER_SIZE=0
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART0_BAUD=38400
CONFIG_USART0_SERIAL_CONSOLE=y
88 changes: 88 additions & 0 deletions boards/avr/atmega/elegoo-mega2560r3/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/****************************************************************************
* boards/avr/atmega/elegoo-mega2560r3/include/board.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

#ifndef __BOARDS_AVR_ATMEGA_ELEGOO_MEGA2560R3_INCLUDE_BOARD_H
#define __BOARDS_AVR_ATMEGA_ELEGOO_MEGA2560R3_INCLUDE_BOARD_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/

/* Configuration ************************************************************/

/* Clocking *****************************************************************/

/* Assume default CLKDIV8 fuse setting is overridden to CLKDIV1 */

/* #define BOARD_XTAL_FREQ 20000000 */ /* 20MHz crystal */

/* #define BOARD_XTAL_FREQ 16700000 */ /* 16.7MHz crystal */

#define BOARD_XTAL_FREQ 16000000 /* 16MHz crystal */
#define BOARD_CPU_CLOCK BOARD_XTAL_FREQ /* F_CPU = 16MHz */

/* LED definitions for Elegoo Mega2560r3 */

#define LED_STARTED 0 /* OFF ON (when board turns on) */
#define LED_HEAPALLOCATE 1 /* OFF ON (never happens) */
#define LED_IRQSENABLED 1 /* OFF ON (never happens) */
#define LED_STACKCREATED 1 /* ON ON (never happens) */
#define LED_INIRQ 1 /* OFF NC (never happens) */
#define LED_SIGNAL 1 /* OFF NC (never happens) */
#define LED_ASSERTION 1 /* OFF NC (never happens) */
#define LED_PANIC 2 /* OFF ON (1Hz flashing PB7) */

/****************************************************************************
* Public Types
****************************************************************************/

#ifndef __ASSEMBLY__

/****************************************************************************
* Inline Functions
****************************************************************************/

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif

#undef EXTERN
#ifdef __cplusplus
}
#endif

#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_AVR_ATMEGA_ELEGOO_MEGA2560R3_INCLUDE_BOARD_H */
37 changes: 37 additions & 0 deletions boards/avr/atmega/elegoo-mega2560r3/scripts/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
############################################################################
# boards/avr/atmega/elegoo-mega2560r3/scripts/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/avr/src/avr/Toolchain.defs

LDSCRIPT = flash.ld
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)


CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__

EXEEXT = .elf
Loading