Programming New ATMEGA 16U2 Chip

I'm working on a derivative board based on Arduino Uno r3. I made a prototype, and used the same components as the Arduino Uno R3 for that part of the board.

However, now I am faced with the fact that my board isn't detected by my computer when connected by USB, since, I am assuming, the firmware on the ATMega 16U2 chip is not the Arduino firmware. Is there anyway to flash it with the firmware made available by Arduino?

I have tried the following:

ISP 6 pin header connected to a AVRISP mkII.

Using winavr, I am entering: avrdude.exe -c avrispmkII -p at90usb162 -F -U flash:w:path\to\file.hex

But I get the following error: avrdude.exe: stk500_2_ReceiveMessage(): timeout

If I look in Device Manager on Windows 7, I can see:

  • AVRISP mkII under LibUSB-Win32 Devices
  • ATmega16u2 DFU under Other Devices with a yellow exclamation point telling me the driver is not installed

Any ideas?

Brian

I have no experience with this but isn't at90usb162 not sound like atmega16u2? I know the atmega328 goes as m328p, isn't the at90usb a whole different thing?

ATmega16u2 DFU under Other Devices with a yellow exclamation point telling me the driver is not installed

This indicates the ATmega16u2 is in DFU programming mode and you can use Atmel's FLIP utility to upload new firmware to the 16u2. The FLIP utility will have the necessary drivers for the ATmega16u2 DFU mode.

You can follow the steps at the following link. The steps should be the same as programming the 8u2. http://arduino.cc/en/Hacking/DFUProgramming8U2

I had the similar issue trying to use Darran's HID usb keyboard 0.3 stuff from http://www.smartinteractionlab.com/lufa-example-turning-your-arduino-into-a-keyb:

I have Arduino Uno Rev.3 I'm using the Pololu USB AVR ISP programmer. Arduino IDE 1.0 for Windows Windows 7 Ultimate 64 bit

I solved the problem by making sure that the UNO Rev 3 was connected to a USB port on the PC via its USB cable along with the having the Pololu usb cable being connected to the PC and the at90USB162 ISCP port on the UNO Rev 3 at the same time. First, I connected the UNO Rev 3 ,started the Arduino 1.0 IDE and imported and uploaded the usb-keyboard-0.3.pde example program into the UNO Rev 3.

I connected the free end of the Pololu six pin ribbon connector to the at90usb162 ICSP connector on the UNO Rev 3 with the red stripe aligned just like the web site showing the MKII Using a USB cable with a Micro B connector, connect it to the Pololu Micro B port and the other end connect to a PC USB port.The Pololu installed as COM17 on my PC. Followed Pololu instructions on their web site to add the programmer to the Arduino 1.0 IDE environment.The programmer type is avrispv2 , STK500 protocol

Opening a Windows command console window,

I changed directory to my C:\Users\gknight\Documents\arduino-1.0-windows\arduino-1.0\hardware\tools\avr folder I copied Darran's arduino-keyboard-0.3.hex into my C:\Users\gknight\Documents\arduino-1.0-windows\arduino-1.0\hardware\tools\avr folder. I copied the original Uno Rev.3 at90usb162 firmware from arduino\firmwares\arduino-usbserial\ folder ,Arduino-usbserial-atmega16u2-Uno-Rev3.hex, into my C:\Users\gknight\Documents\arduino-1.0-windows\arduino-1.0\hardware\tools\avr folder to switch the Uno Rev3 back to usb IDE mode.

From the website, I modified the avrdude command for at90usb162 To use the 0.3 usb firmware use:

bin\avrdude -F -p at90usb162 -C etc\avrdude.conf -P COM17 -c avrispv2 -U flash:w:arduino-keyboard-0.3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e9489 avrdude: Expected signature for AT90USB162 is 1E 94 82 avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file "arduino-keyboard-0.3.hex" avrdude: input file arduino-keyboard-0.3.hex auto detected as Intel Hex avrdude: writing flash (4022 bytes):

Writing | ################################################## | 100% 1.65s

avrdude: 4022 bytes of flash written avrdude: verifying flash memory against arduino-keyboard-0.3.hex: avrdude: load data flash data from input file arduino-keyboard-0.3.hex: avrdude: input file arduino-keyboard-0.3.hex auto detected as Intel Hex avrdude: input file arduino-keyboard-0.3.hex contains 4022 bytes avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.22s

avrdude: verifying ... avrdude: 4022 bytes of flash verified avrdude: reading input file "0xFF" avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written avrdude: verifying lfuse memory against 0xFF: avrdude: load data lfuse data from input file 0xFF: avrdude: input file 0xFF contains 1 bytes avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ... avrdude: 1 bytes of lfuse verified avrdude: reading input file "0xD9" avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory against 0xD9: avrdude: load data hfuse data from input file 0xD9: avrdude: input file 0xD9 contains 1 bytes avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ... avrdude: 1 bytes of hfuse verified avrdude: reading input file "0xF4" avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of efuse written avrdude: verifying efuse memory against 0xF4: avrdude: load data efuse data from input file 0xF4: avrdude: input file 0xF4 contains 1 bytes avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ... avrdude: 1 bytes of efuse verified avrdude: reading input file "0x0F" avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written avrdude: verifying lock memory against 0x0F: avrdude: load data lock data from input file 0x0F: avrdude: input file 0x0F contains 1 bytes avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ... avrdude: 1 bytes of lock verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

"Hello world" started printing in the command console window.

To go back to IDE mode I disconnected the UNO Rev 3 USB cable long enough to stop the hello world printing. I pasted the following command in the window in preparation

bin\avrdude -F -p at90usb162 -C etc\avrdude.conf -P COM17 -c avrispv2 -U flash:w:Arduino-usbserial-atmega16u2-Uno-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -Uefuse:w:0xF4:m -U lock:w:0x0F:m I re-connected the UNO Rev 3 USB cable and pressed enter:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e9489 avrdude: Expected signature for AT90USB162 is 1E 94 82 avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file "Arduino-usbserial-atmega16u2-Uno-Rev3.hex" avrdude: input file Arduino-usbserial-atmega16u2-Uno-Rev3.hex auto detected as I ntel Hex avrdude: writing flash (4034 bytes):

Writing | ################################################## | 100% 1.35s

avrdude: 4034 bytes of flash written avrdude: verifying flash memory against Arduino-usbserial-atmega16u2-Uno-Rev3.he x: avrdude: load data flash data from input file Arduino-usbserial-atmega16u2-Uno-R ev3.hex: avrdude: input file Arduino-usbserial-atmega16u2-Uno-Rev3.hex auto detected as I ntel Hex avrdude: input file Arduino-usbserial-atmega16u2-Uno-Rev3.hex contains 4034 byte s avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.16s

avrdude: verifying ... avrdude: 4034 bytes of flash verified avrdude: reading input file "0xFF" avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written avrdude: verifying lfuse memory against 0xFF: avrdude: load data lfuse data from input file 0xFF: avrdude: input file 0xFF contains 1 bytes avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ... avrdude: 1 bytes of lfuse verified avrdude: reading input file "0xD9" avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory against 0xD9: avrdude: load data hfuse data from input file 0xD9: avrdude: input file 0xD9 contains 1 bytes avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ... avrdude: 1 bytes of hfuse verified .....etc

and I was back in IDE mode. In the beginning, I could have edited the "hello world stuff" out of the pde to prevent the awkward connect-reconnect to go back to IDE mode.

Ah yeah, regarding the last post, I noticed when flashing normal ATmega328's et al using my Olimex AVR-ISP500, the Olimex does NOT power the board. I have to bring +5V from another source or plug up a USB cable to the board or else the programmer won't find the chip.

I believe he had that covered in this paragraph;

I solved the problem by making sure that the UNO Rev 3 was connected to a USB port on the PC via its USB cable along with the having the Pololu usb cable being connected to the PC and the at90USB162 ISCP port on the UNO Rev 3 at the same time. First, I connected the UNO Rev 3 ,started the Arduino 1.0 IDE and imported and uploaded the usb-keyboard-0.3.pde example program into the UNO Rev 3.