User Tools

Site Tools


product:usb2ax:firmware_update

This is an old revision of the document!


USB2AX: Firmware update

The software running in the USB2AX can be updated or changed, to fix bugs, to add new functionalities or to tailor its behavior to your application.

Getting the firmware

The latest official firmware binary can be found on the firmware page.

Updating the firmware

You have a new firmware and you want to put it in the USB2AX, Great! There are three ways to do it:

  • Automatic - for normal firmware update, with minimal user action.
  • Recovery - for when something went wrong with the Automatic mode, or for custom firmwares. Requires actions on the board.
  • ICSP - for geeks.

Automatic

For most people, the Automatic procedure will work nicely. It is supported by the firmwares made by Xevelabs, and relied upon by the automatic firmware update tool.

This update method is supported both for Windows and Linux.

Windows version
Tested on Win7 64bits.
Prerequisites:

  • Installing Atmel FLIP
  • Getting the USB2AX_Update application

FIXME

Linux Version
Tested on Ubuntu 10.10 32bits.

1) Install dfu-programmer >=0.5.4

Debian Squeeze only has 0.5.1, so you might have to build it from sources:

apt-get install libusb-dev
#download and uncompress dfu-programmer
cd dfu-programmer-<version>
./configure
make

The binary is in ./src

Maybe add the user to the uucp group so you don't have to run dfu-programmer as root… but it did not work for me.

2) Run the bootloader using the python script. FIXME

3) Run the programmer :

./dfu-programmer atmega32u2 erase
./dfu-programmer atmega32u2 flash USB2AX.hex
#/!\: the .hex needs to have UNIX-style end of lines (\n, LF), and will not work with DOS end of lines (\r\n CRLF)!
./dfu-programmer atmega32u2 start
More info for power users
  • Running the bootloader on the USB2AX is as simple as sending on its serial port the following ascii bytes: 0xff 0xff 0xfd 0x02 0x08 0xf8

Here is an example in Python, the latest revision of which you can be found in the git repository (usb2ax_run_bootload.py FIXME ):

import serial
bootload_cmd = '\xff\xff\xfd\x02\x08\xf8'
ser = serial.Serial("COM7")
ser.write(bootload_cmd)
ser.close()
  • When the command is received, the USB2AX removes itself from the USB bus immediately and waits two seconds before re-enumerating.
  • The bootloader is the factory-programmed one made by Atmel. On Windows, the USB2AX running the bootloader will appear as ATmega32u2 in the Atmel Devices section of the Device Manager.

Recovery

The Recovery mode is mostly there as a fail-safe: if something goes horribly wrong with the Automatic way or if you want to use a third party firmware, you can always get back to a working state without an additional programmer.

Doing that is a two step process: running the bootloader, then uploading the firmware into the flash memory.

Running the bootloader manually

To run the bootloader manually, you need to get access to the pads on the bottom of the board. Either remove completely the clear protective plastic or just cut out the part that exposes the 3 pads on the side of the board.

The 3 pads are labeled GND, HWB and RST. The goal is to be able to connect GND with the two others, then release RST, then release HWB more than half a second later. There are various ways to do it, here are some suggestions.

Please be aware that attempting these is done at your own risks!

  • with two buttons (requires soldering)

Solder a button between GND and HWB, and the other one between GND and RST. Press the two buttons, then release the one that goes to RST, and a second later the other one.

  • with a button and a capacitor (requires soldering)

Solder a small capacitor (in the uF range) between GND and HWB, and a button between GND and RST. When you press the button for a second or two, this will discharge the capacitor, and when you release the button, it will keep the voltage on HWB low enough for long enough for the bootloader to run.

  • with tweezers or a cable

Take a pair of metallic fine tweezers or a cable with stripped ends, touch one end on the GND pad and the other one successively on HWB (leave it for a second) and RST (just touch it). You will get better results if you switch from one to the other very quickly. If you are lucky, the stray capacitance of the HWB trace maintains it low enough for long enough for the bootloader to run.

Uploading the firmware

FIXME

ICSP

The ICSP method allows you to change the bootloader or do away with it to use the remaining 4k of FLASH, but requires an ICSP programmer and some soldering.

To connect the ICSP to the board, the necessary pads are broken out on the bottom. You will need to remove the clear protection around the board, then connect:

ICSP pin number ↔ pin functionality ↔ place to get it on the USB2AX

  1. ↔ MISO ↔ PB3 pad
  2. ↔ Target VCC ↔ USB pin under the point of the version number “v3.1a”
  3. ↔ SCLK ↔ PB1 pad
  4. ↔ MOSI ↔ PB2 pad
  5. ↔ RST ↔ RST pad
  6. ↔ GND ↔ one of the GND pads

The rest is up to you, from there it's like programming any other AVR MCU. Have fun!

Customizing the firmware

The sources of the firmware are available in the Git Repository of the project.

Read the README file to get an idea of what is going on, read the code, and start hacking away!

product/usb2ax/firmware_update.1390062763.txt.gz · Last modified: 2014/01/18 17:32 by xevel