I2C Bootloader For ATtiny85 Lets Other Micros Push Firmware Updates

There are a few different ways of getting firmware onto one of AVR’s ATtiny85 microcontrollers, including bootloaders that allow for firmware to be updated without the need to plug the chip into a programmer. However, [casanovg] wasn’t satisfied with those so he sent us a tip letting us know he wrote an I2C bootloader for the ATtiny85 called Timonel. It takes into account a few particulars of the part, such as the fact that it lacks a protected memory area where a bootloader would normally reside, and it doesn’t have a native I2C interface, only the USI (Universal Serial Interface). He’s just released the first functional version for the ATtiny85, but there’s no reason it couldn’t be made to work with the ATtiny45 and ATtiny25 as well.

Timonel is designed for systems where there is a more powerful microcontroller or microprocessor running the show (such as an ESP8266, Arduino, or even a board like a Raspberry Pi.) In designs where the ATtinys are on an I2C bus performing peripheral functions such as running sensors, Timonel allows the firmware for these peripheral MCUs to be updated directly from the I2C bus master. Embedded below is a video demo of [casanovg] sending simple serial commands, showing a successful firmware update of an AVR ATtiny85 over I2C.

The ATtiny85 tends to show up a lot in many diminutive projects, like this Tiny Function Generator and Business Card Tetris.

14 thoughts on “I2C Bootloader For ATtiny85 Lets Other Micros Push Firmware Updates

    1. Yes “but” (there’s always a “but” with I2C on the Tiny85 due to its lack of dedicated HW), as the readme explains:

      “This code only supports the attiny841 and attiny441 (only 841 was tested) with TWI hardware. Some attempts have been made to also support attiny24/44/84 with USI hardware, which worked (see the two-wire-usi branch), but due to some of the polling required this was a bit less robust.”

      I’ve searched a lot in the hope of being able to use a bootloader ready and tested, but none worked directly on the Attiny85 for one reason or another, that’s why I’ve written this. I really don’t enjoy reinventing the wheel :)

    1. The whole point is that there is bidirectional communication between the master processor and the slave nodes… I2C doesn’t need that much code either even if you were just bitbanging it and in this case there is the USI doing most of it.

      Most bootloaders also do verification that it was flash correctly… which can’t be done with just a single serial line.

      1. Technicallyyyyyyy you could do it with half-duplex serial in one line, but the real advantage of doing it with i2c is alluded to in the article – being able to program multiple devices on the same bus with different code.

      1. Your guess is correct, I’m working on a small project where the Tiny85 is used as a kind of “I2C-controlled AC mains handling device” (it is in charge of the zero- crossing detection, PWM output, and measures the consumed AC mains current with its ADC). The I2C master, in this case, is an ESP8266 upgradeable by OTA, so with this boot manager, the Tiny85 FW can also be updated wirelessly.

  1. Are there devices this would support that offer more GPIOs and ADCs—like the ATMega328P? I had wanted to connect a Pi to an Arduino via I2C and have the ability to flash it over that I2C channel for remote upgrades.

Leave a Reply to Elliot WilliamsCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.