Program Atmega 1280 with Arduino Uno?

I have the need to program the bootloader into a Atmega 1280, its on a Mightyboard out of a 3d printer, there is an ICSP header for it, and while i was waiting for an AVR ISP programmer i bought to arrive i got to thinking i read an article a while back about programming them with an Arduino??

Here is the problem, so i got this 3d printer, its a Wanhao clone of the Makerbot Replicator 1 Dual, i got it cheap because its broken, well sort of.

The previous owner botched a firmware upgrade, so now when you turn it on there is no power up sound and the LCD display has two lines of blocks on it, just like you see when the printer normally boots briefly before showing the firmware rev and then the menu. So the board appears to be functional otherwise, i can connect to the board via USB and Windows installs the driver for the USB to Serial onboard and Replicator G sees the COM port for it, but thats it, there is no other communication possible and flashing the firmware from Rep G has failed at least 100 times now, it just won't do it.

So i got reading that its more then likely the 1280 got messed up by the failed/interrupted firmware upgrade and to recover it i need to use AVRDude and flash it again. I have the bootloader hex file, and the firmware hex file, i just need a way to communicate with it. The only AVR ISP programmer i could find affordable on eBay was of course in China, so where the ones on Amazon, so i'm stuck waiting 2-3 weeks before i can do anything with it. But thats where i got to thinking, i read something about programming from the Arduino, but i think it was the Mega that they were referring to. Google has failed me in finding that original writeup...

So long story short, i have a few Arduino Uno's, can i use one to program the Atmega 1280, and if so any links to how to's or detailed explanations that you could share would be fantastic!! I have been playing around with Arduinos for a while now for misc little projects and gadgets but looking forward to learning something new!

I presume you read

or were you looking for 1280 specific boot bin file ?

I did read through that, but it shows programming another Arduino or programming a chip on a breadboard, i am dealing with trying to program a 1280 SMD installed on an existing board with an ICSP 6 pin header. So thats where i got lost...

I have a boot file for the 1280, i found all the info and files to do this on a 3d printer forum, the problem is they are all using a standalone USB programmer which i do not have, i bought one but its going to take weeks to get here, so i was hoping to do it with the Arduino if i can to avoid the wait.

I have successfully programmed by Arduino MEGA (which is a m1280 based board) with an Arduino Uno running arduinoISP. It works fine. you CANNOT use arduino ISP for MORE than 128k of flash, but it works fine UP to 128k.

Interesting...

Ok, so its possible to do with the UNO, now the question is how do i wire this up. I have found a bunch of posts on this subject, some mention wiring from the ICSP port on the UNO to the ICSP port of the board you want to program, in my case a Mightyboard from the 3d printer, and then run the reset line over to D10. And yet other posts mention wiring the ICSP port of the board your trying to program to various pins on the UNO, and adding a capacitor or a resistor, etc etc.. Its all very confusing because every post i find on it they did something completely different.

Just looking for the magical formula that actually works!

Well i followed every tutorial i can find on the subject.. NONE of them work.

I just get an error from AVRDude saying that libusb0.dll is missing... So how the heck do i fix that? I installed the Arduino software latest version on my workbench computer and connected the UNO, it saw it, installed the drivers, and its on COM6, i can read and write to the Arduino. I uploaded the ISP sketch, grabbed my breadboard and wired the pins as shown in the sketch using the breadboard as a breakout to add the 10uf capacitor thats needed on the reset line, connected pins 10-13 to the ICSP header on the Mightyboard, powered up the mightyboard and tried the AVRDude command and it returns

LIBUSB0.DLL NOT FOUND REINSTALL BLAH BLAH BLAH

So now what?

Ok i got past the USB problem but then when i issue the command i get this...

C:>avrdude.exe -p m1280 -P COM6 -c avrisp -U flash:w:C:\ATmegaBOOT_168_atmega12
80.hex:i

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude.exe: Device signature = 0x000000
avrdude.exe: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.

avrdude.exe done. Thank you.

C:>

So how do i get past this and whats the -F to override

"device signature 0" usually means a wiring error in between the arduino acting as a programmer, and the chip you are trying to program.

-c avrisp

You should probably be using "-c stk500v1 -b19200"

I will try the command with that instead..

As for wiring its wired as...

Pin on Arduino - Pin on ICSP header of the Mightyboard

10 - Reset
11 - MOSI
12 - MISO
13 - SCK

I also ran a ground from the Arduino to the ICSP header, the Mightyboard is separately powered by its own 5v supply.

Ok i tried what you suggested, still didnt work, but the error message changed..

C:>avrdude.exe -p m1280 -P COM6 -c stk500v1 -b 19200 -U flash:w:C:\ATmegaBOOT_1
68_atmega1280.hex:i

avrdude.exe: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude.exe: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude.exe: stk500_disable(): protocol error, expect=0x14, resp=0x51

avrdude.exe done. Thank you.

C:>

So is this chip just hosed or what??

C:>avrdude.exe -p m1280 -F -P COM6 -b 19200 -c avrisp -u -U efuse:w:0xF5:m -U
hfuse:w:0xDA:m -U lfuse:w:0xFF:m

avrdude.exe: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x000000
avrdude.exe: Yikes! Invalid device signature.
avrdude.exe: Expected signature for ATMEGA1280 is 1E 97 03
avrdude.exe: reading input file "0xF5"
avrdude.exe: writing efuse (1 bytes):
Writing | | 0% 0.00s ***faile
d;
Writing | ################################################## | 100% 0.16s

avrdude.exe: 1 bytes of efuse written
avrdude.exe: verifying efuse memory against 0xF5:
avrdude.exe: load data efuse data from input file 0xF5:
avrdude.exe: input file 0xF5 contains 1 bytes
avrdude.exe: reading on-chip efuse data:

Reading | ################################################## | 100% 0.03s

avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x0000
0xf5 != 0x00
avrdude.exe: verification error; content mismatch

avrdude.exe done. Thank you.

C:>avrdude.exe -P COM6 -b 19200 -c avrisp -p m1280 -F -U flash:w:C:\ATmegaBOOT_
168_atmega1280.hex:i

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x000000
avrdude.exe: Yikes! Invalid device signature.
avrdude.exe: Expected signature for ATMEGA1280 is 1E 97 03
avrdude.exe: NOTE: FLASH memory has been specified, an erase cycle will be perfo
rmed
To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file "C:\ATmegaBOOT_168_atmega1280.hex"
avrdude.exe: writing flash (130838 bytes):
Writing | ################################################## | 100% 4.16s

avrdude.exe: 130838 bytes of flash written
avrdude.exe: verifying flash memory against C:\ATmegaBOOT_168_atmega1280.hex:
avrdude.exe: load data flash data from input file C:\ATmegaBOOT_168_atmega1280.h
ex:
avrdude.exe: input file C:\ATmegaBOOT_168_atmega1280.hex contains 130838 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 83.23s

avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x0000
0xff != 0x00
avrdude.exe: verification error; content mismatch

avrdude.exe: safemode: Fuses OK

avrdude.exe done. Thank you.

You're still using "-c avrisp" rather than "-c stk500v1" (they may actually be synonyms. I'm just saying what worked for me.)

You should forget that -F exists. There are essentially NO circumstances where you should need to use it.

I usually use:

avrdude -c stk500v1 -p atmega1280 -P COM5 -b19200 -t

Until I establish reliable communications with the programmer (-t is "interactive mode")...