Skip to main content
Wie wil meedoen met de solarbike zelfbouw club?
Who wants to join the solarbike DIY club?

How to burn a bootloader at the ATtiny with UPDI

Published: 03 February 2020
Last updated: 21 July 2024

The great advantage of the Arduino is that it can be programmed easily through the serial USB interface, which is made possible by the bootloader on the chip. This is called uploading. Before this is possible, a bootloader must first be burned onto the chip. This can be done via the SPI bus or the UPDI bus, depending on the chip you are using. For example, the ATmega328 uses the SPI bus, while the ATtiny3217 uses the UPDI bus. In this article, I describe the method using the UPDI bus. The process of burning the bootloader on chips with the SPI bus is described in the article How to burn a bootloader at the ATmega and ATtiny with SPI.

I've created a quick step-by-step guide on how to burn a bootloader into the ATtiny chips that are supported by the megaTinyCore.
In this article, I use the ATtiny3217 as an example, but it is synonymous with all other ATtiny chips.

I want to thank Spence Konde for his an extensive work on the megaTinyCore. Also Hans van Meijdam helped me a lot with the SerialUPDI HV programmer. Spence Konde also sells development boards for the ATtiny3227/3217/1607.

ATtiny3227 3217 1607 dev board Spence KondeDevelopment board Spence Konde

Attention to the UPDI / Reset pin

To make the bootloader work, the UPDI pin is programmed as Reset pin. Then UPDI reprogramming via this pin is blocked. To fix this, a HV programmer is needed as described here: High-Voltage Programmer.

How to burn a bootloader into the ATtiny3217

Step 1

Build the SerialUPDI programmer. 

Arduino SerialUPDI programmerArduino SerialUPDI programmer


You need an FTDI adapter. There may be no series resistors in the TX and RX line. If there are any, make them 0 ohms. This FTDI adapter doesn't have any series resistors:
CH340 FTDI adapterFTDI adapter without series resistors

https://nl.aliexpress.com/item/32643085356.html

Make the following circuit, this creates the UPDI signal:

SerialUPDI programmer circuitSerialUPDI-programmer-circuit

I designed a PCB for this, you can download it here on GitHub.

SerialUPDI programmer PCBSerialUPDI programmer PCB

Step 2

Install the megaTinyCore package.

Attention: Use only Arduino IDE v1.8.13,  uncheck setting "Check for updates on startup"

Sometimes the megaTinyCore package is in not shown, than change the URL to: https://archive.org/download/azduino_micronucleus-mirror/package_drazzy.com_index.json

Step 3

The file boards.txt has to be changed. The location is: C:\Users\xxxxx\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10

It is useful to download the modified boards.txt file here at GitHub.

This is changed in the boards.txt file:
Remove the '#' to uncomment all lines starting with #atxy7.menu.resetpin.Do the same with the lines starting with
#atxy6.menu.resetpin
#atxy4.menu.resetpin
#atxy2.menu.resetpin
It's about 4 to 6 lines each time. Save the file.

Step 4

You can skip this step if you've done it before.

To avoid mistakes, first test if the SerialUPDI programmer works well. Open this blinking-LED sketch: 

const byte ledPin = 0; // Edit this, for the Arduino Nano DIP = 0
void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, 0); delay(500); digitalWrite(ledPin, 1); delay(500); }

Perform the following settings with tools menu:

  • Board > megaTinyCore = Attiny3227/3217... ...(not the w/Optiboot !)
  • Chip -> ATtiny3217
  • UPDI/Reset Pin = UPDI (default)
  • Programmer =  SerialUPDI – SLOW:57600 baud
  • Port, select the right port

Upload the sketch (as normal with Sketch > Upload or the -> button at the top).
The LED has to continue flash now.

Now we can set the board settings for burning the bootloader. This can be done in two ways: step 5a or step 5b (preferred).

Step 5a

The board settings must be set manually in the tools menu, but this is prone to errors. This is a serious problem with mass production if the bootloader needs to be burned. It is impossible to check afterwards whether the correct board settings have been made with the manual settings. Better use step 5b.

First, perform the following settings with the menu tools (or better, go to step 5b, see below)

  • Board = megaTinyCore > Attiny3217/3216....... w/optiboot
  • Chip = ATtiny3217
  • Clock = 16MHz internal
  • UPDI/Reset pin = Reset (default optiboot for 1sec. after ext. reset *DANGER*....
  • Programmer =  SerialUPDI – SLOW:57600 baud
  • Port, select the right port

See here for the correct board settings:

Board settings bootloader ATtiny3217Board settings for burning the bootloader ATtiny3217

Detailed information about the board setting can be found here: https://github.com/SpenceKonde/megaTinyCore

Step 5b

The board settings are stored in the file preferences.txt, which is located at: C:\Users\xxx\AppData\Local\Arduino15\preferences.txt. Instead of manually editing the board settings with the tools menu, which is prone to errors, you can simply replace the preferences.txt file with another file that contains the correct settings. 

The settings required for burning the bootloader are stored in the file "preferences-bootloader-ATtiny3217", which you can download here on GitHub. First make a copy of the original preferences.txt file and then replace it with "preferences-bootloader-ATtiny3217.txt" (of course, change the name first). Restore the original preferences.txt file if you want.

Step 6

Tools > burn bootloader
The bootloader is burned into the ATtiny3217. The UPDI pin is now reprogrammed as reset pin and UPDI programming is blocked.

Ignore errors like this:
avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: jtagmkII_program_enable(): bad response to enter progmode command: RSP_ILLEGAL_MCU_STATE

Step 7

Connect an FTDI adapter to the ATtiny3217, like this

ATtiny3217 FTDI FTDI adapter connection to the ATtiny3217

I always use the ZIGZAG connector method like this: Small ATtiny self-clamping program connector

Step 8

Now we can upload and edit sketches via the bootloader with an FTDI adapter.
Perform the following settings with menu tools:

  • Board =  Attiny3217 w/Optiboot

Upload the ATtiny3217-blinking-LED sketch. The LED has to continue flash now.

Restoring preferences.txt

If you delete this file and restart Arduino and then close it again, a new file will be automatically generated with the default values.

Board settings defaultDefault board settings for the ATtiny3217 in preferences.txt

UPDI Enable with High-Voltage Override

If the UPDI pin is programmed as a reset pin, reprogramming via UPDI is disabled. If we want to program the ATtiny again by the UPDI pin, we need the High-Voltage Programmer.