The following boards use either an Atmega16U2 or Atmega8U2 chip as a USB-to-serial converter:
- Arduino UNO
- Arduino UNO Rev3
- Arduino Mega
- Arduino Mega2560 Rev3
- Arduino MegaADK Rev3
The converter chip firmware can be flashed with a computer by setting the board to DFU mode (Device Firmware Update).
Note
This article does not apply to the Uno WiFi Rev2, which uses a different chip with closed source firmware.
1. Get the firmware
The firmware is included in the Arduino AVR Boards platform. The platform comes installed with Arduino IDE by default, and can be found in the Arduino15 directory: Arduino15/packages/arduino/hardware/avr/<version>
. Alternatively, you can download and extract the repository from the GitHub page (Code > Download ZIP).
Within the platform directory, the usb to serial firmware is found in firmwares/atmegaxxu2/arduino-usbserial
. Select the firmware for your board, most likely one of the following:
Board | Firmware |
---|---|
Arduino Mega2560 Rev3 | Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex |
Arduino MegaADK Rev3 | Arduino-usbserial-atmega16u2-MegaADK-Rev3.hex |
Arduino UNO Rev3 | Arduino-usbserial-atmega16u2-Uno-Rev3.hex |
Arduino UNO | Arduino-usbserial-uno.hex |
Arduino Mega | Arduino-usbserial-mega.hex |
2. Program the chip with the firmware
Using dfu-programmer (macOS/Linux)
-
Download dfu-programmer from the GitHub repository or install the
dfu-programmer
package using a package manager like homebrew (macOS) or apt-get (Ubuntu). -
Connect the board to your computer.
-
Open Terminal.
-
Identify the chip model by trying the following commands:
dfu-programmer atmega16u2 read
dfu-programmer atmega8u2 read
Note
For older versions of dfu-programmer, replace
read
withdump
for the commands above.One of these command should read the memory successfully, and print it to terminal or indicate if it’s empty. Use the name from the successful command in the following steps.
-
Erase the memory.
dfu-programmer <atmegaxxu2> erase
-
Flash the firmware.
dfu-programmer <atmegaxxu2> flash <firmware path>
-
Disconnect and reconnect the board to your computer.
Using FLIP (Windows)
-
Connect the board to your computer.
-
Open Device Manager.
-
Expand the libusb-win32-devices category. If it is missing, follow these steps before proceeding.
-
Take a note of the device name, which should be either ATmega16U2 and ATmega8U2.
Next we’ll flash the drivers using FLIP.
-
Download and install FLIP.
-
Open FLIP.
Note
Opening the application may prompt a ‘Could not find a Java Virtual Machine’ error. In this case, install Java Runtime Environment with the Windows Online option.
-
Select the device name you identified earlier (ATmega16U2 or ATmega8U2).
-
Click the Cable button, select USB, then click Open.
-
In the menu, click Device > Select…
-
Click File > Load HEX File…
-
Select your driver
.hex
file and click ‘OK’. -
For Operational Flow, check check Erase, Program, and Verify (this is the default setting).
-
Click on the ‘Program Target Device Memory’ button.
-
The firmware will be flashed, which may happen very quickly. A “Programming done” message should be displayed in the bottom-left corner.
-
Disconnect and reconnect the board to your computer.
Install the libusb-win32 driver in Device Manager (Windows)
-
Look for an Unknown Device under ‘Other Devices’. Disconnect all devices except the board if multiple unknown devices are available.
-
Right-click and select Update driver.
-
Point to
C:\Program Files (x86)\Atmel\Flip 3.4.7
-
Click ‘Install’ and wait for the installation to complete.
-
The device should now be recognized, under ‘libusb-win32-devices’