Programming Arduino
using Makefile
Sudar Muthu
Arduino Day 2015
http://hardwarefun.com
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 ;)
Why look for alternatives
to Arduino IDE
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
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
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
Targets
• make - Compile
• make upload - Upload to Arduino
• make monitor - Open Serial monitor
• make clean - Clean the build
• make size - Run avr-size
Demo
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
Including Libraries
Can auto detect the libraries used in most cases.
You can also specify it using the following variable
ARDUINO_LIBS = Ethernet SPI
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
Full List of Options
All options are documented at
https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md
Interfacing with external
programs/IDE’s
• Vi/Vim
• Emacs/Flymake
• Code:Blocks
• Eclipse
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
Contributions are
welcome
https://github.com/sudar/Arduino-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
Thank You

Programming arduino using makefile

  • 1.
    Programming Arduino using Makefile SudarMuthu Arduino Day 2015 http://hardwarefun.com
  • 2.
    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 ;)
  • 3.
    Why look foralternatives to Arduino IDE
  • 4.
    What is ArduinoMakefile • 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
  • 5.
    How to Installit? • 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
  • 6.
    Basic Usage Create afile 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
  • 7.
    Targets • make -Compile • make upload - Upload to Arduino • make monitor - Open Serial monitor • make clean - Clean the build • make size - Run avr-size
  • 8.
  • 9.
    Using Serial Monitor Itcan auto detect both baud rate and port used. You can also specify it using the following variables. MONITOR_PORT = /dev/ttyUSB0 MONITOR_BAUDRATE = 57600
  • 10.
    Including Libraries Can autodetect the libraries used in most cases. You can also specify it using the following variable ARDUINO_LIBS = Ethernet SPI
  • 11.
    More Demos • Usingplain AVR C code • Using Arduino as ISP • Using Alternate Cores (like Attiny etc) • Using ChipKT • Using Teensyduino • Using Arduino from Raspberry Pi
  • 12.
    Full List ofOptions All options are documented at https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md
  • 13.
    Interfacing with external programs/IDE’s •Vi/Vim • Emacs/Flymake • Code:Blocks • Eclipse
  • 14.
    Limitations • You haveto 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
  • 15.
  • 16.
    Other projects thatmay 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
  • 17.