How to get USB-Serial hex back to Arduino UNO Rev3 / solved

Hello!

This is a bit embracing but I've managed to get my Arduino stuck thinking it is a HID device.

I created a small test program on the arduino and then used Atmel's Flip software to upload the HID.hex file from this project http://hunt.net.nz/users/darran/weblog/cca39/
Arduino successfully thinks it is a mouse now and follows the program that was uploaded prior to the hex file swap.

However now I need to make some changes to the program but I can't get back to the usb-serial.
Getting the UNO Rev3 hex file from https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares does not help. Flip says that the Hex file is not correctly formatted :confused:

Can anyone advise what I'm doing wrong?

Getting the UNO Rev3 hex file from...

What you mean by "getting the hex file"? Did you accidentally save the HTML from the webpage rather than the HEX file?

Try this...

• Go here...
https://github.com/arduino/ArduinoCore-avr/blob/master/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex
https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex

• On the right side, about 1/3 the way down, locate the Raw button

• Right-click Raw

• Click Save Link As

• Save the file to a convenient location

• Retry flipping

Seems that I was indeed saving an html version of the hex.

It is better but still not there. Now when opening the HEX I get an error "Address is out of range."

In Flip, the device is set to ATmega16U2 (rev3 UNO)

Now when opening the HEX I get an error "Address is out of range."

Someone else will have to help with that error. It is outside of my experience.

Still thanks for the quick response!
Got me one step closer to getting my Arduino working again.

Update: I toyed around with the buffer settings and now managed to get it working. For some reason it didn't adjust the Flash buffer range before.

It seems as if the HEX gets uploaded nicely. But after replugging the arduino it is still acting as an HID device.

Try this:

I just put that file (Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex) onto an SD card an verified it against my Uno USB chip, without errors. So the file is OK.

You should be able to follow the wiring on that page (and get the SD card, heh) and re-flash the USB chip.

Atmega hex file uploader.
Written by Nick Gammon.
Version 1.9
Reading SD card ...

HEX files in root directory:

FOO.HEX       :       2915 bytes.
ARDUIN~1.HEX  :      20907 bytes.  Created: 2012-05-17 16:16:06.  Modified: 2012-05-17 16:16:06


--------- Starting ---------

Attempting to enter programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x94 0x89 
Processor = ATmega16U2
Flash memory size = 16384 bytes.
LFuse = 0xEF 
HFuse = 0xD9 
EFuse = 0xF4 
Lock byte = 0xCF 
Clock calibration = 0x8B 
Actions:
 [E] erase flash
 [F] modify fuses
 [L] list directory
 [R] read from flash (save to disk)
 [V] verify flash (compare to disk)
 [W] write to flash (read from disk)
Enter action:

V

Choose disk file [  ] ...

ARDUIN~1.HEX

Processing file: ARDUIN~1.HEX
Checking file ...

############
Lowest address  = 0x0
Highest address = 0x3D33
Bytes to write  = 7414
No bootloader.
Suggest making high fuse = 0xD9 
Attempting to enter programming mode ...
Entered programming mode OK.
Processing file: ARDUIN~1.HEX
Verifying flash ...

##########################################################
No errors found.

TT:
It seems as if the HEX gets uploaded nicely. But after replugging the arduino it is still acting as an HID device.

Try rebooting the PC. I've heard some crazy tales about Windows and caching USB info.

Or, uninstalling the device driver and reinstalling.

Ah, Windows!

Try rebooting the PC. I've heard some crazy tales about Windows and caching USB info.

Ah, Windows!

Hehe, good advice actually. "Have you tried turning it on and off again"

Tried the reboot but still no change. I also have a mac nearby and its still acting as a mouse there aswell...

Unfortunately I don't have an SD card module and they are not that freely available here :frowning: But the deadline for this project is within a few days so I'll have to find some other method.. I do have another UNO at home. Might be worth trying if i can flash the bootloader that way.

But if possible I'd prefer to get it working just using the Flip software. Can't be that hard? :slight_smile:

Well two things I noticed ...

  • The signature reported in your image doesn't agree with mine (0x1E 0x94 0x89)
  • The file size (either on disk or as bytes to be changed) doesn't agree with mine (File: 20907 bytes ... Bytes to write = 7414)

So something fishy is going on.

The file I used was:

https://raw.github.com/arduino/Arduino/master/hardware/arduino/firmwares/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex

MD5 (Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex) = 374845d004d03c6ca0535bb4b6f19235

Darn, getting that Address is out of range error again..

Don't use that Atmel software. Use something crafted by the Arduino community. :wink:

Show us your MD5 sum of the file you have.

Places to grab MD5:

http://etree.org/cgi-bin/counter.cgi/software/md5sum.exe eb574b236133e60c989c6f472f07827b
http://www.fourmilab.ch/md5/md5.zip b14e189e965e5ed523282d3c8ee6c945

I got:

C:\Documents and Settings\Owner\Desktop>md5sum Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex
374845d004d03c6ca0535bb4b6f19235 *Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex

Same as before:

MD5 (Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex) = 374845d004d03c6ca0535bb4b6f19235

I get 8642f9f240d1d0fdeb1d2f6fb0185452 for mine. Compared to your's which is 21kb, the one I was using so far is a whopping 34kb in size..

And for the one you linked, I get the same MD5 as you do

374845d004d03c6ca0535bb4b6f19235

You don't have the right file. Edit the file. It should have this in it:

:1000000090C00000A9C00000A7C00000A5C000006B
:10001000A3C00000A1C000009FC000009DC0000060
:100020009BC0000099C0000097C0000048C40000B9
:100030000CC4000091C000008FC000008DC0000003
:100040008BC0000089C0000087C0000085C0000090
:1000500083C0000081C000007FC0000002C100001A
:100060007BC0000079C0000077C0000075C00000B0
:1000700073C0000071C000006FC000006DC00000C0
:100080006BC0000069C0000067C0000065C00000D0
...
:0A3CF0000FBE01960895F894FFCF6F
:103CFA0001021E948920DCFB120110010000002041
:103D0A00EB03EF2F00000001000109021B00010173
:103D1A000080320904000000FE01020009210300AC
:0A3D2A0000000C000104030904006E
:0400000300003000C9
:00000001FF

It should be 20907 bytes. If it isn't you don't have it.