huh4k ~/dev
Case Study

Digispark ATTINY85 CLI Uploader & Hardware Tooling

Automated firmware flashing utility and payload tool for ATTINY85 USB microcontrollers, integrating arduino-cli compilation without IDE overhead.

Python C++ Arduino CLI Hardware Automation

Overview

The Digispark ATTINY85 is a tiny, low-cost USB development board capable of emulating USB human interface devices (HID keyboards). Flashing code to Digispark devices traditionally requires setting up the legacy Arduino IDE with third-party Micronucleus board URLs, manual USB driver installs, and repetitive manual device plugging cycles.

This project delivers an automated CLI utility and build harness in Python that streamlines compiling .ino sketches and flashing ATTINY85 microcontrollers with a single terminal command.


Architectural Highlights

  • Automated Toolchain Provisioning: Automatically installs and configures arduino-cli, sets up the Digistump core index package JSON, and installs essential Digistump AVR cores silently.
  • Headless Sketch Compilation: Compiles target .ino or C++ scripts through arduino-cli compile --fqbn digistump:avr:digispark-tiny.
  • Micronucleus Integration: Executes the device upload sequence, prompting the user for hot-plugging at the exact 5-second Micronucleus bootloader window.
  • Companion Payload Suite: Paired with Digispark-Scripts providing custom USB HID automation scripts and keystroke injection demos.
# Digispark compilation and flash trigger
def flash_firmware(sketch_path: str):
    print("[+] Compiling sketch with arduino-cli...")
    subprocess.run([
        "arduino-cli", "compile", 
        "--fqbn", "digistump:avr:digispark-tiny", 
        sketch_path
    ], check=True)

    print("[*] Please plug in your Digispark device now (5s bootloader window)...")
    subprocess.run([
        "arduino-cli", "upload", 
        "-p", "usb", 
        "--fqbn", "digistump:avr:digispark-tiny", 
        sketch_path
    ], check=True)
    print("[✓] Firmware upload completed successfully.")