I’ve finally finished work on updating the firmware. The main goal of this update was to add high voltage programming support, but I took a bit more time to prepare the codebase for future updates.
As I’ve shared before, I initially took the ArduinoISP code and made a few adjustments here and there according to my taste (I’m an IT pro in my other life). With each subsequent revision, I had to add more and more changes to support the onboard OLED screen, buffer IC, serial bridge code, and so on.
When the idea of adding a high voltage programmer came I had to completely redesign the RESET schematics, since I had to accommodate a 12 V state, in addition the to 0 V, 5 V, and Z states.
At this stage, things were getting complex enough that I begin having trouble understanding my own code base. I had to modularize it at least.
When you upload your code using Arduino IDE, Platformio, or the basic console, you’d typically use the avrdude tool, as it supports most of the Microchip MCUs and most of the known protocols. In the case of ATtiny Flasher, the STK500 protocol is used.
In fact, the protocol only defines communication contracts between a host PC (avrdude sofware wise) and a programming tool (Flasher in this case). It doesn’t really matter which way Flasher will upload code to MCU, that depends on both the MCU and Flasher capabilities.
Naturally, I’ve extracted the stk500 communication layer into separate class. Its sole responsibility is to handle communication with avrdude.
The next thing was to separate out the ISP communication layer that talks to the MCU using a standard, low-voltage SPI protocol.
With this behind me, it wasn’t much trouble to implement a high-voltage communication equivalent. Now, depending on the state of onboard switch, the STK500 layer will communicate with either the LV or HV implementation over the same interface.
Perhaps more importantly, this design makes it relatively easy to add more supported protocols. I’m planning to add TPI and UPDI support. TPI will add support for smaller Tinys (ATtiny4, ATtiny5, ATtiny9, ATtiny10, ATtiny20), while UPDI will complete the list with support for the latest generation of ATtinys (ATtinyX04, ATtinyX14, ATtinyX24, and many more). Then it will truly be a one tool to flash them all jig.