How to MAKE a new ATMega16u2 .hex file?

Hi,

I would like to generate the usb2serial code on the UNO 16u2, for myself . Before jumping into the dark, I would like to take small steps. To this end, I have pulled the code from my UNO Rev3 using:

avrdude -p atmega16u2 -c usbasp -U flash:r:/tmp/flash-dump.hex:i

and compared it against the the distribution file:

/usr/share/arduino-1.6.5/hardware/arduino/avr/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex.

Which matches - an encouraging first step, I thought! Next, I tried compiling the provided code at:

/usr/share/arduino-1.6.5/hardware/arduino/avr/firmwares/atmegaxxu2/arduino-usbserial/ and /usr/share/arduino-1.6.5/hardware/arduino/avr/firmwares/atmegaxxu2/arduino-usbdfu/.

Again, that seems to compile without any errors.

However, and this is my question, the compiled binarys do not match the distribution .hex files.

Can you offer an suggestions on how I generate for myself the exact same code that is on my UNO before I start making changes?

Best regards, Martin

Do your compiled binaries work?

The production .hex used may be build with an old version fo the compiler.