merged/modified/etc.

1. Merge remote-tracking branch 'refs/remotes/sudar/master'

Conflicts:
	.gitignore
	arduino-mk/Arduino.mk

2. reflected the advise from jaysonlarose.
3. I guess raw_eeprom should require `reset' on leonardo... I'm not sure.
This commit is contained in:
Masataro Asai 2013-05-28 02:18:34 +09:00
commit 0b2877cfed
8 changed files with 633 additions and 219 deletions

4
.gitignore vendored
View file

@ -1,3 +1,5 @@
*.o *.o
build-cli build-cli
*~ *~
/.project

140
README.md
View file

@ -1,30 +1,17 @@
# A Makefile for Arduino Sketches # A Makefile for Arduino Sketches
This is a very simple Makefile which knows how to build Arduino sketches. This is a very simple Makefile which knows how to build Arduino sketches. It defines the entire workflows for compiling code, flashing it to Arduino and even communicating through Serial monitor. You don't need to change anything in the Arduino sketches.
Until March 2012, this was simply posted on my website where you can If you're using Debian or Ubuntu, you can find this in the `arduino-mk` package.
still find [what
documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html
"Documentation") exists.
If you're using Debian or Ubuntu, you can find this in the ## Credits
arduino-mk package.
# Important Changes, 2012-04-29 This makefile was originally created by [Martin Oldfield](http://mjo.tc/atelier/2009/02/arduino-cli.html) and he maintained it till v0.10.2.
From May 2013, it is maintained by [Sudar](http://hardwarefun.com)
I've rejigged the path calculations so that: ## Usage
1. Few, if any paths, need to specified in the project specific Makefiles. Download a copy of this repo some where in your system.
1. The paths can be grabber from the environment e.g. set up in a user's .bashrc.
1. It should be easier to move between e.g. Mac and Linux.
I'm indebted to Christopher Peplin for making me think about this, and indeed for
contributing code which did similar things in different ways.
The upshot of all this is that you'll need to set up some variables if you want
this to work:
On the Mac you might want to set: On the Mac you might want to set:
@ -38,12 +25,12 @@ On Linux, you might prefer:
AVR_TOOLS_DIR = /usr AVR_TOOLS_DIR = /usr
The Makefile also delegates resetting the board to a short Perl program. The Makefile also delegates resetting the board to a short Perl program.
You'll need to install Device::SerialPort to use it though. You'll also You'll need to install `Device::SerialPort` to use it though. You'll also
need the YAML library to run ard-parse-boards. need the `YAML` library to run ard-parse-boards.
On Debian or Ubuntu: On Debian or Ubuntu:
apt-get install libdevice-serial-perl apt-get install libdevice-serialport-perl
apt-get install libyaml-perl apt-get install libyaml-perl
On Fedora: On Fedora:
@ -51,6 +38,13 @@ On Fedora:
yum install perl-Device-SerialPort yum install perl-Device-SerialPort
yum install perl-YAML yum install perl-YAML
On Mac using MacPorts:
sudo port install p5-device-serialport
sudo port install p5-YAML
and use /opt/local/bin/perl5 instead of /usr/bin/perl
On other systems: On other systems:
cpanm Device::SerialPort cpanm Device::SerialPort
@ -62,3 +56,103 @@ In order to use Arduino libraries installed in the user's sketchbook folder (the
standard location for custom libraries when using the Arduino IDE), you need to standard location for custom libraries when using the Arduino IDE), you need to
set the `ARDUINO_SKETCHBOOK` variable to point to this directory. By default it set the `ARDUINO_SKETCHBOOK` variable to point to this directory. By default it
is set to `$HOME/sketchbook`. is set to `$HOME/sketchbook`.
## Changelog
The following is the rough list of changes that went into different versions. I tried to give credit whenever possible. If I have missed anyone, kindly add it to the list.
### 0.10.2 15.xii.2012 Sudar
- Added sketch size verification. (https://github.com/fornellas)
- Show original line number for error messages (https://github.com/WizenedEE)
- Removed -w from CPPFLAGS to show warnings (https://github.com/gaftech)
- Changed shebang to use /usr/bin/env (https://github.com/anm)
- set USB_VID and USB_PID only for leonardo boards(https://github.com/alohr)
- Updated Readme (https://github.com/fr0sty1/)
### 0.10.1 15.xii.2012 Sudar
- Merged all changes from Upstream and the following changes from https://github.com/rpavlik
- Allow passing extra flags
- Make listing files more useful
- Add knowledge of device-specific assembler
- Use variables instead of hardcoded commands
- Make disasm more helpful
- Change .sym output
- Provide symbol_sizes and generated_assembly targets.
- Be able to silence configuration output
- Make everybody depend on the makefile, in case cflags are changed, etc.
- Make the makefile error if the arduino port is not present.
### 0.10 17.ix.12 M J Oldfield
- Merged all changes from Upstream
### 0.9.3.2 10.ix.2012 Sudar
- Fixed a typo in README. Issue reported at upstream (https://github.com/mjoldfield/Arduino-Makefile/issues/21)
### 0.9.3.1 18.viii.2012 jeffkowalski
- Autodetect ARDUINO_LIBS from includes in LOCAL_SRCS
- Autodetect ARDUINO_SKETCHBOOK from file set by Arduino IDE
- Autodetect ARDMK_DIR based on location of this file
- Added support for utility directory within SYS and USER libraries
### 0.9.3 13.vi.2012
- Auto detect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/)
- Categorize libs into user and system (https://github.com/rpavlik/)
- Dump size at the end of the build (https://github.com/rpavlik/)
- Lots and lots of improvements (https://github.com/rpavlik/)
- Changed bytes option for the head shell command, so that it works in Mac as well
- Auto detect Serial Baud rate from sketch if possible
### 0.9.2 06.vi.2012
- Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech)
- Modified "make size" behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech)
### 0.9.1 06.vi.2012
- Corrected the ubuntu package names
- Prevent the *file-not-found* error if the depends.mk file is not needed
- Delete the build-cli folder as well while doing make clean
- Added support for compiling .pde files in Arduino 1.0 environment
- Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed
- Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE)
- Cleaner way to delete the build-cli directory when make clean is invoked
- The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa)
### 2012-02-12, version 0.8
- Patches for version 1.0 of the Arduino IDE. Older versions might still work, but Ive not tested it.
- A change to the build process: rather than link all the system objects directly into the executable, bundle them in a library first. This should make the final executable smaller.
- If TARGET isnt explicitly set, default to the current directory name. Thanks to Daniele Vergini for this patch.
- Add support for .c files in system libraries: Dirk-Willem van Gulik and Evan Goldenberg both reported this and provided patches in the same spirit.
- Added a size target as suggested by Alex Satrapa.
### Unreleased, version 0.7
- Added -lm to the linker options, and -F to stty.
### 2011-06-23, version 0.6
- Added ard-parse-boards. Mark Sproul suggested doing something like this ages ago, but Ive only recently looked at it in detail.
- Fabien Le Lez reported that one needs to link with -lc to avoid [linker errors](http://forum.arduino.cc/index.php/topic,40215.0.html).
### 2011-06-23, version 0.5
- Imported changes from Debian/Ubuntu, which incorporate a patch from Stefan Tomanek so that libraries would be compiled too.
Note: Many other people sent me similar patches, but I didnt get around to using them. In the end, I took the patch from Debian and Ubuntu: there seems merit in not forking the code and using a tested version. So, thanks and apologies to Nick Andrew, Leandro Coletto Biazon, Thibaud Chupin, Craig Hollabaugh, Johannes H. Jensen, Fabien Le Lez, Craig Leres, and Mark Sproul.
### 2010-05-24, version 0.4
Tweaked rules for the reset target on Philip Hands advice.
### 2010-05-21, version 0.3
- Tidied up the licensing, making it clear that its released under LGPL 2.1.
- [Philip Hands](http://hands.com/~phil/) sent me some code to reset the Arduino by dropping DTR for 100ms, and I added it.
- Tweaked the Makefile to handle version 0018 of the Arduino software which now includes main.cpp. Accordingly we dont need to—and indeed must not—add main.cxx to the .pde sketch file. The paths seem to have changed a bit too.
## Know Issues
- Because of the way the makefile is structured, the configuration parameters gets printed twice.
- Doesn't work with Leonardo yet.
- More todo's at https://github.com/sudar/Arduino-Makefile/issues/
## Similar works
- It's not a derivative of this, but Alan Burlison has written a [similar thing](http://bleaklow.com/2010/06/04/a_makefile_for_arduino_sketches.html).
- Alan's Makefile was used in a [Pragmatic Programmer's article](http://pragprog.com/magazines/2011-04/advanced-arduino-hacking).
- Rei Vilo wrote to tell me that he's using the Makefile ina Xcode 4 template called [embedXcode](http://embedxcode.weebly.com/). Apparently it supports many platforms and boards, including AVR-based Arduino, AVR-based Wiring, PIC32-based chipKIT, MSP430-based LaunchPad and ARM3-based Maple.

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
#! /usr/bin/perl #! /usr/bin/env perl
use strict; use strict;
use warnings; use warnings;
@ -8,9 +8,14 @@ use Pod::Usage;
use YAML; use YAML;
my %Opt = my %Opt =
( (
boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt', boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt',
); );
# if the ARDUINO_DIR is defined, then use it
if (defined $ENV{'ARDUINO_DIR'}) {
$Opt{boards_txt} = "$ENV{'ARDUINO_DIR'}/hardware/arduino/boards.txt";
}
GetOptions(\%Opt, GetOptions(\%Opt,
"boards_txt=s", # filename of the boards.txt file "boards_txt=s", # filename of the boards.txt file

View file

@ -1,4 +1,4 @@
#! /usr/bin/perl #! /usr/bin/env perl
use strict; use strict;
use warnings; use warnings;

View file

@ -3,6 +3,9 @@
import sys import sys
import serial import serial
ser = serial.Serial(sys.argv[1], 1200) ser = serial.Serial(sys.argv[1], 57600)
s.open()
s.close()
s.setBaudrate(1200)
ser.open() ser.open()
ser.close() ser.close()

9
bin/ard-verify-size Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
TARGET_HEX="$1"
MAX_SIZE="$2"
HEX_SIZE="$(cut -c12- < $TARGET_HEX | tr -d \\n | tr -d \\r | wc -c | awk '{print $1/2}')"
if [ $HEX_SIZE -gt $MAX_SIZE ]
then
echo "Sketch size is ${HEX_SIZE} bytes and maximum allowed is ${MAX_SIZE} bytes; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it." 1>&2
exit 1
fi

Binary file not shown.