Go Down

Topic: Build and burn bootloader for virgin MEGA2560 device (Read 1 time) previous topic - next topic


I posted a question similar to this as a reply to a different subject; then realized that the subject was dated, so I am reposting a new question...
I have a board that is similar to the ArduinoMEGA2560.  I want to build and burn each of the bootloaders (Mega8u2 and Mega2560) from scratch.  Currently, I am having trouble with the Mega2560.  I'm trying to build (and then install) the .hex file that ultimately turns into the stk500boot_v2_mega2560.hex file.  I made what I think are the necessary adjustments to the makefile under hardware/arduino/bootloaders/stk500v2 and can run "make clean; make all" to create a stk500boot.hex file.  I've also modified the 'program' rule in that makefile to allow me to directly download to my 2560 (using Pololu USB AVR Programmer).  After I install this on my board, I can run it and I am able to type '!!!' and it returns the multiple lines of exclamation points indicating that the firmware has entered the RunMonitor() function. This is good; however, after that the code uses PrintFromPROGMEMln() and the loop looking for a null terminator never ends because the data pointed to is 0xff.  The .hex file appears to have the data consistent with the .lss file; however, the data pointed to in the runtime code doesn't seem to agree with that.  Not being very familiar with AVR, I'm hoping someone can give me the magic formula (probably some parameter in the makefile I haven't set) that will get me over this.
Anyone know what I'm doing wrong?


Well, I'm answering my own question here just in case someone else runs into a similar snag...
The problem was that I was using a BOOTLOADER_ADDRESS value of 1E000 instead of 3E000.
I knew it was supposed to be 3E000; however I was getting an error because the size of the
image exceeded 0x2000.
Anyway, to reduce the image size I just #ifdeffed a few of the Monitor commands out.
Also, there was another thread somewhere asking about the '!!!' problem.  I put in a small
fix for this as well.  Not really knowing the purpose of this code in detail, the fix may not
be appropriate for general use, but it does what I need it to do for my board.

So, I am now able to build the ATMEGA2560 bootloader and install it with Pololu programmer.
Just posting this incase someone else needs the info.

Go Up