Skip to content

Flashing Linux (Unix)

@shinhub edited this page Aug 18, 2019 · 17 revisions

Flash ChameleonMini firmware on GNU/Linux with software

Scope

Note that all of the sections of this page, except for UDEV-specific rules in troubleshooting, 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.

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 RevE rebooted device

Follow the instructions on main Wiki page to compile your firmware: ChameleonMini.eep and ChameleonMini.hex will be generated, in Firmware/ChameleonMini/ where you built firmware source.

Next, because the actual RevE rebooted device is still stuffed with a custom bootloader that scrambles standard firmwares, we need to encode firmware as the bootloader needs it. This is done with the crypt_operations.py Python tool in Software/Tools/ from this repo:

python3 ./Software/Tools/crypt_operations.py scramblehex ./Firmware/ChameleonMini/ChameleonMini.eep ./Firmware/ChameleonMini/ChameleonMini.eep.scramble
python3 ./Software/Tools/crypt_operations.py scramblehex ./Firmware/ChameleonMini/ChameleonMini.hex ./Firmware/ChameleonMini/ChameleonMini.hex.scramble

Next, put the device in bootloader mode as described here: keep the black button pressed while plugging Chameleon USB to your Linux box.

Now go with the following use of dfu-programmer:

sudo dfu-programmer atxmega32a4u erase --force
sudo dfu-programmer atxmega32a4u flash --eeprom --force --suppress-validation ./Firmware/ChameleonMini/ChameleonMini.eep.scramble
sudo dfu-programmer atxmega32a4u flash --force --suppress-validation ./Firmware/ChameleonMini/ChameleonMini.hex.scramble

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

Troubleshooting

USB cables, 2 vs. 3, and libusb-dev

As indicated in this issue, 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.

Configure UDEV to handle the RevE rebooted device

Note: this might not be needed at all. It is not needed on a 2019 Kali Linux with root privileges, but you could need it to ensure your RevE rebooted device is found by flashing tools.

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)
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)
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 most systems this will be something like /dev/ttyACM0.