Sie sind auf Seite 1von 3

Bootloader for Arduino Mega2560

Bootloader for Arduino Mega2560

The standard Arduino bootloader uses STK500 version 1 protocol. This protocol works fine up to chips that have
128 bytes of Flash.
After that it does not understand the extended addressing. Fortunately there is STK500v2 protcol
that can handle larger memory footprints.

I started with the wiring project stk500 v2 bootloader and modified it to work with the 2560.

This bootloader has been tested on

CPU BOARD Web site


atmega2560 Arduino mega
atmega1280 Arduino mega
atmega128 Amber128 http://www.soc-robotics.com/
atmega32 Penguino-AVR http://www.icy.com.au/
atmega2561 Boston Android http://www.bostonandroid.com/EVAL-USB-2561.html

It should be able to be made to work with any larger atmega cpu by modifiying the make file which is included with
the source.

How to use the 2560 and others in Arduino

Download new Arduino core files Alternate CORE files

NOTE: This ONLY applies to version 0019 and earlier. If you have 0020 you DO NOT NEED TO DO THIS.

Update eeprom.h

Click here for eeprom.h.zip


It must be placed in hardware/tools/avr/avr/include/avr.>
On the MacOSX, the full path is
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr/include/avr

This is STILL NEEDED for 0020.

Restart Arduino software

Full source and make files can be found here stk500v2bootloader.zip

The current bootloader in the Arduino mega board has a little known fact that it has a monitor built in. It is not very
usable in that it has to be done with a program and cannot be used via a terminal because it uses binary commands.
In order
to access this "monitor" you have to open the serial port at 57600 baud and type "!!!" before it jumps to the
main program.

I have done the same thing in the new bootloader but it is a command prompt to allow you to look at the hardware

http://www.avr-developers.com/bootloaderdocs/index.html[18/05/2017 13:59:09]
Bootloader for Arduino Mega2560

and memory.
To access this monitor open up a serial port at 115200 and type "!!!" within 3 seconds.

The commands are

0=Zero address counters


?=CPU stats
@=EEPROM test
B=Blink LED
E=Dump EEPROM
F=Dump FLASH
H=Help
L=List available Ports
Q=Quit and jump to user program
R=Dump RAM
V=show interrupt Vectors
Y=Port blink

This bootloader takes 8K memory and I have used almost every available byte. The monitor can be turned of but this
was designed for the atmega2560, atmega1280, and atmega128, all of which have plenty of flash memory space.

The monitor is VERY useful to test hardware. For example you can blink any port, you can look at flash, ram and
eeprom.

Sample output

Arduino Bootloader>? CPU stats


Arduino explorer stk500V2 by MLS
Compiled on = Aug 2 2010
CPU Type = ATmega2560
__AVR_ARCH__ = 6
GCC Version = 4.3.3
AVR LibC Ver = 1.6.7
CPU signature= 1E9801
Low fuse = FF
High fuse = D8
Ext fuse = FD
Lock fuse = FF
Arduino Bootloader>
ATmega2560
V# ADDR op code instruction addr Interrupt
01 - 0000 = C5 95 00 00 rjmp 0595 >000B2A RESET
02 - 0002 = C5 C0 00 00 rjmp 05C0 >000B84 INT0
03 - 0004 = C5 BE 00 00 rjmp 05BE >000B84 INT1
04 - 0006 = C5 BC 00 00 rjmp 05BC >000B84 INT2
05 - 0008 = C5 BA 00 00 rjmp 05BA >000B84 INT3
06 - 000A = C5 B8 00 00 rjmp 05B8 >000B84 INT4
07 - 000C = C5 B6 00 00 rjmp 05B6 >000B84 INT5
08 - 000E = C5 B4 00 00 rjmp 05B4 >000B84 INT6
09 - 0010 = C5 B2 00 00 rjmp 05B2 >000B84 INT7
10 - 0012 = C5 B0 00 00 rjmp 05B0 >000B84 PCINT0
11 - 0014 = C5 AE 00 00 rjmp 05AE >000B84 PCINT1
12 - 0016 = C5 AC 00 00 rjmp 05AC >000B84 PCINT2
13 - 0018 = C5 AA 00 00 rjmp 05AA >000B84 WDT
14 - 001A = C5 A8 00 00 rjmp 05A8 >000B84 TIMER2 COMPA
15 - 001C = C5 A6 00 00 rjmp 05A6 >000B84 TIMER2 COMPB
16 - 001E = C5 A4 00 00 rjmp 05A4 >000B84 TIMER2 OVF
17 - 0020 = C5 A2 00 00 rjmp 05A2 >000B84 TIMER1 CAPT
18 - 0022 = C5 A0 00 00 rjmp 05A0 >000B84 TIMER1 COMPA
19 - 0024 = C5 9E 00 00 rjmp 059E >000B84 TIMER1 COMPB
20 - 0026 = C5 9C 00 00 rjmp 059C >000B84 TIMER1 COMPC
21 - 0028 = C5 9A 00 00 rjmp 059A >000B84 TIMER1 OVF
Arduino Bootloader>L List available Ports
PORTA
PORTB
PORTC
PORTD
PORTE
PORTF
PORTG
PORTH

http://www.avr-developers.com/bootloaderdocs/index.html[18/05/2017 13:59:09]
Bootloader for Arduino Mega2560

PORTJ
PORTK
PORTL
Arduino Bootloader>
Arduino Bootloader>R Dump RAM
0000 - 00 00 20 02 87 20 10 10 08 00 00 00 00 00 0E 00 .. .. ..........
0010 - 00 00 00 E3 00 00 20 00 2E 10 01 02 86 20 1E 00 ...... ...... ..
0020 - 00 00 00 80 80 80 00 00 00 07 00 00 03 00 00 00 ................
0030 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040 - 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 62 ...............b
0050 - 30 00 62 00 07 00 62 00 62 62 62 07 01 86 20 02 0.b...b.bbb... .
0060 - 00 00 62 62 00 00 88 62 00 00 00 00 00 00 00 00 ..bb...b........
0070 - 00 00 00 00 00 00 62 62 00 00 00 00 00 00 00 00 ......bb........
0080 - 00 00 00 62 00 00 00 00 00 00 00 00 00 00 62 62 ...b..........bb
0090 - 00 00 00 62 00 00 00 00 00 00 00 00 00 00 62 62 ...b..........bb
00A0 - 00 00 00 62 00 00 00 00 00 00 00 00 00 00 62 62 ...b..........bb
00B0 - 00 00 00 00 00 62 00 62 00 F8 FE FF 00 00 62 62 .....b.b......bb
00C0 - 22 18 06 62 10 00 6C 62 20 00 06 62 00 00 00 62 "..b..lb ..b...b
00D0 - 20 00 06 62 00 00 00 62 62 62 62 62 62 62 62 62 ..b...bbbbbbbbb
00E0 - 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 bbbbbbbbbbbbbbbb
00F0 - 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 bbbbbbbbbbbbbbbb
Arduino Bootloader>

http://www.avr-developers.com/bootloaderdocs/index.html[18/05/2017 13:59:09]

Das könnte Ihnen auch gefallen