How to program ATtiny 85 with PlatformIO / VScode?

You have the board http://digistump.com/products/1?

Me too.

But you need to install drivers first from Releases · digistump/DigistumpArduino · GitHub (then Install Drivers.exe)

Then you have to unplug the device from the USB port and hit “Upload” (Or Advanced → Verbose Upload).

The commandprompt will ask you

micronucleus -c micronucleus --timeout 60 .pio\build\digispark-tiny\firmware.hex
> Please plug in the device ... 

and once you do that…

> Press CTRL+C to terminate the program.
> Device is found!
connecting: 20% complete
connecting: 27% complete
connecting: 34% complete
connecting: 40% complete
> Device has firmware version 1.6
> Available space for user applications: 6012 bytes
> Suggested sleep time between sending pages: 8ms
> Whole page count: 94  page size: 64
> Erase function sleep duration: 752ms
parsing: 60% complete
> Erasing the memory ...
erasing: 65% complete
erasing: 70% complete
erasing: 75% complete
erasing: 80% complete
> Starting to upload ...
writing: 85% complete
writing: 90% complete
writing: 95% complete
writing: 100% complete
>> Micronucleus done. Thank you!
==================== [SUCCESS] Took 10.13 seconds ====================

The compile warnings aren’t too critical, the wrong BIN definition goes unused in the header file.

You can test the blinky LED with

#include <Arduino.h>

/* LED is on chip's PB1 pin which maps to D1 arduino pin*/
#define LED 1

void setup()
{
  pinMode(LED, OUTPUT);
}

void loop()
{
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
}

Just be aware that after upload the bootloader will sit for a short time and wait for a new upload (5 secs), then after will the firmware start.

You always have to plug and unplug that board for uploading, per http://digistump.com/wiki/digispark/tutorials/connecting, since you don’t get into the bootloader otherwise…

Edit: I’ve tried and get the USB-CDC working with help from DigiSpark compilation failure using CDC library - #2 by maxgerhardt but it doesn’t seem to be working anymore – Windows just reports a USB device error (getting descriptor failed). Maybe you have more luck or insights.

3 Likes