Mega 2560 wont upload sketches

I have a mega 2560 r3 that i had been playing around on for a little bit. I had tried to use a USBtinyisp to flash a midi firmware software onto it,but it just ended up messing up my board.

The weird thing is that is shows up in device manager as the 'arduino mega 2560(com3)' so i figured it would still be ok. The IDE detects it as well. When i upload sketches, it will look like its sending it over but it doesnt. Trying to reinstall the bootloader from the IDE doesn't work either when i have it hooked up through usbtinyisp.(hangs)

I downloaded 'flip' in hopes of getting it to flash but it says 'could not open usb device'

trying to flash the midi firmware on avrdude and i get this: usbdev_open(): did not find any USB device

Figured that i got the right device and that usbtinyisp would be able to reflash it back to normal.Not sure if it needs to be in DFU mode or what to get it to flash over.

Does anyone have any idea what .hex file i would need to flash over and the steps to fix this? Maybe the usbtinyisp isn't capable of flashing on the 2560. The ebay person said it would that i got it from.Idk.thanks

What did you program and mess up using ISP, the ATmega2560 or the ATmega16U2 (or both)?

Sounds like you need to restore the firmware on the ATmega16u2. If the firmwre currently loaded includes DFU (Direct Firmware Update) mode you should be able to use the Atmel FLIP program to upload new firmware. Here are instructions: http://projectsfromtech.blogspot.com/2013/03/updating-firmware-on-atmega16u2.html

If the DFU firmware has been overwritten you will need to use the USBtiny to burn fresh firmware. On my Mac the firmware you want appears to be this file: hardware/arduino/avr/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex The commands on my Mac would be something like:

cd /Applications/Arduino 1.6.5rc3.app/Contents/Java/hardware

tools/avr/bin/avrdude -C tools/avr/etc/avrdude.conf  -p at90usb162 -P usb -c usbtiny -v -F -e -u -U efuse:w:0xF4:m -U hfuse:w:0xDF:m -U lfuse:w:0xFF:m -U flash:w:arduino/avr/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lock:w:0x2b:m

dmjlambert: What did you program and mess up using ISP, the ATmega2560 or the ATmega16U2 (or both)?

Sorry, it was my actual Arduino mega 2560 that i screwed up. I tried to flash a firmware from my ISP, connected to the mega. The tiny ISP seems to connect through usb just fine by itself but, i dont have anything else to connect it to try and see if i can program something else.

IF this programmer on this link is like the USBtinyISP, then maybe it wasn't capable of programming on the 2560 among other ones:

https://learn.adafruit.com/usbtinyisp

"Works with any AVR ISP chip with 64K of flash (or less) - does not work with Atmega1281/1280/2561/2560"

Thanks John. It doesn’t feel completely broken besides me not able to flash sketches onto anymore. I’ll give this a try and see if i can get it to work.Appreciate it.

johnwasser:
Sounds like you need to restore the firmware on the ATmega16u2. If the firmwre currently loaded includes DFU (Direct Firmware Update) mode you should be able to use the Atmel FLIP program to upload new firmware. Here are instructions:
Projects from Tech: Updating Firmware on ATmega16U2

If the DFU firmware has been overwritten you will need to use the USBtiny to burn fresh firmware. On my Mac the firmware you want appears to be this file: hardware/arduino/avr/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex The commands on my Mac would be something like:

cd /Applications/Arduino 1.6.5rc3.app/Contents/Java/hardware

tools/avr/bin/avrdude -C tools/avr/etc/avrdude.conf  -p at90usb162 -P usb -c usbtiny -v -F -e -u -U efuse:w:0xF4:m -U hfuse:w:0xDF:m -U lfuse:w:0xFF:m -U flash:w:arduino/avr/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lock:w:0x2b:m

If you tried to upload to the ATmega2560 with a usbtiny, then I would suspect that is your problem, the ATmega2560 no longer has a bootloader. Proceed to the loopback test, which is one of the sticky posts at the top of the forum. If the loopback test works, it means your ATmega16U2 is fine and does not need a flash. You just need to burn a bootloader onto the ATmega2560 using something other than usbtiny, perhaps another Arduino running the ArduinoISP sketch and choose on the Tools, Programmer menu "Arduino As ISP"

I did and i'm now thinking thats how it got messed up. I followed 'johnwasser' instructions and seemed to have functioned for the most part. I was able to get it into DFU mode and flash the hex file it said no problem. Still i have the same issue with it not uploading sketches.

This were some of the errors from trying to upload the sketch via the IDE:

avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer

I'' try to find the the sticky you mentioned and let you know how it goes. If i program it with another Arduino doing it that method, does it need to be the same one i use or can i use a cheap uno or something? My mega was an authentic one when i got it. Thanks for the help.

Any Arduino will do, what do you have on hand?

All i have at the moment is my mega 2560 which is broken. Maybe i'll pick up an Uno off ebay and go from there.

I still want to try to flash the midi firmware later on down the road but hopefully do it right this time. Is this programmer capable of fixing my 2560 and flashing the "Hiduino" firmware onto it as well?

"Atmel AVRISP STK500 USB ISP Programmer"

http://www.seeedstudio.com/depot/Atmel-AVRISP-STK500-USB-ISP-Programmer-p-207.html

Im gonna try the loopback test tonight and let you know the results

johnwasser: If the DFU firmware has been overwritten you will need to use the USBtiny to burn fresh firmware. On my Mac the firmware you want appears to be this file: hardware/arduino/avr/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex The commands on my Mac would be something like:

cd /Applications/Arduino 1.6.5rc3.app/Contents/Java/hardware

tools/avr/bin/avrdude -C tools/avr/etc/avrdude.conf  -p at90usb162 -P usb -c usbtiny -v -F -e -u -U efuse:w:0xF4:m -U hfuse:w:0xDF:m -U lfuse:w:0xFF:m -U flash:w:arduino/avr/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lock:w:0x2b:m

I hooked up the USBtiny and modded the code a little since im on windows 8.1 but for once it seemed like it was trying to write the bootloader.

New code ( avrdude -C avrdude.conf -p at90usb162 -P usb -c usbtiny -v -F -e -u -U efuse:w:0xF4:m -U hfuse:w:0xDF:m -U lfuse:w:0xFF:m -U flash Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lock:w:0x2b:m )

All other times it would just say " usbdev_open(): did not find any USB device" .Looking over what it says though after i run command, im not sure if its gonna let me program the bootloader onto this. I added a screenshot but it does say 'avrdude: programmer operation not supported'

Maybe i'll need to just go buy either a better programmer or get a cheapy arduino uno to fix it.

http://i.imgur.com/Oe9XF3R.png

If anyone has any other ideas that think might work, i'd be willing to try them out. Still got farther than both programs than i had before when i was trying to fix it. Thanks for your time anyways.

Did you do the loopback test?

I did but it seems to be acting strange. I'm hoping i got the jumpers on the right places but i'll add a picture of where i placed them:

http://i.imgur.com/J3jSu0C.jpg

Opening the Arduino IDE program i noticed that Tools/port is greyed out. For some reason it says i'm on COM4 now instead of the COM3.All i can think is trying to flash it last time might of changed it. Opening serial monitor in the IDE says 'Board at COM4 is not available'.With both those jumpers on device manager doesn't show anything about the arduino device. If i pull the reset jumper then i get the 'ATmega16U2' which is to be expected. Having the jumpers on though and plugging in the device, there is no sound or anything in device manager to show it connected.

When i take the jumpers off and open IDE, the Tools/port menu is no longer greyed out and can select the only one which is COM4. Very frustrating as i have no clue why it switched over. Unless i got the jumpers put in wrong i don't know what happened.

EDIT: I went into device manager and 'show hidden devices' and deleted the COM3 that says wasnt in use. Plugged it back in and Switched it back in the IDE. Very strange.

Maybe i just need to go get another arduino and use that as an ISP to fix this one like you said. All i can think of is that whatever i did with the usbtinyisp programmer probably wasn't good and or compatible with my device. I cant really tell what progress i made with flashing it with avrdude but, for some reason there looked to have some writing errors.

So i decided to try and see if i could reflash the code to my arduino, one last time with the USBtinyisp. I used johnwasser's code and added '-vvvvvvvv' since i read it either slows down/speeds up the read or write speed. Whatever it did, it seemed to have worked! :)

I took off the programmer and connected the arduino and uploaded the blink sketch no problem.(along with a few others to try them out)

Maybe it just needed to be slowed down/sped up in order to write the amount of memory before shutting itself off.idk.

I found a website that says the 'Pololu USB AVR Programmer' is compatible with the 2560.So if i get that i should be able to flash the midi firmware and atleast be able to fix it if i screw it up somehow. Once again thanks for all the help/support in trying to get this working.

I like the USBasp programmer. You can get a clone version for about $3 via eBay and it supports the STK500V2 protocol needed for the larger chips. The main issue with the USBasp is that it typically come with only a 10-pin ICSP cable where the Arduino has a 6-pin connector. The only difference is that the 10-pin version has five signal wires interleaved with five ground wires. The 6-pin version has five signal wires and one ground wire. You can get a 10-to-6-pin adapter from eBay for about $1.

johnwasser: I like the USBasp programmer. You can get a clone version for about $3 via eBay and it supports the STK500V2 protocol needed for the larger chips. The main issue with the USBasp is that it typically come with only a 10-pin ICSP cable where the Arduino has a 6-pin connector. The only difference is that the 10-pin version has five signal wires interleaved with five ground wires. The 6-pin version has five signal wires and one ground wire. You can get a 10-to-6-pin adapter from eBay for about $1.

I'll have to take a look at that for sure. Especially if i can get it for just $4.00 compared to the $20.00 for the other one.Seeing if you could help me with one more thing. When i decide to flash to midi firmware again, do you know in what order i need to do it? Here was a link to the site:

https://github.com/ddiakopoulos/hiduino

It's all confusing to me even after reading what it is asking for. Do i first flash this file : arduino_midi.hex and then flash the usbserial_mega_16u2.hex file after that or just one or the other? ty