Developing for the Digispark without using the Arduino IDE

Posted on 17, Mar 2013

Digisparks run the micronucleus bootloader. To upload code to a digispark you will need the micronucleus upload utility:

git clone https://github.com/Bluebie/micronucleus-t85.git
cd micronucleus/commandline
make
sudo make install

Next, the headers and libraries for using the various onboard devices (Serial and so on) are required. DigisparkArduinoIntegration does the trick, to which I have added a modified Arduino Makefile as well as a no IDE example:

$> git clone https://github.com/christopherpoole/DigisparkArduinoIntegration.git
$> DigisparkArduinoIntegration/examples/Digispark_Examples/NoIDEBlink/
$> make
$> sudo make dsupload
micronucleus --run build-cli/main.hex
> Please plug in the device ... 
> Press CTRL+C to terminate the program

The only thing that is different to normal Arduino like development is the inclusion of main :

void setup () {
}

void loop() {
}

int main(void) {
    init();
    setup();
    for (;;) {
        loop();
    }
}

At minimum you need this in your Makefile:

DIGISPARK_DIR = <path to DigisparkArduinoIntegration>

TARGET                 = main
#DIGISPARK_LIBS         = <Serial and so one> 
MCU                    = attiny85
F_CPU                  = 16000000L

include $(DIGISPARK_DIR)/Arduino.mk

Copyright, Christopher Poole 2008-2016.