Nick Gammon's Hex Converter Error
I can't reproduce that.

My apologies - I couldn't quite read the error message in the screen dump. What you got was:

Don't know end address for 0
Please add to table: end_addresses
Run-time error
World: smaug2
Immediate execution
[string "Immediate"]:96: Cannot continue
stack traceback:
        [C]: in function 'error'
        [string "Immediate"]:96: in function 'process'
        [string "Immediate"]:134: in main chunk


The relevant error is the first line. That file has code for address 0 - which is not part of the bootloader. It tries to detect bootloader addresses, and zero is not one of them. Looking at the start of the file I see this:

:1000000090C00000A9C00000A7C00000A5C000006B
:10001000A3C00000A1C000009FC000009DC0000060
:100020009BC0000099C0000097C0000048C40000B9
:100030000CC4000091C000008FC000008DC0000003
:100040008BC0000089C0000087C0000085C0000090
:1000500083C0000081C000007FC0000002C100001A
:100060007BC0000079C0000077C0000075C00000B0
:1000700073C0000071C000006FC000006DC00000C0
:100080006BC0000069C0000067C0000065C00000D0
:1000900063C0000061C000001201100102000008EE
:1000A0004123430001000102DC0109023E0002017C
:1000B00000C0320904000001020201000524000111
:1000C0001004240206052406000107058203080027
:1000D000FF09040100020A000000070504024000B5
:1000E00001070583024000010403090432034100B3
:1000F00072006400750069006E006F002000280027
:100100007700770077002E006100720064007500B0
:1001100069006E006F002E0063006300290000007C
:10012000000011241FBECFEFD2E0DEBFCDBF11E033
:10013000A0E0B1E0ECEAFFE002C005900D92A6312C


In particular the format is:

 :10 0000 00 90C00000A9C00000A7C00000A5C00000 6B
  ^  ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^
len  addr TT   data                          sumcheck


So this file includes code for the Atmega16U2 as well as the bootloader.

My sketch is not designed to program non-bootloaders (it is a bootloader programmer after all).



Scroll down that page for how to reprogram the Atmega16U2 chip.

The bootloader programmer sketch (as published) will put the bootloader onto the Atmega16U2. Then follow the instructions on that page, or on this page, below, for entering DFU mode and uploading the main part of the code (not the bootloader part).



Entering DFU mode

If you have just flashed the bootloader using the bootloader programmer sketch then it should enter DFU mode, visible because the pin 13 LED flashes rapidly.

If not, enter DFU mode by shorting together Reset and Ground briefly with a screwdriver or similar. They are the two left-most pins visible in the image above, nearest to the Reset button and below the hole on the board.

(Don't keep them shorted, just a brief touch should do it).



Once in DFU mode, you should see it appear as an Atmel USB device, if you type lsusb (on Linux):

$ lsusb
...
Bus 003 Device 092: ID 03eb:2fef Atmel Corp. 
...


A Uno which is not in USB mode might look like this:

$ lsusb
...
Bus 003 Device 090: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)
...


(or not appear at all if there is no firmware on it).

If you are using Ubuntu or similar you can obtain the DFU programmer as follows:

 sudo apt-get install dfu-programmer


You can obtain the code for the firmware from here:

http://gammon.com.au/Arduino/Arduino-atmega16u2-Uno-firmware-Rev3.hex

(RH-click and "save as" to put a copy on your hard disk).

Assuming you place that firmware in the current directory of your terminal window, you can now flash the code as follows:

sudo dfu-programmer atmega16u2 flash Arduino-atmega16u2-Uno-firmware-Rev3.hex


You should see a message like:

Validating...
4034 bytes used (32.83%)


Now you can unplug the USB cable, plug it back in, and the USB interface should be back to factory settings.

For other operating systems, such as Windows, you should be able to get a copy of the DFU programmer from:


https://github.com/dfu-programmer/dfu-programmer 
http://dfu-programmer.github.io/