Tutorial - How to change firmware on 8u2

I've just received my arduino uno.
I try to upload a new firmware on the 8u2
I share here the steps I follow.
I use Windows.

I use the following sources:


I need those software:- Arduino 020 : http://arduino.cc/en/Main/Software

After install, copy folder arduino-0020\hardware\arduino\firmwares\arduino-usbserial on *LUFA_100807\Projects*

There are two modifications to do:
Solder 2 jumpers: one on the HWB line and one between pin 5 & 6 on ISP1 for RESET

How to put the Uno on DFU mode:
4. put the 8U2 into USB DFU mode:
4.a. assert and hold the 8U2's RESET line
4.b. assert and hold the 8U2's HWB line
4.c. release the 8U2's RESET line
4.d. release the 8U2's HWB line
The device became USB DFU

Hardware, drivers installation:

  • Arduino Uno: drivers are on arduino-0020\drivers
  • Arduino Uno DFU: drivers are on Atmel\Flip 3.4.2\usb

Verify the board
Upload blink program on your uno to check that the board is working fine.

Compile firmware

  • To be sure that's working i change a line in Descriptors.c:
  • UnicodeString = L"Arduino Uno"* by UnicodeString = L"ArduINo UNO"
  • Open WinAvr/Programmer Notepad
  • Load makefile
  • I modify LUFA_PATH => LUFA_PATH = ../../
  • You should have to modify ARDUINO_MODEL_PID if you use MEGA
  • Do Tools[ch8594]Make clean
  • Do Tools[ch8594]Make all

Upload Arduino-usbserial.hex on the board

  • make sure the board is in DFU mode
  • Start Flip
  • Select the device AT90USB82 (not the ATmega8u2!!)
  • Open usb communication
  • Select Load Hex file
  • Program target device memory

Unplug the board and re-plug
The Name of the board should have changed : it becomes “ArduINo UNO”

Verify the board
Upload blink program on your uno to check that the board is still working fine.

That's all!

good work. :smiley:

This is the next step : how to make a joytick emulator with the arduino-uno.

First step
Be sure to be able to upload the initial firwmare arduino-serial: we need this firmware to upload the Atmega328.

How it works
The Atmega328 sends to 8u2 a byte on serial communication that represents the state of the joystick.

Point of attention
It's important to load first the atmega328 program and then the 8u2 firmware.
Once the firmware of 8u2 is upload with joystick program, atmega328 can't be loaded.
In order to modify atmega328 program, the original firmware of 8u2 need to be re-loaded.

Atmega328 program

Program test for arduino uno
8u2 firmware-> Usb Joystick
6 oct 2010

void setup() 

void loop() 

void send_byte(boolean JOY_UP, boolean JOY_DOWN,
                boolean JOY_LEFT, boolean JOY_RIGHT,
                boolean JOY_PRESS, boolean BUTTONS_BUTTON1)
  byte byte_to_send;// use a 'byte' not a 'int'-> a int will send 3 bytes via serial
  byte_to_send= JOY_UP*32 + JOY_DOWN *16  +
                JOY_LEFT*8 + JOY_RIGHT*4 +
                JOY_PRESS*2 +  BUTTONS_BUTTON1*1;
  delay(1000);//delay 1s before send another byte

8u2 program

  • copy the folder LUFA_100807\Demos\Device\ClassDriver\Joystick to LUFA_100807\Projects\Arduino-Joystick
  • copy the following files from *arduino-0021\hardware\arduino\firmwares\arduino-usbserial* to LUFA_100807\Projects\Arduino-Joystick
  • folder 'Lib'
  • folder 'Board'
  • file makefile

Changes to make
In makefile
Set TARGET = Joystick
In Joystick.h
Delete #include <LUFA/Drivers/Board/Joystick.h>
Delete #include <LUFA/Drivers/Board/Buttons.h>
In Joystick.c
Add this on the begining:

#include <LUFA/Drivers/Peripheral/Serial.c>
uint8_t temp;
const uint8_t JOY_UP= 0b100000;
const uint8_t JOY_DOWN = 0b010000;
const uint8_t JOY_LEFT= 0b001000;
const uint8_t JOY_RIGHT= 0b000100;
const uint8_t JOY_PRESS= 0b000010;
const uint8_t BUTTONS_BUTTON1= 0b000001;

Add this in void SetupHardware(void)
 Serial_Init(9600, false);

I delete clock_prescale_set(clock_div_1); because this line can't compile. I don't know if it is usefull ??
I also delete

  • Buttons_Init();*
    I add this in for( ;;; )
while (Serial_IsCharReceived())
            Serial_TxByte(temp);// Sendback the same byte juste for information

And finally replace the content of CALLBACK_HID_Device_CreateHIDReport by that

USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;

uint8_t JoyStatus_LCL    =temp; //Joystick_GetStatus();

      if (JoyStatus_LCL & JOY_UP)
             JoystickReport->Y = -100;
        else if (JoyStatus_LCL & JOY_DOWN)
              JoystickReport->Y =  100;

       if (JoyStatus_LCL & JOY_LEFT)
              JoystickReport->X = -100;
       else if (JoyStatus_LCL & JOY_RIGHT)
              JoystickReport->X =  100;

       if (JoyStatus_LCL & JOY_PRESS)
              JoystickReport->Button  = (1 << 1);

       if (JoyStatus_LCL & BUTTONS_BUTTON1)
               JoystickReport->Button |= (1 << 0);

      *ReportSize = sizeof(USB_JoystickReport_Data_t);
        return false;

Then compile and upload this program on 8u2

You can verify that it is working by unplug and replug the usb connection.

The joystick is visible in configuration pannel / gamepad.

Comment : I have had some difficulties with Flip : I often had the error 'Address is out of range'. I don't really now why?? Does someone have an idea?

Thanks ant.b. I was supposed to write a tutorial like this one but didn't get to it yet. I linked here from the Arduino Uno page (under the programming section).

I had trouble with the arduino-0021 version of arduino-usbserial. After building and programming it onto the 8U2 the Windows would ask to install drivers for the new device. After pointing the installation to the arduino drivers directory windows would report a failure in driver installation. The Arduino IDE would not recognize the UNO after that... :-/ I compiled the 0020 version and my UNO is back in action... :sunglasses:

I noticed in the 0021 release mentioned tweaks to PID/VID values... wondering if that has something to do with it. I don't have time to look at it tonight it's 12:50am :stuck_out_tongue:

Great tutorial ant.b! Can't wait to try the joystick version tomorrow.

Update: In the arduino-0021 version of arduino-usbserial the Descriptor.c file is using VID = 0x03EB (Atmel) and PID = 0x204B (LUFA USBtoSerial demo). The Arduino UNO.inf is looking for VID=0x2341 and PID=0x0001 which is reflected in arduino-0020...

I see in the 0021 release notes indicate "Modifying VID / PID combination in 8U2 firmwares" but was this the intent?

According to the USB folks, we're not really allowed to share our VID / PIDs with other organizations. So the firmware was modified to use other ones. Probably we should create a different version of the .inf file that uses the other VID/PID pair. The intent is that any VID/PID pair should work with the IDE, but that the Arduino ones should only be used with the official Arduino hardware.

Awesome work! I wasn't looking forward to working out all this stuff on my own.

The only problem I've encountered is loading the DFU drivers in windows 7. It seems they aren't signed so win7 refuses to allow access to the device via Flip. I had to install it on an XP machine before I could write my newly compiled .hex to the 8U2.

There are ways of making win7 load unsigned drivers in test mode, but this is cumbersome.

You can also use an ISP to update the 8U2 firmware, if you have one.

It would be great if the software on the ATmega8u2 had various usb "personalities" included, selectable by software on the 328.

You could send some special string to 328 to swithch it from usb-serial mode to usb-keyboard mode or usb-joystick mode.

Then, there will be no need to upload new software to the 8u2.

When power off it could return to the default usb-serial mode.

Here's a way to get the Uno into DFU mode without any soldering. Put two wires into GND pins on either side of the board. Then put the other ends of the wires on the board as follows:

The sequence is, hold the first wire on the top left 8u2 ICSP pad, then touch the second wire against the left side of the capacitor below the RX LED. Then remove both wires. It's slightly different to the sequence in the instructions but it seems to work.

Be careful with the second wire as the capacitor is quite near a 5v track. You can try using a low-value resistor instead of a wire if you are worried about blowing up your board.

To get back to normal mode, hold wire 1 in place as above, press the reset button, then remove wire 1. Or just unplug the USB cable and plug it back in.

I doesen'T have an Arduino Uno only a nano does someone know how I can use this code on an Arduino nano 3.0

it would be realy great if anyone has an answer for me ;D

does someone know how I can use this code on an Arduino nano 3.0

Can you post a picture of your nano with a ATMega8U2 chip on it?

Found a solution to my problem:


These drivers were signed by some generous avrfreak, and work with the Uno under Win7 64b. Happy days!

Great! I want to try this now.

Thanks so much for this! Got an Uno for the purpose of making a funky arduino accelerometerfmouse and was fretting about the lack of info on how to go about the USB HID part til I found this post. Can't wait to get choppin with it!

I've been lurking around in this thread for some time now.
I think I've wrapped my head around the general idea.
How hard would it be to add another 2 axes to the example joystick?
(axes A,B,C,D instead of only X-Y)

As far as I can see, it requires some tinkering in the Descriptors.c file.
Could any other "HID Usages" like Vx or Vbrx serve as my extra axes?

How hard would it be to add another 2 axes to the example joystick?

Surely you only have X,Y and Z?

A Playstation Dualshock styled controller has 2 thumbsticks.
So four usable axes.
I would just like to pipe 4 different sensor values into Unity using no intermediate software whatsoever, so that's why.

A Playstation Dualshock styled controller has 2 thumbsticks.
So four usable axes.
I would just like to pipe 4 different sensor values into Unity using no intermediate software whatsoever, so that's why.

Ahh I see.