Skip to content

Flashing Linux (Unix)

shinhub edited this page Aug 11, 2019 · 17 revisions

Flash Chameleon-Mini firmware on GNU/Linux

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.

The dfu-programmer tool, as well as some custom tools from this repo in `Software/Tools/' will be needed to flash the firmware.

We prefer the utility dfu-programmer in place of the suggested avr-dude from the RevG docs for a couple of reasons:

  • dfu-programmer is open source, freely available on GitHub and easy to compile
  • the repository which provides the necessary flip2 support for avr-dude is not recently maintained nor compatible with recent versions of some GNU/Linux distros
  • the RevE rebooted has a custom bootloader that forces some crypto and scrambling operations to flash a new firmware, and at the time standard tools only will not suffice
  • dfu-programmer utility works on both RevE rebooted and RevG devices.

Configure UDEV to handle the USB devices

Note: this might not be needed at all. It is not needed on a 2019 Kali Linux with root privileges.

Following from this #64 post on the RevG board issues forum, it might be needed to configure UDEV rules to control plug-and-play devices mounting results for the Chameleon.

Just copy/paste Drivers/98-ChameleonMini.rules from this repo in /etc/udev/rules.d/, or create the file as this in /etc/udev/rules.d/98-ChameleonMini.rules:

# 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"

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

This utility will be needed to do the chip programming. The latest version (0.7.2) is required and is not available as package on some distros. As so it must be compiled from its sources, so we will do just that below:

$ git clone https://github.com/dfu-programmer/dfu-programmer.git
$ cd dfu-programmer
$ ./bootstrap.sh
$ ./configure
$ make all
$ make install
$ alias dfup="<PATH TO COMPILE DIRECTORY>/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.