Programming ATtinys with Arduino 1.6.8 [Updated]
11th March 2016
Update
22nd October 2017: This article has been superseded by Spence Konde's ATTiny Core, which replaces the various earlier ATtiny cores, and provides support for most of the useful ATtiny processors; see ATTinyCore on GitHub. I have only left it here for reference.
Introduction
So far all my AVR projects have been developed using version 1.0.6 of the Arduino IDE, referred to as the Classic Arduino IDE. This supports all Arduino boards apart from the Arduino Yún and Arduino DUE.
I recently decided to try version 1.6.8, to see if my old projects would work under the latest IDE. Initially I had several problems, and this article describes how to solve them and get ATtiny projects working with the latest IDE. Note that I have only been able to test this on the Mac OS X version of the Arduino IDE; please let me know if the same fix works for the Windows version.
Installing the Arduino-Tiny core
Note that before doing any of the following changes you should quit from the Arduino application.
First locate the Arduino folder. Its location is specified in the Arduino Preferences dialog box, and by default is:
/Users/david/Documents/Arduino
or as appropriate for your home folder.
Then install the correct version of the Arduino-Tiny core:
- Download the version of the Arduino-Tiny core extension for Arduino 1.5 [1].
- Put the tiny folder in the hardware folder in the Arduino folder.
- Rename the file Prospective Boards.txt to boards.txt.
If all is well, when you re-run the Arduino application you should see an extra Arduino Tiny section added to the Boards submenu containing the additional options listed in the boards.txt file.
Getting compiling to work
If you select one of the ATtiny options from the Boards submenu, such as ATtiny85 @ 1MHz (internal oscillator; BOD disabled), and try compiling a project, you'll see several warnings which can be ignored (see below for information about how to remove them), and the following error:
exec: "avr-g++": executable file not found in $PATH Error compiling for board ATtiny85 @ 1 MHz (internal oscillator; BOD disabled).
To solve this error:
- Open the tiny folder you installed in the Arduino hardware folder.
- In the avr folder edit the platform.txt file.
- After the comment:
# Default "compiler.path" is correct, change only if you want to overidde
the initial value
- Insert:
compiler.path={runtime.tools.avr-gcc.path}/bin/
- Save the file.
Alternatively, get a corrected file here: platform.txt. You should now be able to compile and upload programs.
Eliminating the warnings
You can ignore the warnings, but if you'd like to get rid of them proceed as follows:
Missing 'build.board' preference
For every board definition in the boards.txt file you'll get the following warning:
Board tiny:avr:attiny85at1 doesn't define a 'build.board' preference.
Auto-set to: AVR_ATTINY85AT1
In each section add an appropriate build.board section with the same prefix as the other entries in that section. For example:
attiny85at1.build.board=AVR_ATTINY85AT1
Bootloader file missing
For the board you are using you'll get a warning:
Bootloader file specified but missing:
/Users/david/Documents/Arduino/hardware/tiny/avr/bootloaders/empty85at1.hex
In the boards.txt file, replace the two lines:
attiny85at1.bootloader.path=empty
attiny85at1.bootloader.file=empty85at1.hex
with the single line:
attiny85at1.bootloader.file=empty/empty85at1.hex
Alternatively, get a corrected file here: boards.txt.
Path warnings
There will be four warnings such as:
Warning: platform.txt from core 'Arduino Tiny' contains deprecated
tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude,
automatically converted to tools.avrdude.cmd.path={path}/bin/avrdude.
Consider upgrading this core.
In each case make the suggested change to the appropriate line in the platform.txt file. Alternatively, get a corrected file here: platform.txt.
This should solve all the warnings.
Language differences
The latest version of the AVR tools used in version 1.6.8 expects a slightly different format for the PROGMEM statement. Replace a line such as:
PROGMEM prog_char Tune[] =
with:
const char Tune[] PROGMEM =
New processor support
As well as supporting the Arduino Yún and Arduino DUE, version 1.6.x of the Arduino IDE supports several recent 8-bit AVR processors. The most interesting of these are:
ATtiny4313: A version of the ATtiny2313 with 4Kbytes of flash and 256bytes of EEPROM and SRAM.
ATtiny841: An improved version of the ATtiny84 with two UARTs, six PWM outputs, and 12 analogue inputs, available in a 14-pin SOIC package.
ATtiny1634: An ATtiny with 16Kbytes of flash memory, 256Kbytes of EEPROM, and 1Kbyte of SRAM, two UARTs, four PWM outputs, and 12 analogue inputs, available in a 20-pin SOIC package.
I'm hoping to develop some applications using these processors and describe them in a future article.
- ^ Arduino-Tiny core on Google Code.
blog comments powered by Disqus