#Trampoline examples for AVR8 Targets
This directory shows some examples for 8 bits AVR targets, including some Arduino boards. For all these examples, the Gcc cross-compiler is required.
##avr-gcc cross-compiler
Linux (Debian/Ubuntu) -> sudo apt-get install avr-libc gcc-avr avrdude
MacOSX -> AVR CrossPack
Windows -> Winavr (integrated in Atmel Studio, or here).
Arduino libraries should be installed separately as a git submodule.
in the trampoline installation path:
git submodule init
git submodule update machines/avr/arduino
It gets the trampoline patched version of ArduinoCore-avr from GitHub.
##Compilation The build script is written in Python (2.7 and 3.x) and works for Windows, Mac and Linux. The build script (make.py) is generated from goil the first time goil is called.
See examples, for the correct first call to goil (in runGoil.bat for Windows).
The avrdude port should be set as en environmemnt variable. Then, the build script can call avrdude to flash the Arduino:
example (/dev/tty.usbmodem1421
for Mac, but may be /dev/ttyUSB0
with Linux…).
export AVRDUDE_PORT="/dev/tty.usbmodem1421"
./make.py flash
The avr arduino installation is set in machines/avr/arduino
.
Default Libraries are:
- advancedIO : tone, noTone, pulseIn, …
- serial : Serial object
- spi
- i2c (refered as Wire in Arduino…).
- eeprom
- softwareSerial
To insert a library in your project, add in your .oil file (in section CPU->OS->BUILD
):
LIBRARY = serial;
You have an example in the serial/
example (both Arduino Uno and Mega).
The definition is in file goil/templates/config/avr/arduino/config.oil
You may need to add your own libraries, it can be added in the file goil/templates/config/avr/arduino/config.oil
. For the SPI library for instance:
LIBRARY spi {
PATH = "avr/arduino/libraries/SPI/src"; //path from machine/
CPPFILE = "SPI.cpp"; //list of files (CPPFILE, CFILE, ASFILE)
};
The Atmel Studio project allows to insert breakpoints and interactive debug. The generation of a project is not automatic, and should be based on the source files that are compiled in the classic Makefile
based approach…
- create a new C++ project (ATMega328P device for Arduino Uno)
- add all the files compiled using the
./make.py -j 1
command line. - update project properties (
projet->toolchain->C compiler->directories
) with the directories defined in the compilation rules of the 'make' command line (directories starting with -I...) - copy and paste these directories in
C++ compiler-> directories
andassembler/General
- add the symbols used in the 'make' command line (starting with
-D
...) in thesymbols
part (without the-D
) - That's all!