If you try using the 'monitor' built-in the bootloader by typing 3 '!' immediately after hitting the reset button on the Arduino mega2560 you will see a bunch of garbage on the screen, every time you type a character. Well the program has a bug (several bugs), for those technically inclined, the RAMPZ I/O register is initialized to '0' instead of '3' in the PrintFromPROGMEM() routine. I have a kludge that will allow you to use the monitor with proper prompts! You need a 'C' ino file and a '.S' assembler file (note the capital 'S') to fix the problem. You will then be able to examine the bootloader. To examine your program, you have to update the '.org' statement so that the strings start at 0xE0E4, with the mostly empty kludge program, 0x110 has to be subtracted, the bigger the program the bigger the offset to subtract, thanks to the compiler/assembler/linker(check the hex file it tells you where the stuff is loaded in memory). Create a kludge project in the arduino IDE and upload it to your mega2560. Then you can use to IDE's Serial Monitor to send !!! after a reset on the mega (be quick, a very short timeout disables the !!! escape) Set the speed of the Serial Monitor to 115200. I included a sample usage using the Tera terminal emulator. Enjoy!
kludge.ino
extern "C"
{
void start();
}
void setup() {
start();
// your program here, remember to update the '.org'
}
void loop() {
// your program here
}
kludge.S
.global start
start:
ret
.org (0xe0e4 - 0x110) ;this is a byte address and
;somehow the compiler/assembler
;locates it at 0xE1F4, hence the
; " - 0x110 " to end up at 0xE0E4!!!
mix:
.ascii "ATmega2560\0", \
"Arduino explorer stk500V2 by MLS\0", \
"Bootloader>\0", \
"Huh?\0", \
"Compiled on = \0", \
"CPU Type = \0", \
"__AVR_ARCH__= \0", \
"AVR LibC Ver= \0", \
"GCC Version = \0", \
"CPU ID = \0", \
"Low fuse = \0", \
"High fuse = \0", \
"Ext fuse = \0", \
"Lock fuse = \0", \
"Mar 7 2013\0", \
"1.6.8\0", \
"4.3.5\0", \
"V# ADDR op code instruction addr Interrupt\0", \
"no vector\0", \
"rjmp \0", \
"jmp \0", \
"What port:\0", \
"Port not supported\0", \
"Must be a letter\0", \
" \0", \
"Writting EE\0", \
"Reading EE\0", \
"EE err cnt=\0", \
"PORT\0", \
"0=Zero addr\0", \
"?=CPU stats\0", \
"@=EEPROM test\0", \
"B=Blink LED\0", \
"E=Dump EEPROM\0", \
"F=Dump FLASH\0", \
"H=Help\0", \
"L=List I/O Ports\0", \
"Q=Quit\0", \
"R=Dump RAM\0", \
"V=show interrupt Vectors\0", \
"Y=Port blink\0", \
"*\0"
Partial sample of 'hex' file showing where the strings should be in flash memory, skipping lots of lines before and after.
...
3598 :10E0D0000000000000000000000000000000000040
3599 :10E0E0000000000041546D656761323536300041F3
3600 :10E0F000726475696E6F206578706C6F72657220DE
3601 :10E1000073746B3530305632206279204D4C530099
3602 :10E11000426F6F746C6F616465723E004875683F52
3603 :10E1200000436F6D70696C6564206F6E203D200048
3604 :10E130004350552054797065202020203D20005FF9
3605 :10E140005F4156525F415243485F5F3D2000415658
...