17
Programming Arduino using Makefile Sudar Muthu Arduino Day 2015 http://hardwarefun.com

Programming arduino using makefile

Embed Size (px)

Citation preview

Page 1: Programming arduino using makefile

Programming Arduino

using MakefileSudar Muthu

Arduino Day 2015

http://hardwarefun.com

Page 2: Programming arduino using makefile

Who am I?

• Hardware Hobbyist

• Used to conduct Arduino and Robotics Workshop

• Long time Arduino User

• Blog at http://hardwarefun.com

• Own more than a dozen Arduino’s ;)

Page 3: Programming arduino using makefile

Why look for alternatives

to Arduino IDE

Page 4: Programming arduino using makefile

What is Arduino Makefile

• Makefile to compile, upload and debug Arduino code

• Highly customizable

• Automatic dependency tracking

• Allows you to use your own IDE / Editor

• Doesn’t require Java ;)

• More than 500 stars in github and 42 contributors

https://github.com/sudar/Arduino-Makefile

Page 5: Programming arduino using makefile

How to Install it?

• Packages available for most platforms -

Debian/Ununtu/Fedora/homebrew/linuxbrew/

• Installing for source is as easy as doing a git

checkout (bleeding edge)

http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile

Page 6: Programming arduino using makefile

Basic Usage

Create a file with name Makefile in your sketch directory with the following

variables and then include the Arduino.mk file

ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java

ARDMK_DIR = /usr/local

MONITOR_PORT = /dev/ttyACM0

BOARD_TAG = uno

Except the last one, everything else can be auto-detected

https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md

Page 7: Programming arduino using makefile

Targets

• make - Compile

• make upload - Upload to Arduino

• make monitor - Open Serial monitor

• make clean - Clean the build

• make size - Run avr-size

Page 8: Programming arduino using makefile

Demo

Page 9: Programming arduino using makefile

Using Serial Monitor

It can auto detect both baud rate and port used.

You can also specify it using the following variables.

MONITOR_PORT = /dev/ttyUSB0

MONITOR_BAUDRATE = 57600

Page 10: Programming arduino using makefile

Including Libraries

Can auto detect the libraries used in most cases.

You can also specify it using the following variable

ARDUINO_LIBS = Ethernet SPI

Page 11: Programming arduino using makefile

More Demos

• Using plain AVR C code

• Using Arduino as ISP

• Using Alternate Cores (like Attiny etc)

• Using ChipKT

• Using Teensyduino

• Using Arduino from Raspberry Pi

Page 12: Programming arduino using makefile

Full List of Options

All options are documented at

https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md

Page 13: Programming arduino using makefile

Interfacing with external

programs/IDE’s

• Vi/Vim

• Emacs/Flymake

• Code:Blocks

• Eclipse

Page 14: Programming arduino using makefile

Limitations

• You have to declare your functions

• Arduino 1.5.x is still not fully supported

• Native Windows support is patchy. You can use

Cygwin

• Supports only AVR based boards. Others WIP

• You would still need to install the IDE

Page 15: Programming arduino using makefile

Contributions are

welcomehttps://github.com/sudar/Arduino-Makefile

Page 16: Programming arduino using makefile

Other projects that may be of

interest

• Arduino syntax files for vim -

https://github.com/sudar/vim-arduino-syntax

• Arduino Snippets for vim -

https://github.com/sudar/vim-arduino-snippets

Page 17: Programming arduino using makefile

Thank You