Skip to main content

 I urgently need individuals who are willing to cooperate on my website and projects.

How to burn the Arduino bootloader

Published: 22 November 2011
Last updated: 28 September 2018

Using the Arduino as a In Circuit System Programmer (ICSP or ISP)

The great advantage of the Arduino is that it can be programmed (this is called uploading) easily through the serial USB interface, which is made possible by the bootloader on the chip. However, smaller Atmel ATtiny chips don't have a serial interface, such as the 8pin ATtiny85. Here we need an In System Programmer (ISP).

ATtiny ICs can be programmed while they are already assembled in the product (system) by the four ISP pins on the chip and a connection cable to an ISP programmer. If in system program isn't possible, the chip must be separately programmed on an IC socket at the ISP programmer.

With the programmer we can do 2 things:

  • Burning the Arduino bootloader.
  • Uploading sketches.

Arduino ISP circuit

There exists several circuits; some use components such as a capacitor between reset and ground, these parts are omitted.

How to burn the Arduino bootloaderHow to burn the Arduino bootloader

Error message "Invalid device signature"

There is an anomaly. Usually, we can burn the bootloader into ATmega chips that doesn't have a crystal oscillator connected. But I encountered that sometimes we get the error message "Invalid device signature" although everything is connected well. In this case, a crystal oscillator is required because the manufacturer has set the internal fuses in a different way. So, to be sure, always connect a crystal oscillator.

Change the Arduino board into an ISP

The first step for burning the Arduino bootloader or burning ATtiny chips is to change the Arduino board into an ISP.

  • For ATtiny chips, use the boards manager, see the article here.
  • Install always the latest Arduino software. 
  • Copy the entire "tiny" folder to \arduino-1.0.4\hardware\ (for version 1.0.4). This completes the board list in Extra > Board with the ATtiny chips.
  • Open the folder C:\Projects\Arduino\hardware\tiny and rename Prospective Boards.txt to Boards.txt.
  • Start Arduino with the Arduino board connected to the USB.
  • Tools > Board > select your Arduino board as usual, for instance Arduino Uno.
  • File > Examples > ArduinoISP.
  • Do not insert the program board.
  • Upload the ArduinoISP sketch to the Arduino.
  • The Arduino is a ATtiny programmer now.

Burning the Arduino bootloader

  • Open the Arduino IDE
  • Select the board in which the processor will be used, for instance: Tools > Board > Arduino Uno. Don't take the Arduino board that is used for ISP.
  • Select the programmer: Tools > Programmer > Arduino as ISP.
  • Tools > Burn Bootloader.

Burning the ATtiny

See also here: http://hlt.media.mit.edu/?p=1695

  • Insert the program board with the ATtiny chip into the Arduino.
  • Check if the heartbeat LED blinks now, if not, disconnect the Arduino and connect again.
  • Extra > Board > select your ATtiny chip, for instance "Attiny85 @ 1MHz (internal oscillator; BOD disabled)".
  • Extra > Programmer > select Arduino as ISP.
  • Upload the example blink program, see below.
  • Ignore two error messages: "avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85".
  • The test LED should blink now, the on and off time is 1 sec. 

Uploading sketches

Attention: when uploading a sketch this way, a bootloader will be deleted!
Normally we use the serial USB port or a FTDI breakout board to upload sketches. But for chips without a serial interface, a SPI programmer has to be used.

  • Sketch > Upload Using Programmer.
  • Note: the upload button doesn't work here, this is confusing.

How to solve weird upload errors

Note that uploading or burning the bootloader doesn't work flawlessly, often you get error messages despite you have not made any mistakes, this is very annoying. If this happens, unconnect the programmer and the chip. Plug in the programmer again and thereafter the chip and then try uploading or burning the bootloader again.

ATtiny45 pin1 used as PB5 or ADC0

As the other ATtiny pins, pin 1 can be used as for instance an I/O line PB5 or an analog input ADC0. But with the Arduino program environment, pin1 can't be used for other purposes. When pin1 is changed once, the chip can't be programmed anymore with the Arduino. So we have to live with just 5 available pins.

Setting the internal ATtiny clock

The fuse bits of the ATtiny, which configures the internal clock, are automatically set by selecting the chip: "Attiny85 (internal 1 MHz clock)" /  "Attiny85 (internal 8 MHz clock)". Note that this influences the timer functions such as delay(). 

How to use the TinyLoadr AVR Breakout and the USBasp for burning bootloaders and uploading sketches

TinyLoadr-AVR-BreakoutTinyLoadr-AVR-Breakout

Jeff Murchison has built the TinyLoadr AVR Breakout, which is an adapter for a AVR/ISP programmer, that supports multiple AVRs. The TinyLoadr AVR Breakout has to be connected to a separate AVR programmer such as the USBasp. The USBasp is an In-Circuit Serial Programming (ICSP or ISP) adapter that allows you to install bootloaders and firmware into AVR microcontrollers. 

You need to install a driver for the USBASP first, I used Zadig (no it isn’t malware from Eastern European): http://zadig.akeo.ie/

  • Open the Arduino IDE
  • Select the board in which the processor will be used, for instance: Tools > Board > Arduino Uno.
    For ATtiny chips see the chapter “Change the Arduino (UNO) into an ISP”
  • Select the programmer: Tools > Programmer > USBasp.
  • Note: USBasp doesn't appear as a USB serial port, this is confusing: Tools > Port is empty.

Burning a bootloader

  • Tools > burn bootloader. 
    Ignore the warning “avrdude: warning: cannot set sck period. please check for usbasp firmware update”

Upload a sketch

  • Sketch > Upload Using Programmer
  • Note: the upload button doesn’t work here, this is confusing.

Links:

Other articles from Interfacing with hardware