I've been working with Arduino for a while (Since 2 years ago) and finally I decided it's time for me to develop my projects on a custumised PCB with ATMEGA2560 built on it. After successfully build my project on Arduino Development board, Ii designed my own PCB with everything built on it.
I'm trying to upload the Arduino bootloader to my ATMEGA2560 on my PCB but with no success. I have a USBTinyISP and I'm using the Arduino IDE to burn the bootloader. I selected Arduino Mega 2560, the USBTinyISP programmer and selected Burn Bootloader, but it returns me this error:
C:\Program Files\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files\Arduino/hardware/tools/avr/etc/avrdude.conf -q -q -patmega2560 -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
I don't know what to do, what might be the problem? I already checked the pinout of my PCB and it matches the USBTinyISP pinout and everything seems to be ok.
Maybe something related to this, from the designer of the Red Back Robot Controller (2560 compatible):
---------------------( COPY )---------------------
If the students do corrupt the bootloader then I have written a tutorial for
re-burning the bootloader here: http://letsmakerobots.com/node/35649
Please note that the tutorial does not seem to work with Arduino 1.05 or
later but works fine with 1.04.
When burning the bootloader for the ATmega 2560 you will get an error
message at the end but the bootloader will work fine. This is not a fault
with the PCB.
It seems to be a problem with the software as other people have had the same
problem with Arduino Mega 2560 boards.
-----------------( END COPY )----------------------
Also, he says that sometimes he has to immediately retry burning with the 2560.. Hmmm....
The factory chips come clocked at 1Mhz. Some programmers won't run slow enough to communicate with the chip at that speed.
This could be the issue you are seeing.
You can use something like ArduinoISP or one of Nick Gammons bootloader/programmer sketches. You could also set your programmer to a slower clock using either a hardware jumper or through software (avrdude -B option).
For sure the USBtiny cannot properly write to the higher address space use by the 2560 bootloader code uses because (if I recall correctly) of the protocol the USBTiny uses with AVRDUDE.
That involves the USBASP and mentions the bootloader appearing in two memory locations. I know that the latest USBASP firmware means they can address 128kb of Flash (64 kilo Word) and work well with AtMega1284.
I seem to recall reading somewhere that this means you CAN burn the bootloader because it effectively writes it twice, by writing two blocks of 128kB (repeated). You get an error, but it can be ignored. This means you can burn the bootloader but you can't burn any normal sketches (via ICSP) of over 128kb.
I'm not sure if the USBTinyISP is similar. If it can only do 64kb then it probably won't have the same quirk that just happens to allow an updated USBASP to burn the bootloader when it technically shouldn't do.