How do I update the firmware on ClusterHAT v2.6?

The ClusterHAT v2.6 uses an ATtiny1616 to emulate the XRA1200P I/O expander, to update the firmware using the built-in UPDI programmer you will need to.

  • Use either a Pi 4 or Pi 5 as the controller.
  • Remove all Pi Zeros.
  • Boot the controller using either the regular "Raspberry Pi OS" or ClusterCTRL bookworm release.

If you see any errors when following the steps below please create a new thread on the mailing list, contact us via Discord, or open a support ticket.

When running the steps you can copy/paste the commands within each block to the Pi terminal.

Log into the controller and enable UART5 and reboot (Pi 4 ONLY - NOT needed on Pi 5).

echo "dtoverlay=uart5" | sudo tee -a /boot/firmware/config.txt
sudo reboot

Log into the controller and setup the variables to keep the files within the clusterhat26-firmware directory.

DIR=~/clusterhat26-firmware
mkdir -p $DIR $DIR/home $DIR/user $DIR/data
cd $DIR
export XDG_CACHE_HOME=$DIR/home
export ARDUINO_DIRECTORIES_USER=$DIR/user
export ARDUINO_DIRECTORIES_DATA=$DIR/data

ARCH=$(/usr/bin/dpkg --print-architecture)
MODEL=$(/usr/bin/cat /proc/device-tree/model |/usr/bin/sed "s#^Raspberry Pi \(.*\) Model.*#\1#")

Setup the variable for UART.

# Setup serial port to upload using UPDI over the serial port on GPIO12/13
if [ $MODEL == "4" ];then
 if [ -c /dev/ttyAMA5 ];then
  PORT="/dev/ttyAMA5"
 else
  echo 'Device not found'
  echo 'Append "dtoverlay uart5" onto /boot/firmware/config.txt and reboot'
  echo
  echo 'echo "dtoverlay=uart5" | sudo tee -a /boot/firmware/config.txt'
  echo 
  echo 'And then "sudo reboot" and run this again'
 fi
elif [ $MODEL == "5" ];then
 sudo dtoverlay uart4
 PORT="/dev/ttyAMA4"
else
 echo "Writing firmware not supported from this model of Pi"
fi

Download Arduino-cli.

# Download and extract Arduino CLI for our arch
if [[ $ARCH == "armhf" ]] && [[ ! -f "arduino-cli_latest_Linux_ARMv6.tar.gz" ]]; then
 wget https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARMv6.tar.gz
 tar zxf arduino-cli_latest_Linux_ARMv6.tar.gz
elif [[ $ARCH == "arm64" ]] && [[ ! -f "arduino-cli_latest_Linux_ARM64.tar.gz" ]]; then
 wget https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARM64.tar.gz
 tar zxf arduino-cli_latest_Linux_ARM64.tar.gz
fi

Setup and install the board manager/core/libraries.

$DIR/arduino-cli config add board_manager.additional_urls https://drazzy.com/package_drazzy.com_index.json
$DIR/arduino-cli core install megaTinyCore:megaavr
$DIR/arduino-cli lib install I2C_EEPROM

Download fixup for later python versions (AttributeError: module 'collections' has no attribute 'Hashable')

wget https://raw.githubusercontent.com/SpenceKonde/megaTinyCore/refs/heads/master/megaavr/tools/libs/yaml/constructor.py -O $DIR/data/packages/megaTinyCore/hardware/megaavr/2.5.11/tools/libs/yaml/constructor.py

Download Cluster HAT minimal firmware source code.

mkdir minimal
curl -o minimal/minimal.ino https://raw.githubusercontent.com/8086net/clusterhat26-firmware/refs/heads/main/minimal/minimal.ino

Compile the firmware.

$DIR/arduino-cli compile -b megaTinyCore:megaavr:atxy6:chip=1616,clock=10internal,bodvoltage=2v6 minimal

Program the Cluster HAT v2.6 with the compiled firmware.

$DIR/arduino-cli upload  -b megaTinyCore:megaavr:atxy6:chip=1616,clock=10internal,bodvoltage=2v6 -P serialupdi57k -p $PORT minimal

You should now be able to see the emulated I2C device at address 0x20.

i2cdetect -y 1

When you see the device at 0x20 the ClusterHAT has been programmed correctly.

ADVANCED USERS ONLY

If you're using multiple ClusterHAT on the same Controller Pi you may need to change the I2C address of the ClusterHATs emulated I/O Expander. Whilst this could be changed by cutting solder jumpers on earlier v2.x models with the v2.6 it can currently only be changed by recompiling the firmware. If you've successfully followed the steps above you can update the source code to use an alternative I2C address and then reprogram.

For example to change the source from address 0x20 to 0x21 you can run the following.

sed -i "s#I2C_ADDRESS_DEFAULT 0x20#I2C_ADDRESS_DEFAULT 0x21#" minimal/minimal.ino

Then compile and upload the firmware.

$DIR/arduino-cli compile -b megaTinyCore:megaavr:atxy6:chip=1616,clock=10internal,bodvoltage=2v6 minimal
$DIR/arduino-cli upload  -b megaTinyCore:megaavr:atxy6:chip=1616,clock=10internal,bodvoltage=2v6 -P serialupdi57k -p $PORT minimal

You should then see the ClusterHAT at address 0x21.

i2cdetect -y 1