Skip to content

Flashing Linux (Unix)

Iceman edited this page Feb 17, 2019 · 11 revisions

How to flash a new firmware on the Chameleon on a linux-based OS? (Some Starting Points)

Scope

Note that all of the sections of this WIKI except for the first on UDEV-specific rules are applicable more generally to flashing the Chameleon bootloader on Unix systems. We prefer the utility dfu-programmer in place of the suggested avr-dude from the RevG docs for a couple of reasons. First it is open source, freely available on GitHub and easy to compile. Secondly, the repository which provides the necessary flip2 support for avr-dude is not recently maintained nor compatible with recent versions of Ubuntu Linux. The dfu-programmer utility should suffice to get the bootloader code installed on both RevE (rebooted) and RevG devices.

Configure UDEV to handle the USB devices

Following from this #64 post on the RevG board issues forum, we need to configure the UDEV rules which most modern Linux boxes are going to be using to plug-and-play with these devices. Add the following lines to /etc/udev/rules.d/98-ChameleonMini.rules (or create the file if it does not already exist on your system):

# Rule for ChameleonMini RFID Research tool (RevG)
ATTRS{product}=="Chameleon-Mini", SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="04b2", GROUP="users", MODE="0666", SYMLINK+="chameleonG", ENV{ID_MM_DEVICE_IGNORE}="1"

# Rule for ChameleonMini RFID Research tool (RevE)
ATTRS{product}=="Chameleon-Mini", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2044", GROUP="users", MODE="0666", SYMLINK+="chameleonE", ENV{ID_MM_DEVICE_IGNORE}="1"

# DFU mode (i.e., flashing the devices)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2fde", GROUP="users", MODE="0666"

You find the file with these udev rules here.

Next, restart the UDEV service to make sure that these rules are getting parsed:

$ sudo service udev restart
$ sudo udevadm control --reload

Once you have this setup, plugging in the device over USB should create the DEV handler /dev/chameleonE. NOTE: I actually had trouble getting the RevE device recognized this way. To see what the device defaults are run

$ dmesg | tail | grep -i dev

to print the device name the RevE board is attached to. On my system this was something like /dev/ttyACM0. Now you can continue on as in RevG post #64 to configure a serial terminal to communicate with the Chameleon board, or continue on with the flashing procedure below.

Compiling dfu-programmer from source

As numerous online forum posts indicate, if you have trouble flashing the Chameleon devices from within Linux, one thing to rule out is dependencies of the dfu-programmer utililty we will be using to do the chip programming. It's not too difficult to get this programmer compiled from its sources, so we will do just that below. Other under-documented (or at least under-acclaimed) utilities that might be useful to you include the following: dfu-tool and dfu-util (both can be installed by stock apt-get install commands on Debian variants).

To compile dfu-programmer from source execute the following commands in your home directory:

$ git clone https://github.com/dfu-programmer/dfu-programmer.git
$ cd dfu-programmer
$ ./bootstrap.sh
$ ./configure
$ make all
$ alias dfup="$HOME/dfu-programmer/src/dfu-programmer" 

Flashing the device

Follow the instructions on this page to generate your binary Chameleon-Mini.eep and Chameleon-Mini.hex files which we will be flashing to the Chameleon device. Next, put the device in bootloader mode as described here (or here for RevG devices): keep the black button pressed from off to plugging in the board over USB to your Linux box configured as above.

At this point you should have a working DFU device that can be recognized by the Linux box. Verify that this is the case by running:

$ lsusb                 # locate your Chameleon device
$ sudo dfu-tool -v list # verify it's recognized as a DFU-programmable device

REV G

Once the device is appropriately recognized by the software tools, we can proceed to flash the chip. In the RevG case, run the following commands (see here for reference):

$ sudo dfup atxmega128a4u get bootloader-version
$ sudo dfup atxmega128a4u flash --eeprom Chameleon-Mini.eep
$ sudo dfup atxmega128a4u flash Chameleon-Mini.hex
$ sudo dfup atxmega128a4u launch

REV E rebooted

In the RevE case (slightly different chipset on the board), execute the following (TODO: untested):

$ sudo dfup atxmega32a4u get bootloader-version
$ sudo dfup atxmega32a4u flash --eeprom Chameleon-Mini.eep
$ sudo dfup atxmega32a4u flash Chameleon-Mini.hex
$ sudo dfup atxmega32a4u reset

The terminal output should indicate whether the flashing operation was a success or not. If so, congratulations on your new Chameleon firmware!

Troubleshooting

As indicated in this post, there may be a problem with getting the DFU-compatible Chameleon board recognized on some systems due to differences in USB-2 versus USB-3 support. This could be a compatibility issue that can be fixed by upgrading the development packages for libusb-dev on your system. At any rate, if you have USB-3 on your system and are having difficulty getting the board recognized, try routing the connection to the Chameleon through an older USB-2 hub. Another common issue is in faded connectors on some USB cables. Try attaching the device with multiple USB cables to see if this makes a difference in the connection to the board. Other troubleshooting topics can be added here as well.

You can’t perform that action at this time.