项目作者: gahcep

项目描述 :
Build your Arduino projects without IDE
高级语言: Makefile
项目地址: git://github.com/gahcep/arduino-mk.git
创建时间: 2017-12-17T07:10:57Z
项目社区:https://github.com/gahcep/arduino-mk

开源协议:MIT License

下载


Build Arduino-based libraries without IDE

This repository contains all required infrastructure to allow you to build your Arduino projects without actually having an IDE nearby.

You are free to forget about *.ino files and Arduino IDE, just setup the toolchain, use main.cpp as a skeleton and you are free to go.

NOTE: only Arduino Nano board were tested (I only have this guy). But the base Makefile should work for any Arduino-based libraries.

AVR Toolchain

In order to be able to compile under GCC and upload firmware files you need:

  • avr-binutils
  • avr-gcc
  • avr-libc
  • avr-dude

Our installation directory will be /usr/local/avr/ and OS is Fedora.

Linux (Fedora) Prerequisites

  1. sudo dnf install gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel flex

avr-binutils

  1. wget https://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.bz2
  2. tar -xvjf binutils-2.29.tar.bz2
  3. cd binutils-2.29
  4. mkdir build && cd build
  5. ../configure --prefix=/usr/local/avr/ --target=avr --disable-nls
  6. make -j8
  7. sudo make install

avr-gcc

  1. wget http://ftpmirror.gnu.org/gcc/gcc-7.1.0/gcc-7.1.0.tar.bz2
  2. tar -xvjf gcc-7.1.0.tar.bz2
  3. cd gcc-7.1.0
  4. mkdir build && cd build
  5. ../configure --prefix=/usr/local/avr/ --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
  6. make -j8
  7. sudo make install

avr-libc

  1. wget https://download.savannah.gnu.org/releases/avr-libc/avr-libc-2.0.0.tar.bz2
  2. tar -xvjf avr-libc-2.0.0.tar.bz2
  3. cd avr-libc-2.0.0
  4. mkdir build && cd build
  5. ../configure --prefix=/usr/local/avr/ --build=`../config.guess` --host=avr
  6. make -j8
  7. # Note: because `install` target that runs `/bin/sh` can't find `avr-ranlib` no matter what
  8. # (expanding PATH doesn't work), we do `make install` from root
  9. su -h
  10. cd PATH_TO_AVR_LIBC
  11. sudo make install

avr-dude

  1. # Note: make sure only flex is installed: no bison/bison-devel is installed
  2. wget https://download.savannah.gnu.org/releases/avrdude/avrdude-6.3.tar.gz
  3. gunzip -c avrdude-6.3.tar.gz | tar xf -
  4. cd avrdude-6.3
  5. mkdir build && cd build
  6. ../configure --prefix=/usr/local/avr/
  7. make -j8
  8. sudo make install

Using Makefile

You can run make help in order to get all the information about possible targets and avalable options to change.

In general the flow is as follows (assuming you want to compile with Wire default Arduino library and immediately after upload to the board):

  1. Update main.cpp file - put your logic in there.

  2. Compile project

    1. make BAUD=57600 PORT=/dev/ttyS0 BRD=AVR_NANO WITH_WIRE=1 all
  3. Upload the binary to the board

    1. make upload

Feedback and Support

Fell free to send me emails, push requests. Also, create issues for missing things.