Wednesday, October 12, 2011

arduino uno revived!

This is the second post with a trailing exclamation point. I hope I'm not getting too excited here in my room alone @ 10:30 pm. What I have done tonight is successfully revived my Arduino Uno that my friend and I broke this last spring. Here were its symptoms:

  • The uno could :
    • Run the last code that was on it
  • The uno could not:
    • Be recognized normally by a computer through the USB port therefore it could not
    • Receive new code
Since then, I was thinking I'm out of luck and down $35 or whatever it cost me... until now.  So if you have a newer Arduino uno (the one that uses the ATmega8U2 - look at the writing on the other little SMD chip next to USB port) and have some problem with it not being recognized by a computer normally, there may be hope!

Since I've been working on my ATtiny84, I needed some sort of programmer. I bought the USBtinyISP which I've talked about many times. With this I'm able to manually put code (flashing hex files or modify fuses) on most of the AVR AT* chips. Cool.   Now I also knew that there were two microcontrollers on the newer Arduino Unos.  The one you program normally: ATmega328 and the one whose job is to program the ATmega328 with what comes in from the USB.  This uC is the ATmega8U2.

My first thought was to reflash the main uC (ATmega328) with its bootloader, thinking that something was wrong with it.  I was wrong.

My second thought was, "Woah, Ethan.  There's another 6 pin SPI interface for the in system programmer! Perhaps I can load the ATmega8U2 with its original program!"  This is when things started getting exciting, since there was hardly any information on this.  Many websites and walkthroughs told me to use the USB input, a utility from AVR, solder a resister on the back and wire up some other things to get it to work.  I thought there had to be another way since these nice SPI pins were looking me right in the face. So I plugged in my USBtinyISP to these 6 pins and started looking for source code to upload.

Here you'll find where that code is.  I used Arduino-usbserial-uno.hex for the file that needed to be flashed to the 8U2.  Now I manually needed to run avrdude (found in win-avr) to actually write this hex file to the 8U2's flash memory.  This can be done with this command:

avrdude.exe -c usbtiny -p at90usb82 -F -U flash:w:**********

where ********** is your path to Arduino-usbserial-uno.hex.  


After a few seconds, this is completed.  If the avrdude command doesn't work for you, perhaps your programmer isn't installed correctly, you've got it plugged in wrong, this isn't actually your problem, or many other things.  The error would maybe give you a more specific direction.

When this was done writing, I plugged in my Arduino Uno.  Pretty much to my full surprise my computer recognized the Uno...  

I hope this helps some people out if they run into the same problem.  Back when we were working on the project, we must've shorted something on the 8U2 to erase/corrupt the flash.  This probably doesn't happen too often but maybe once in a while.  Also some people get corrupted ones brand new.  If you have a programmer on hand, this is a viable solution. I sincerely hope this does show up in google searches, because I could've used it a while ago!!

10 comments:

  1. My Atmega328 executes the last code, i've tried to upload trough ISP, but it said that device signature wasn't recognized.

    ReplyDelete
    Replies
    1. Is the other chip on your Uno the ATmega8U2? Are you using the correct command for your programmer? Is your programmer plugged into the correct 6 pin header (there's two). Does the board have power?

      Delete
    2. Electrical connections are fine. I used khazama avr program and usbasp programmer, I think the matter is with fuses, because I have the same response with blocked ATmega16.

      Delete
    3. Yeah and there might be a problem with ATmega8U2, because I've changed with new ATmega328 preuploaded with bootloader, no response in programing throu RX, TX. So main priority is to revive the 8U2.

      Delete
  2. I also have the UNO R2 with the same problem. It executes the last code loaded but shows up under USB controllers as Unknown Device. I don't have the USBtinyISP though. I do have a FTDI Basic Breakout - 5V from Sparkfun. Is there a way to use this instead? If I bought the tinyISP I'm not sure what I would do with it afterwards as I'm just starting out with this stuff.

    ReplyDelete
    Replies
    1. Yep! It should be possible, although I don't have the hardware, so I couldn't tell you exactly how it interfaces. I think you'll need to wire the output of that basic FTDI breakout board to the ISP on the Uno. Also the command for avrdude will be different, because you're using a different programmer.

      Delete
  3. I see an ICSP 6-pin header. Is that the same one as the ISP that I hear talked about everywhere? It's at the opposite end of the board from the USB.

    ReplyDelete
  4. Today I was working with my mega 2560 when I accidentally plugged 12v on the 5v pin and smth strange happened: this problem appeared and I thought I burned the 8u2. This blog post gives me some hope.
    I will be using a mega ADK borrowed from a friend with AVRISP skecth to program the firmware back into the 8u2.
    I must say that it was hard to get to this information.
    Thank you!

    ReplyDelete
    Replies
    1. Good luck rodrigo! I hope it is something as simple as reflashing the 8u2.

      Delete
    2. Just checking in. Result: did not work. After setting up everything and after a few syntax error with the avrdude.exe command I got the CMD line running. It flashed the error light, the after a few seconds the programming and error flash and on the cmd prompt I get this message: avrdude.exe: stk500_getsync(): not in sync: resp=0x00
      maybe the 8u2 is actually burned (although there's no physical evindence for that) and my mega is off to the trash :-P

      Delete