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. Fotuneatly 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 |
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 and memory. To access this monitor open up a serial port at 115200 and type "!!!" within 3 seconds.
The commands are
The monitor is VERY useful to test hardware. For example you can blink any port, you can look at flash, ram and eeprom.
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 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>
avrdude: verification error, first mismatch at byte 0x3e000 0x0d != 0xff avrdude: verification error; content mismatch
############################################################## # Added for Emartee in china # by Mark Sproul msproul@skychariot.com June 2010 mega2560.name=Arduino Mega2560 mega2560.upload.protocol=stk500 mega2560.upload.maximum_size=258048 mega2560.upload.speed=57600 mega2560.bootloader.low_fuses=0xFF mega2560.bootloader.high_fuses=0xD8 mega2560.bootloader.extended_fuses=0xFD mega2560.bootloader.path=atmega mega2560.bootloader.file=ATmegaBOOT_168_mega2560.hex mega2560.bootloader.unlock_bits=0x3F mega2560.bootloader.lock_bits=0x0F mega2560.build.mcu=atmega2560 mega2560.build.f_cpu=16000000L mega2560.build.core=arduino