Difference between revisions of "DIY USB adapter"

From GIMX
Jump to: navigation, search
(Update Arduino Builder link.)
(Remove the first-time instructions as they don't work. Add a specific section for avrdude.)
Line 76: Line 76:
 
===Cheap Arduino-compatible atmega32u4-based boards===
 
===Cheap Arduino-compatible atmega32u4-based boards===
  
====First-time flashing instructions====
+
====Using the Arduino Builder tool====
  
 
* Download the Arduino Leonardo drivers and save them into the same folder:
 
* Download the Arduino Leonardo drivers and save them into the same folder:
Line 82: Line 82:
 
** [https://github.com/arduino/Arduino/raw/master/build/windows/dist/drivers/arduino.inf arduino.inf]
 
** [https://github.com/arduino/Arduino/raw/master/build/windows/dist/drivers/arduino.inf arduino.inf]
 
* Right-click on the arduino.inf file and click on Install.
 
* Right-click on the arduino.inf file and click on Install.
* Connect the atmega32u4 board. A new COM port named "Arduino Leonardo (COMX)" should appear in the device manager.
+
* Make sure that the USB to UART board (e.g. CP2102) is connected and powered, and that the wiring with the atmega32u4 board is correct.
* Download the [http://sourceforge.net/projects/arduinodev/files/latest/download?source=files Arduino Builder tool] and extract the archive (using [http://www.7-zip.org/ 7zip]).
+
* Make sure that the atmega32u4 board is connected and powered.
 +
* Download the [http://sourceforge.net/projects/arduinodev/files/ArduinoBuilder/ArduinoBuilder-0.9.1.7z/download Arduino Builder tool] and extract the archive (using [http://www.7-zip.org/ 7zip]).
 
* Run ArduinoBuilder.exe.
 
* Run ArduinoBuilder.exe.
 
* Click on "Load Sketch / HEX", and select the desired atmega32u4.hex firmware.
 
* Click on "Load Sketch / HEX", and select the desired atmega32u4.hex firmware.
 
* Click on "Board Type" and select "Arduino Leonardo".
 
* Click on "Board Type" and select "Arduino Leonardo".
* In the Arduino Builder tool, click on the COM port that matches the "Arduino Leonardo (COMX)" COM port in the device manager.
+
* Click on the COM port that matches the "Silicon Labs CP210x ... (COMX)" COM port in the device manager (or whatever the name of your USB to UART board is). This is a trick to make the Arduino Builder tool look for a new COM port.
Upon success a "Uploading completed!" message should be displayed.<br /><br />
+
* The following message should appear: "Forcing reset using 1200bps open/close on COMX...".
If it does not work, manually perform the steps by calling avrdude and putting the com ports in use:
+
* Quickly unplug/replug the atmega32u4 board, or connect RST to GND twice.
avrdude.exe" -C"C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf" -v -n -patmega32u4 -cavr109 '''-PCOM3''' -b1200
+
* The atmega32u4 board should run the bootloader. The Arduino builder tool should find the Arduino Leonardo COM port and flash the firmware.
followed within a few seconds by:
+
Upon success a "Uploading completed!" message should be displayed.<br />
avrdude.exe" -C"C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf" -v -patmega32u4 -cavr109 '''-PCOM5''' -b57600 -D -Uflash:w:'''<PATH TO FIRMWARE>'''\atmega32u4.hex:i
 
  
In GNU/Linux, use the following command to run the bootloader:
+
====Using Avrdude====
avrdude -v -n -p atmega32u4 -c avr109 -P /dev/ttyACM0 -b 1200
 
And use the following command (within 8 seconds) to load the firmware:
 
avrdude -v -p atmega32u4 -c avr109 -P /dev/ttyACM0 -b 57600 -D -U flash:w:atmega32u4.hex:i
 
  
====Further flashing====
 
 
Because GIMX reprograms the USB interface, the COM port used in the First-time flashing instructions is no more available.<br />
 
Fortunately, there is a way to make the board run the bootloader:
 
 
* Make sure that the USB to UART board (e.g. CP2102) is connected and powered, and that the wiring with the atmega32u4 board is correct.
 
* Make sure that the USB to UART board (e.g. CP2102) is connected and powered, and that the wiring with the atmega32u4 board is correct.
 
* Make sure that the atmega32u4 board is connected and powered.
 
* Make sure that the atmega32u4 board is connected and powered.
* Run ArduinoBuilder.exe.
+
* Download the [http://sourceforge.net/projects/arduinodev/files/ArduinoBuilder/ArduinoBuilder-0.9.1.7z/download Arduino Builder tool] and extract the archive (using [http://www.7-zip.org/ 7zip]).
* Click on "Load Sketch / HEX", and select the desired atmega32u4.hex firmware.
+
* Press shift and right-click into the bin folder, and click on "Open command window here".
* Click on "Board Type" and select "Arduino Leonardo".
+
* Type the following text but don't press enter:
* In the Arduino Builder tool, click on the COM port that matches the "Silicon Labs CP210x ... (COMX)" COM port in the device manager (or whatever the name of your USB to UART board is). This is a trick to make the Arduino Builder tool look for a new COM port.
+
avrdude -v -n -p atmega32u4 -c avr109 -P COM7 -D -U flash:w:<path to atmega32u4.hex>:i
* The following message should appear: "Forcing reset using 1200bps open/close on COMX...".
+
* Make sure to replace "<path to atmega32u4.hex>" in the command line with the location of the firmware to load (for example: C:\Users\YourUserName\Downloads\firmwares-5.0\EMUPS4\atmega32u4.hex).
 +
* Move the cursor right after COM7.
 +
* Open the device manager, and unfold the COM port item.
 
* Quickly unplug/replug the atmega32u4 board, or connect RST to GND twice.
 
* Quickly unplug/replug the atmega32u4 board, or connect RST to GND twice.
* The atmega32u4 board should run the bootloader. The Arduino builder tool should find the Arduino Leonardo COM port and flash the firmware.
+
* The atmega32u4 board should run the bootloader. As soon as you see it appearing in the device manager, change the COM port number in the CMD window and press enter.
Upon success a "Uploading completed!" message should be displayed.<br /><br />
+
 
In GNU/Linux, use the following command to load the firmware (within 8 seconds after repluging):
+
In GNU/Linux, the avrdude command is:
 
  avrdude -v -p atmega32u4 -c avr109 -P /dev/ttyACM0 -b 57600 -D -U flash:w:atmega32u4.hex:i
 
  avrdude -v -p atmega32u4 -c avr109 -P /dev/ttyACM0 -b 57600 -D -U flash:w:atmega32u4.hex:i
 +
(make sure to adjust the port and the file)
  
 
===Other tools===
 
===Other tools===

Revision as of 20:53, 29 October 2015

Other languages:
English • ‎français

This page explains how to build a GIMX DIY USB adapter.

A much easier but less complete tutorial is also available: DIY USB Adapter for dummies.
A German translation of a previous version is also available on the forum: old German translation.

Warning: you are responsible for the hardware you buy, and anything right or wrong you do with this.

Required hardware parts

USB to serial TTL converter

Make sure it works at 500kbps and that it is 5V tolerant.

chip CP2102 FT232R PL2303 CH340 FT230X
5V tolerant yes (*) (*) (*) yes
500 kbps yes yes no no yes
compatible yes (*) no no yes

(*) depends on the board
Examples:

AVR USB development board

Make sure it is working at 5V and that is has a chip among the following: at90usb82, at90usb162, at90usb646, at90usb647, at90usb1286, at90usb1287, atmega16u2, atmega32u2, atmega16u4, atmega32u4
Examples:

Recommended setup

  • CP2102 converter from ebay (very low price, but sometimes low delivery)
  • Teensy 2.0 board (low price, good quality, and quick delivery).

Firmware loading

  • EMUJOYSTICKPS3: HID joystick emulation, with 16bit stick axes, for PS3
  • EMUPS3: Sixaxis emulation, for PS3
  • EMU360: 360 pad emulation, for Xbox 360
  • EMUPS4: Hori Pad FPS Plus emulation, for PS4 (with touchpad support)
  • EMUXONE: Xbox One pad emulation, for Xbox One
  • EMUG29PS4: Logitech G29 gaming wheel emulation, for PS4, with force feedback support
  • EMUG27PS3: Logitech G27 gaming wheel emulation, for PS3, with force feedback support
  • EMUGTFPS2: Logitech GT Force emulation, for PS2, with force feedback support
  • EMUDFPS2: Logitech Driving Force emulation, for PS2, with force feedback support
  • EMUDFPPS2: Logitech Driving Force Pro emulation, for PS2, with force feedback support
  • EMUG27PC: Logitech G27 gaming wheel emulation, for PC, force feedback support

Teensy boards

Teensy boards can be easily flashed using the Teensy Loader.
It is probably the easier to use flashing tool, but it is only compatible with genuine teensy boards.

Cheap Arduino-compatible atmega32u4-based boards

Using the Arduino Builder tool

  • Download the Arduino Leonardo drivers and save them into the same folder:
  • Right-click on the arduino.inf file and click on Install.
  • Make sure that the USB to UART board (e.g. CP2102) is connected and powered, and that the wiring with the atmega32u4 board is correct.
  • Make sure that the atmega32u4 board is connected and powered.
  • Download the Arduino Builder tool and extract the archive (using 7zip).
  • Run ArduinoBuilder.exe.
  • Click on "Load Sketch / HEX", and select the desired atmega32u4.hex firmware.
  • Click on "Board Type" and select "Arduino Leonardo".
  • Click on the COM port that matches the "Silicon Labs CP210x ... (COMX)" COM port in the device manager (or whatever the name of your USB to UART board is). This is a trick to make the Arduino Builder tool look for a new COM port.
  • The following message should appear: "Forcing reset using 1200bps open/close on COMX...".
  • Quickly unplug/replug the atmega32u4 board, or connect RST to GND twice.
  • The atmega32u4 board should run the bootloader. The Arduino builder tool should find the Arduino Leonardo COM port and flash the firmware.

Upon success a "Uploading completed!" message should be displayed.

Using Avrdude

  • Make sure that the USB to UART board (e.g. CP2102) is connected and powered, and that the wiring with the atmega32u4 board is correct.
  • Make sure that the atmega32u4 board is connected and powered.
  • Download the Arduino Builder tool and extract the archive (using 7zip).
  • Press shift and right-click into the bin folder, and click on "Open command window here".
  • Type the following text but don't press enter:
avrdude -v -n -p atmega32u4 -c avr109 -P COM7 -D -U flash:w:<path to atmega32u4.hex>:i
  • Make sure to replace "<path to atmega32u4.hex>" in the command line with the location of the firmware to load (for example: C:\Users\YourUserName\Downloads\firmwares-5.0\EMUPS4\atmega32u4.hex).
  • Move the cursor right after COM7.
  • Open the device manager, and unfold the COM port item.
  • Quickly unplug/replug the atmega32u4 board, or connect RST to GND twice.
  • The atmega32u4 board should run the bootloader. As soon as you see it appearing in the device manager, change the COM port number in the CMD window and press enter.

In GNU/Linux, the avrdude command is:

avrdude -v -p atmega32u4 -c avr109 -P /dev/ttyACM0 -b 57600 -D -U flash:w:atmega32u4.hex:i

(make sure to adjust the port and the file)

Other tools

There are a few other tools that can be used to load the hex file:

  • avrdude: comes with the Arduino IDE, and with the Arduino Builder tool
  • Flip utility from Atmel (not compatible with genuine teensy boards and with Arduino-compatible atmega32u4-based boards)
  • dfu-programmer command-line tool (not compatible with genuine teensy boards and with Arduino-compatible atmega32u4-based boards)

dfu-programmer example:

   sudo dfu-programmer at90usb162 erase
   sudo dfu-programmer at90usb162 flash at90usb162.hex
   sudo dfu-programmer at90usb162 reset

Wiring

The only thing you have to do is to connect the following pins:

USB dev board USB to UART board
GND GND
RX TX / TXO / RXD
TX RX / RXI / TXD

With a Teensy 2.0 as a USB dev board:

Teensy 2.0 USB to UART board
GND GND
D2 TX / TXO / RXD
D3 RX / RXI / TXD

If you use the arduino on-board USB to serial converter, Rx and Tx are inverted, i.e. Rx = TX▶ and Tx = RX◀

The example below shows how to connect a CP2102 converter (left) to a Teensy 2.0 board (right):

It's possible to solder wires or to use jumper wires (these are generally provided with USB to serial TTL boards) in case your AVR USB board has header pins:

Examples:

  • Bumble-b and FT232RL wired on a breadboard:
  • Teensy++ and CP2102 wired on a breadboard:
  • Teensy 2.0 and CP2102 soldered:

Connection

If it's not already done, install GIMX.
Connect the USB to UART converter to your PC, and connect the usb dev board to your console.
Turn the console on (the ps/guide buttons are not working at this point).
The console should detect a controller (if you add another controller, it should be detected as controller #2).
Start gimx-launcher:
TODO: update screenshot

In Ubuntu/Linux, the USB to UART converter should be detected as "ttyUSBX" (with 'X' a number).
In Windows, it should be detected as "COMX" (with 'X' a number). Check the device manager to select the right one.

Now that your adapter is ready you can follow the instructions on the Quick Start page.