Showing posts with label usbtinyisp. Show all posts
Showing posts with label usbtinyisp. Show all posts

Sunday, March 24, 2013

Updating Firmware on ATmega16U2

Ok. I promised I'd tell how I updated the firmware on my ATmega16U2 on my Arduino Mega. Hopefully I will remember everything I did. Below are some of the websites I referenced to do this.
http://arduino.cc/en/Hacking/DFUProgramming8U2
http://andrewmemory.wordpress.com/2011/04/14/upgrading-the-arduino-uno-8u2-using-flip/
http://aphes.com/hardware/how-to-set-arduino-mega-2560-r3-into-dfu-mode/

Step 1. Download and install Flip programmer from Atmel.

Step 2. Make sure you have the latest version of the Arduino IDE. This will include the firmware you'll need.

Step 3. Plug in your Arduino and find it in the device manager. There are 6 male pins sticking up near the USB socket. Find the two nearest the socket and bridge them with some wire (as shown HERE and to the right). The Arduino should disappear from the device manager. Take the wire off. The Arduino should re-enter as an unknown device. It is now in DFU mode. If you unplug the USB, you will have to do this step again.

Step 4. Open the new device that is the ATmega16U2 in the device manager and load the driver for the flip programmer. On my install it was C:\Program Files (x86)\Atmel\Flip 3.4.7\usb. I just let it search that folder and it found it. Alternatively you could just say "have disk" and click on it. It should be similar to atmel_usb_dfu.inf.

Step 5. Open Flip. Click Load Hex File. You want "Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex" (assuming you are using a Mega 2560 rev 3). It is in your Arduino folder. It can be found at this location. "arduino-1.0.4\hardware\arduino\firmwares\atmegaxxu2\arduino-usbserial". You should get a message something like "Hex file parsed" at the bottom.

Step 6. Click Select Target Device. Select ATmega16U2.

Step 7. Click Select Communication Medium. Select usb. Click open. This should bring up a new page with all sorts of interesting things to look at.

Step 8. Click Run. Assuming all goes well, you are done. Unplug your Arduino and plug it back in.

The most useful site I found was a blog HERE. Note that he was using an Uno. The Mega rev3 is easier to put into DFU mode. All you have to do is short the two pins I described above.

I hope this was helpful. If you find anything that I posted is wrong, let me know in a comment or by email. You can also email or comment if you have problems and can't get it to work. I will try to help as best I can.

Have fun in your endeavors!
Matthew

Friday, March 22, 2013

Arduino Mega as ISP- broken Arduino

Well it has been a while since I posted anything on here, and there are several good reasons for that. One, last week was spring break, and it was beautiful. I did a lot of stuff outside and never really touched my computer. Two, right before spring break I managed to break my Arduino again. Here's how.

As I have mentioned I got an ATtiny85 to play around with. I thought it would be a natural next step to start doing stuff with just the bare chip. I am by no means an expert in such things and thus went searching for someone else's work that I could shamelessly copy in the name of education. I found this website HERE and began to follow their instructions.

Now to program these chips you need an external programmer. Being a college student and not having a whole lot of money that I just long to spend, I decided to go with the Arduino as ISP route. Well you can go to the website if you don't know what that entails, but to the right there's a picture to give you a general idea. Basically you are piggybacking off of the Arduino's programmer.

This went great! I plugged in all the wires based off of the charts on the high-low tech page, followed the rest of the instructions, and clicked go. Off the races I went, loading blink. I unplugged everything but the power and ground and got a blinking light! Yay!

Now that's cool. I plugged the wires back in and loaded fade. Error. Try again. Error. Sigh.

Now I unplug everything and try to load blink onto the arduino. It took forever to try to upload. Error. I believe it was something like the one below. Its funny that I saw it so many times but never actually copied it down.

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

Then I got thouroughly depressed and didn't touch it for a few days. Later I began trying to fix it.

Attempt 1: The reset doesn't appear to be working. Google such things. Nothing. Manual reset with a resistor on reset pin. Nothing. I hope this isn't the problem.

Attempt 2: Somehow I decided it might be the ATmega16U2 firmware (the smaller chip near the usb port). Download necessary stuff and reflash it. This took a while for me to figure out, but I finally did it. Successful firmware update, but no results. I never found a good tutorial on how to do this on a Mega, so I will post one later based on what I learned next time.

Attempt 3: Re-download Arduino IDE. Yes, this should have been my first step, but for various reasons it was not. Well this did not fix it either, but then a few days ago I notice that there was a new version 1.0.4. The release notes yielded this, "Fixed a bunch of bugs on Mega2560's bootloader (Mark Sproul)." Bingo I think. My problems are solved.

Well to upload the bootloader I needed a programmer. So now I bought what I should have bought in the first place, a usbtinyisp. I got mine off eBay from a US seller for $15 I think. You can also get kits HERE. There's a picture if you're wondering.

I uploaded the bootloader (go HERE for now). I may do a tutorial on this later too. Who knows. Anyway, I upload the bootloader and it appears to go well until I get an error message. It didn't work. However, I notice that the led is blinking on the Arduino. That's odd. Before it was just on all the time. It wouldn't blink even if  I pushed the reset button. I plugged in the USB cable to the Arduino, and its alive again.

I have no idea what the problem was or what fixed it, but it now works again. The moral of this story (for me anyway) is spend the $15 and get an isp. $15 could have saved me many hours. Then again, I learned a lot through this process. I learned a lot about flashing firmware, loading bootloaders, and maintaining patience.

There will be more posts to come now. I hope this helped someone.
Matthew