will be read-only starting December 31st, 2018. For more info please look at this Forum Post

Build using Cmake

This page explains how to cross-compile and link to the arduino core lib using cmake/avr-gcc

This tarball has a dir structure and example file for building with cmake: (derived from arduino-0016 linux)

Intended to be used by people who are writing largish projects for the arduino, people who can't get the standard IDE to work, people who really like a certain text editor, or people who would like to emit a single "make" to build a large number of projects. Spawned from frustrations opening many header files in the default arduino IDE.

General Instructions

  1. Make a new Dir (top level build)
  2. Make a new subdir for the arduino core lib
  3. copy the files from /arduino-0016/hardware/cores/arduino to the dir created above, and add all the C\C++ files to a library directive (see the example in the tarbal)
  4. make a project, and link to the lib created above
  5. convert the built elf exec to a hex file
    • eg, avr-objcopy -O ihex -R .eeprom input output.hex
  6. upload hex file
    • eg, sudo avrdude -V -c dragon_isp -p m168 -b 19200 -P usb -U flash:w:output.hex

Console upload instructions:

  • using bootloader
    1. avr-objcopy -O ihex -R .eeprom input output.hex
    2. sudo avrdude -V -c stk500v1 -p m168 -b 19200 -P /dev/ttyUSB0 -U flash:w:output.hex
  • using AVR Dragon ISP
    1. avr-objcopy -O ihex -R .eeprom input output.hex
    2. sudo avrdude -V -c dragon_isp -p m168 -b 19200 -P usb -U flash:w:output.hex

The following settings allow cmake to cross-compile for the ATmega168. They should be put in the top of every file, or in an include file.



SET(CSTANDARD "-std=gnu99")
SET(CDEBUG "-gstabs")
SET(CWARN "-Wall -Wstrict-prototypes")
SET(CTUNING "-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums")
SET(CINCS "-I${Candi_SOURCE_DIR}/libarduino")
SET(CMCU "-mmcu=atmega168")
SET(CDEFS "-DF_CPU=16000000")



Complements of the Georgia Tech IGVC Team - JS