Compare commits

...

140 commits

Author SHA1 Message Date
Sudar Muthu
a1fbda0c53
Merge pull request from tuna-f1sh/grep_Fix
no echo required for `info`
2021-08-02 13:08:09 +05:30
John Whittington
4d7a10c774 no echo required 2021-07-19 11:15:37 +02:00
Sudar Muthu
32736a9353
Merge pull request from xrstf/patch-1
fixed typo in readme
2021-06-05 09:27:30 +05:30
Christoph Mewes
5a328f2673
fixed typo in readme 2021-05-27 16:27:50 +02:00
Simon John
7ac13de7f9
Merge pull request from kpfleming/improve-detection-ard-reset-arduino
Improve detection of ard-reset-arduino location
2020-10-20 12:20:30 +01:00
Kevin P. Fleming
55e003ff6c Improve detection of ard-reset-arduino location
Find location of ard-reset-arduino before prefixing it with
PYTHON_CMD (so that 'which' failure can be detected). Also
display the resulting RESET_CMD, or user-provided RESET_CMD.
2020-10-20 06:47:20 -04:00
Simon John
d664c9b6b2
Merge pull request from kpfleming/use-cxx-for-linking-on-samd
Use C++ compiler when linking for SAMD-based boards
2020-10-20 09:15:05 +01:00
Simon John
e39a026014
Merge pull request from soburi/define_board_macro
Add -DARDUINO_{build.board} and -DARDUINO_VARIANT for compile options
2020-10-20 09:13:50 +01:00
Tokita, Hiroshi
01493f4e23 Add -DARDUINO_VARIANT definition 2020-10-20 09:57:36 +09:00
Kevin P. Fleming
37e757599a Use C++ compiler when linking for SAMD-based boards
The Arduino IDE supports full usage of C++ (including the standard
library) on SAMD-based boards, so the final linking of the executable
must be done using the C++ compiler.

Closes .
2020-10-19 06:21:45 -04:00
Tokita Hiroshi
d21e7ebe99 Add -DARDUINO_BOARD definition 2020-09-16 08:00:59 +09:00
Tokita Hiroshi
e482e6fbc7 Add -DARDUINO_{build.board} for compile options 2020-09-15 12:57:05 +09:00
Sudar Muthu
c7eb909b84
Merge pull request from co-dan/ctags_docs_fix
Rename `CTAGS_CMD` to `CTAGS_EXEC` (in the documentation).
2020-09-03 07:30:28 +05:30
Sudar Muthu
587beb9d7c
Merge pull request from osamuaoki/ARDMK_DIR
Let's make examples platform neutral
2020-09-03 07:25:14 +05:30
Sudar Muthu
e6881e2a43
Merge pull request from tuna-f1sh/travis
Fix Travis CI, add SAMD test support, support GNU grep on macOS
2020-09-03 07:22:54 +05:30
John Whittington
2329d19b97 remove 2020-08-10 16:37:32 +02:00
John Whittington
bf319c49b7 platform neutral examples and manual cherry-pick merge of https://github.com/alissa-huskey/Arduino-Makefile/tree/test_fixes 2020-08-06 20:01:05 +02:00
John Whittington
185a1e9e35 document GREP_CMD 2020-08-06 12:42:47 +02:00
John Whittington
264f8f604a Arduino IDE upto support version and SAMD builds
process uses direct downloads. Might be better to move to distribution
Arduino install + arduino-cli to install board support in future.
2020-08-06 12:32:17 +02:00
John Whittington
bcce50471e add python3 and pip3 to travis yml 2020-08-06 09:29:32 +02:00
John Whittington
517fe4a632 Merge remote-tracking branch 'sej7278/python3' 2020-08-05 18:22:29 +02:00
Simon John
88dc641c8d removed shebang sed from specfile 2020-08-05 00:04:42 +01:00
Simon John
5f5a68aa31 Replaced env with python3 shebang 2020-08-04 23:49:32 +01:00
Simon John
dff6492a4b Fixed SyntaxWarning: "is" vs "==" 2020-08-04 23:28:36 +01:00
Simon John
207253abc6 Rebased python3 branch with some changes from tuna-f1sh@87d5241 2020-08-04 23:19:49 +01:00
John Whittington
26e34cd6f2 detect and use GNU grep on macOS 2020-08-04 11:51:35 +02:00
John Whittington
0c36c3489e Merge branch 'master' of https://github.com/sudar/Arduino-Makefile 2020-06-04 17:50:33 +02:00
Osamu Aoki
ce088e097d Use $(ARDMK_DIR) for 1.6 files
Signed-off-by: Osamu Aoki <osamu@debian.org>
2020-04-13 00:47:06 +09:00
Osamu Aoki
9357f7d3ab Use $(ARDMK_DIR)
Signed-off-by: Osamu Aoki <osamu@debian.org>
2020-04-13 00:28:41 +09:00
Sudar Muthu
6f786a96b0
Merge pull request from ladislas/fix-monitor_baudrate-typo
Fix monitor baudrate typo for user config
2020-03-21 19:48:11 +05:30
Ladislas de Toldi
95d99dd3cc
fix monitor baudrate typo for user config 2020-03-21 13:47:48 +01:00
John Whittington
e6574e3c72 switch compliler flags to prevent AR fail on ARM 2020-02-24 09:58:20 +01:00
John Whittington
93b251a4e1 Merge branch 'master' of https://github.com/sudar/Arduino-Makefile into HEAD 2020-02-24 09:57:13 +01:00
Simon John
e870443f48
Merge pull request from TaylorZowtuk/master
Fixed syntax error of make monitor on windows/cygwin
2019-08-25 15:18:09 +01:00
Dan Frumin
d0f192e983 Rename CTAGS_CMD to CTAGS_EXEC.
The former is not actually tweakable.
2019-07-31 19:42:56 +02:00
Taylor Zowtuk
fa2146080c Updated changelog 2019-07-19 11:11:58 -06:00
Taylor Zowtuk
54c941fa88 Syntax fix and documentation of MONITOR_PARAMS 2019-07-19 11:00:25 -06:00
John Whittington
62caf00a15 Add new *_VER variables to documentation 2019-07-18 11:10:42 +02:00
John Whittington
e3b46003d3 Merge branch 'upstream' into HEAD 2019-07-17 10:25:21 +02:00
John Whittington
bdeaf1576b ARM_TOOL_PATH detection, use latest version of tool if multiple found 2019-07-17 10:19:03 +02:00
Simon John
0e462fcff1
Merge pull request from szeder/build-api
Build the ArduinoCore API (fixes issue )
2019-07-05 07:03:50 +01:00
SZEDER Gábor
d4ae799795 Build the ArduinoCore API
As part of the big modularizing efforts of the Arduino project they
split out the hardware-independent layer of the Arduino "language"
from the hardware-specific cores into the dedicated 'ArduinoCore-API'
repository.  As described in 'ArduinoCore-API's README, the API source
files won't reside directly in the directory of the standard Arduino
core, i.e. in 'ARDUINO_CORE_PATH', but in its 'ARDUINO_CORE_PATH/api'
subdirectory.  Consequently, Arduino-Makefile won't be able to build
any projects when using an Arduino core following the new directory
structure.

Prepare for the upcoming new Arduino core directory structure by
building all 'ARDUINO_CORE_PATH/api/*.cpp' source files as well.  Out
of caution, look out for and build any .c source files in that
directory, too: though there are no .c source files in the
'ArduinoCore-API' repository at the moment, in the future there might
be.  Furthermore, add this directory to the list of directories to be
searched for header files: though it's not necessary to explicitly and
directly include any header file from this directory ('Arduino.h'
includes all there is), some projects might nonetheless do so, and
their build would then break.

Note that a 'make clean' will be most likely necessary when
re-building a project after switching to the new directory structure.
2019-07-04 22:19:18 +02:00
Sudar Muthu
95cae69d7c
Merge pull request from mumme74/master
Allow custom link script (Teensy)
2019-07-03 09:06:19 +05:30
Fredrik Johansson
19d5aafd10 Allow custom link script 2019-07-02 19:02:57 +02:00
Sudar Muthu
3f1ef10d40
Merge pull request from SearchAThing-forks/master
allow to enable AVRDUDE_AUTOERASE_FLASH
2019-06-19 09:05:02 +05:30
Simon John
cf5d016746
Merge pull request from szeder/quiet-0
Show the configuration when ARDUINO_QUIET=0
2019-06-12 20:28:02 +01:00
SZEDER Gábor
dafdaafabd Show the configuration when ARDUINO_QUIET=0
There is a bit of inconsistency between documentation and code
regarding the ARDUINO_QUIET variable: 'arduino-mk-vars.md' states
that ARDUINO_QUIET "Defaults to `0` (unset/disabled)", but the code
only checks whether it's defined or not, and doesn't check whether
it's set to '0' or something else.

Consequently, having 'ARDUINO_QUIET=0' in the Makefile or running
'make ARDUINO_QUIET=0' contadicts the documentation and doesn't print
the configuration.  It also means that if someone in general prefers
not to see a screenful of configuration on each build and therefore
has 'ARDUINO_QUIET = 1' in the project's Makefile or 'config.mak',
then there is no way to override it from the command line in the odd
case when showing the configuration is desired.

Modify the corresponding condition in Arduino.mk to check whether
ARDUINO_QUIET is set to 0 and treat an undefined ARDUINO_QUIET
variable as "set to 0" as well.
2019-06-12 17:15:27 +02:00
Sudar Muthu
3817dbeb28
Merge pull request from stv0g/fix-issue-601
Fix regression: PARSE_BOARD chops off flags which contain '=' signs
2019-06-03 11:52:05 +05:30
Steffen Vogel
6cf275f0e7 fix regression: PARSE_BOARD chops off flags which contain '=' signs (closes ) 2019-05-03 20:07:13 +02:00
Sudar Muthu
8c85ca7001
Merge pull request from Dukejung/master
Add OpenCR.mk for OpenCR 1.0 board example sketch
2019-04-20 14:37:12 +05:30
Simon John
4e465c693c
Update HISTORY.md 2019-04-01 10:30:33 +01:00
Simon John
f5893dc7a1
Merge pull request from tuna-f1sh/master
add swtich for ARM 'avr-size' so that .elf is passed as arg
2019-04-01 10:26:33 +01:00
John Whittington
9783e68bc8 add swtich for ARM 'avr-size' so that .elf is passed as arg
`avr-size` was defaulting to AVR non-aware when using ARM builds, which
meant passing .hex rather than .elf to size and limiting size readout.
Adding a switch for defining `avr-size` and SIZEFLAGS to Sam.mk seems
like the best way to include proper ARM support (despite conflicting
naming).
2019-03-25 13:36:03 +00:00
Simon John
591855b890
Merge pull request from HorkusBoy/samd-typo-pr
Fixed typo in variable name BOARDS_TXT in Sam.mk
2019-03-02 23:38:21 +00:00
Ben B
d2d7d4ec16 Fixed typo in var name BOARDS_TXT in Sam.mk 2019-03-02 10:01:25 -06:00
Dukejung
12c62dd200
Update runtests.sh 2019-02-11 18:04:09 +09:00
Dukejung
c9d9c9f34d
Update HISTORY.md 2019-02-11 17:50:05 +09:00
Dukejung
17a69524ee Add OpenCR.mk for OpenCR 1.0 board and add example code(example/BlinkOpenCR) 2019-02-11 16:54:35 +09:00
Simon John
4452f7790a
Merge pull request from tuna-f1sh/master
Fix  and sam flag for ardmk-init
2019-01-11 19:55:14 +00:00
John Whittington
e3a99fdf4e Only add USB_PRODUCT and USB_MANUFACTURER to flags if defined 2019-01-11 13:49:40 +00:00
John Whittington
8a313c5d94 Populate USB_PRODUCT and USB_MANUFACTURER if in boards file using Caterina 2019-01-11 11:17:16 +00:00
John Whittington
e88f7e1a9f Add 'sam' flag to ardmk-init to include Sam.mk rather than Arduino.mk 2018-12-24 09:24:14 +00:00
Simon John
fd24677719
Updated history
Added ArchLinux documentation uplift
2018-11-27 15:45:59 +00:00
Simon John
2938a0f5b4
Merge pull request from Akram-Chehaima/master
Change & add repo to install package on Arch linux
2018-11-27 14:18:37 +00:00
Akram Chehaima
ccd3a5289c
Change & add repo to install package onArch linux
yaourt is "Discontinued" it's not save must use alternatives like yay On Arch Linux
add commands to install python-pyserial on Arch Linux
2018-11-27 13:59:12 +01:00
Simon John
d3be28b500
Merge pull request from dewhisna/cpu_speed_select
Add support for BOARD_CLOCK setting
2018-11-17 18:59:48 +00:00
Donna Whisnant
35fece8b9c Change BOARD_SPEED to BOARD_CLOCK setting and extend to menu.clock and menu.speed.
This is needed to specify CPU speed and fuses for boards.txt files that use this format:
"{board_tag}.menu.clock.{board_clock}.build.f_cpu"
"{board_tag}.menu.clock.{board_clock}.bootloader.low_fuses"
"{board_tag}.menu.clock.{board_clock}.bootloader.high_fuses"
"{board_tag}.menu.clock.{board_clock}.bootloader.extended_fuses"
For example ATtiny processors.

It also works for speed-only settings like the Watterott ATmega328PB library: https://github.com/watterott/ATmega328PB-Testing
"{board_tag}.menu.speed.{board_clock}.build.f_cpu"
2018-11-11 17:14:11 -06:00
Donna Whisnant
66e0211878 Update documentation for BOARD_SPEED. 2018-11-11 13:27:11 -06:00
Donna Whisnant
0f02622467 Add support for BOARD_SPEED setting.
This is needed to specify CPU speed for boards.txt files that use this format:
"{board_tag}.menu.speed.{board_speed}.build.f_cpu"
For example, the Watterott ATmega328PB library: https://github.com/watterott/ATmega328PB-Testing
2018-11-11 13:01:52 -06:00
Lorenzo Delana
ec1947a7cd allow to enable AVRDUDE_AUTOERASE_FLASH 2018-10-13 02:28:32 +02:00
Lorenzo Delana
b351ab375d
Update arduino-mk-vars.md 2018-10-13 02:21:47 +02:00
Sudar Muthu
5a0c80bf0c
Merge pull request from wingunder/move_core_link_last
Moved CORE_LIB to the last position of the defined linked objects.
2018-10-07 11:19:56 +05:30
Pieter du Preez
ed608ce658 Merge remote-tracking branch 'origin/fix-travis-sudo-required' into move_core_link_last 2018-10-03 21:19:16 +02:00
Pieter du Preez
50e883b640
Fix "does not allow use of 'sudo'" error in travis
Pull requests seem to fail with the following error:
> This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid, and setgid executables.
> If you require sudo, add 'sudo: required' to your .travis.yml

This commit fixes it, by adding 'sudo: required' to .travis.yml, as suggested by the error message.
2018-10-03 14:36:49 +02:00
Pieter du Preez
a285810cb5 Added a test case for moving CORE_LIB in PR .
This patch is meant to test the link order, if the OTHER_OBJS
variable gets used to add 3rd party archives, that depend on the
Arduino core lib (the archive pointed to by the CORE_LIB variable).

The examples/Blink3rdPartyLib directory contains a stripped down Blink
and includes a library in the examples/Blink3rdPartyLib/Toggle
sub-directory. The archive, built inside the Toggle directory mimics a
3rd party library. The archive gets built and linked in by using the
OTHER_OBS variable in examples/Blink3rdPartyLib/Makefile.
2018-10-02 23:00:14 +02:00
Pieter du Preez
d4d3d3d6c3 Merge remote-tracking branch 'org/master' into move_core_link_last 2018-10-02 22:53:12 +02:00
Sudar Muthu
fe84c59194
Merge pull request from wingunder/master
Moved the PARSE_BOARD macro and added the TOOL_PREFIX variable for setting up tool chains.
2018-09-30 20:13:29 +05:30
Sudar Muthu
089b535601
Merge pull request from tuna-f1sh/master
Pass OpenOCD options to debug_init target
2018-09-30 20:12:49 +05:30
Pieter du Preez
ddf7210407 Moved CORE_LIB to the last position of the defined linked objects.
The linking order was changed from:
   $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS)
to:
   $(LOCAL_OBJS) $(OTHER_OBJS) $(OTHER_LIBS) $(CORE_LIB)

This makes more sense, as OTHER_OBJS would rather depend on CORE_LIB,
than the other way around.

Apart from libc and libm, CORE_LIB should conceptually _always_ be
the last lib in the link list, as it is the core (base of everything).
BTW, this was implemented correctly for the 'sam' architecture.
2018-09-30 00:27:18 +02:00
John Whittington
0692c13e98 Pass OpenOCD options to debug_init target 2018-09-28 18:25:56 +01:00
Pieter du Preez
62d23d66a2 Moved the BOARDS_TXT section and stop if BOARDS_TXT is not a file.
The section of Arduino.mk that calculates BOARDS_TXT was moved to just
before the point where it gets used for the first time (a call to
PARSE_BOARD). An error gets generated if BOARDS_TXT is not pointing to a
valid file, directly after the BOARDS_TXT calculation.

In addition, the PARSE_BOARD macro will now be bypassed if the
BOARDS_TXT variable points to a non-existing file. If a user makefile
uses PARSE_BOARD before including Arduino.mk, and the BOARDS_TXT is
wrong, the error will only be caught in the Arduino.mk file, which is
probably acceptable.
2018-09-15 14:31:39 +02:00
Pieter du Preez
e44540043e Added the TOOL_PREFIX variable for setting up the executable tools.
Currently three different tool chains seem to be used:
   * avr-*
   * pic32-*
   * arm-none-eabi-*

These all get set up independently. This patch centralizes the
definitions of the executable tools and does it generically, by means
of the newly introduced TOOL_PREFIX variable. Setting up a
tool chain is now simply a matter of defining the TOOL_PREFIX
variable. For the currently supported tool chains it gets set to avr,
pic32 or arm-none-eabi. Arbitrary tool chains can now easily be set up,
by the TOOL_PREFIX variable.

Although the use of the OVERRIDE_EXECUTABLES variable is now almost
not justifiable, it was left as-is, in order to assure backwards
compatibility.
2018-09-14 16:14:14 +02:00
Pieter du Preez
2442dafb4f Moved the PARSE_BOARD macro from Arduino.mk to Common.mk.
There seems to be 3 different macros to parse the boards.txt file.
This patch moves the PARSE_BOARD macro from Arduino.mk to Common.mk.
The PARSE_OPENCM and PARSE_TEENSY macros in Teensy.mk and OpenCM.mk
were removed and the common PARSE_BOARD is now being called from
everywhere.

Advantages of this fix are:
  1. Less code, i.e. no redundant parse macros.
  2. A single standardized algorithm to parse the boards.txt file.
2018-09-13 23:44:12 +02:00
Simon John
22ca63614d
Merge pull request from TE-HiroakiYamazoe/fix_typo_of_avrdude_isp_opt
Fix typo of AVRDUDE_ISP_OPT
2018-08-10 19:41:18 +01:00
Hiroaki Yamazoe
300ec05328 Fix typo of AVRDUDE_ISP_OPT 2018-08-09 18:48:50 +09:00
Sudar Muthu
b2d1ff23a2
Merge pull request from tuna-f1sh/due
Support for Arduino Due added
2018-06-22 09:45:03 +05:30
John Whittington
3f32563683 Support for Arduino Due added
Update HISTORY.md

Add avr core emulation to C sources
2018-06-14 07:29:06 +01:00
Sudar Muthu
0809b54606
Merge pull request from wingunder/master
Added the DIAGNOSTICS_COLOR_WHEN var for controlling diagnostics-color.
2018-03-18 22:36:23 +05:30
Pieter du Preez
36b6b233eb Added the DIAGNOSTICS_COLOR_WHEN var for controlling diagnostics-color.
Some IDEs do not work nicely with the recently added diagnostics-color
compiler switch. This patch adds the DIAGNOSTICS_COLOR_WHEN variable,
for controlling diagnostics-color switch. The default was chosen to be
'always', which makes the Arduino.mk file backwards compatible with
everything up to commit fa82c3a9db (Sat Sep 2 15:32:52 2017 +0100).

The supported values for DIAGNOSTICS_COLOR_WHEN are: `always`, `never`
and `auto`, and as with all Arduino.mk variables, it can easily be
overridden. For more details on the diagnostics-color compiler switch,
see: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Language-Independent-Options.html#Language-Independent-Options
2018-03-18 16:54:39 +01:00
Simon John
a7b8084ac6
Merge pull request from kierdavis/disable-prog-types-compat
Allow compatibility with old pgmspace API to be disabled by the user
2018-02-24 16:06:09 +00:00
Simon John
139b5dbc49
Merge branch 'master' into disable-prog-types-compat 2018-02-24 16:03:37 +00:00
Simon John
c10eaa4f48
Merge pull request from doronbehar/detect-archlinux
Set `ARDMK_VENDOR` differently if OS is Arch Linux.
2018-02-24 16:02:18 +00:00
Simon John
80b8167206
Merge pull request from tuna-f1sh/sam
Arduino Atmel SAM family Support (ARM architecture)

Thanks @tuna-f1sh !
2018-02-24 16:01:00 +00:00
John Whittington
f804866095 SAMD Cortex M0 device support (Zero, MKR1000, etc)
Compilation improvements by adding variant as other obj but not working on device

Arduino Zero devices with OpenOCD working

Created ARM_TOOLS_DIR and define arm toolchain executables in Sam.mk

Check avr-gcc on last AVR_TOOLS_DIR detect and indenting formatting

GDB debugging and programming added

Documentation updates and define ARDMK_VENDOR rather than include Sam.mk

Expand all parse_boards when defined rather than when used

Trim extra defines regex working on both macOS and Linux but need better fix

Print USB ids and added debug usage to readme

Add note on Arduino package dir and made board.txt work

Do ARM ARDUINO_ARCH define in Arduino.mk]

Add MZeroBlink to non-testable examples for now

Remove \B from extra defines grep

Add ARDUINO_PACKAGE_DIR for board support files

Fix a typo in the README

Fix typo in arduino-mk-vars.md

Prevent re-including Arduino.mk from Sam.mk when make restarts for upload

Add catrina to ARD_REST_OPTS if/else

Remove realpath in Sam.mk for cygwin compatability

SAMD bootloader support in ard-reset using --zero

Enters bootloader using open/close of port at 1200 BAUD, then polls the
attached devices for new port enumerating (bootloader). This is how the
Arduino IDE operates

Bossa support for Zero, MKR1000 etc

Re-word Arm README section after Native USB development

Reset for zero refactored like IDE

Zero bootloader reset tested on macOS and comments added

Re-word ARM bootloader and remove imports from testing

Patch changes ARDMK_VENDOR->ARCHITECHTURE, show_config_vars, ignore CORE_VER if emtpy

Common.mk header guard, openocd/bossac avoid separator, typos

Documentation update for patch changes

Move ARM tools to Sam.mk and auto-detect include

Correct accidental commit of Blink Makefile change

Lib fix with alternative core and documentation

Append zero to ARD_RESET_OPTS rather than set

Prioritise package ARM upload tools over path installed

Add note in README on ARM tools versions

Move openocd variant config script flag to OPTS
2018-02-24 11:15:53 +00:00
Sudar Muthu
8480373477
Merge pull request from kierdavis/fix-typo
Fix typo in arduino-mk-vars.md
2018-01-25 09:38:47 +05:30
Kier Davis
b4c381c4b7
Fix typo in arduino-mk-vars.md 2018-01-24 22:12:01 +00:00
Kier Davis
b3c5127be2
Allow compatibility with old pgmspace API to be disabled by the user
When this compatibility mode is enabled, code that is entirely
compliant with the new pgmspace API can still raise deprecation
warnings when symbols present in both the old and new APIs (for
example, PGM_P) are used. Clearly, these warnings are false
positives. They can be avoided by disabling the compatibility mode.

This functionality is achieved by prepending the flag that enables
the compatibility mode to CPPFLAGS instead of appending it, thus
allowing the user to override the default behaviour and disable the
compatibility mode by putting the negation of the flag in the
CPPFLAGS variable in their top-level Makefile.
2018-01-24 21:52:22 +00:00
Sudar Muthu
5869c98344
Merge pull request from kierdavis/fix-readme-typo
Fix a typo in the README
2018-01-22 15:00:28 +05:30
Kier Davis
5229b075cb
Fix a typo in the README 2018-01-21 23:06:05 +00:00
Simon John
74e1ef00fd
Merge pull request from tuna-f1sh/master
ardmk-init - Makefile initialisation and template project utility
2018-01-12 19:27:14 +00:00
John Whittington
a6d979ef90 Merge remote-tracking branch 'upstream/master' 2018-01-03 08:14:39 +00:00
Simon John
c3fe5dcc2f
Merge pull request from sej7278/master
Moved ATtiny examples from Blink to ATtinyBlink

Probably the last merge of 2017? ;-)
2017-12-28 18:05:18 +00:00
Simon John
6d3d973cd4 Moved ATtiny examples from Blink to ATtinyBlink and updated the instructions (issue ).
Updated the alternate core instructions for e.g. ATmega644p for IDE 1.8
2017-12-28 17:55:01 +00:00
Simon John
7a26a86c78
Merge pull request from sej7278/master
Moved -e flag for avrdude from set_fuses to ispload
2017-12-22 14:13:23 +00:00
Simon John
246e568011 Moved -e flag for avrdude from set_fuses to ispload as you wouldn't want a chip erase operation when only setting the fuses.
ispload probably should erase the flash+eeprom+lockbits as that's when you upload the sketch.

setting fuses should be just that, not deleting anything.
2017-12-22 10:14:06 +00:00
John Whittington
d874c59103 ardmk-init runs without prompt by default, cli arg added to avoid clint dependency 2017-11-07 16:54:34 +00:00
John Whittington
78d11c6678 Update Fedora spec file 2017-10-13 15:41:56 +01:00
John Whittington
625861009a Merge remote-tracking branch 'upstream/master' 2017-10-12 10:41:56 +01:00
John Whittington
2a4c2660be Run ardmk-init without dependancy if running quiet 2017-10-12 09:25:56 +01:00
John Whittington
55c149fb03 Add ardmk-init manpage and correct typos 2017-10-06 10:32:17 +01:00
Doron Behar
c18ad9fba5 Set ARDMK_VENDOR differently if OS is Arch Linux. 2017-10-06 11:35:47 +03:00
SZEDER Gábor
b8f5eaa816 Recognize serial monitors with full path in MONITOR_CMD
When assembling the command line for the various supported serial
monitors, MONITOR_CMD must match the name of one of the supported
commands to be recognized.  Serial monitors given with leading path
components are not recognized, and a command like

  make MONITOR_CMD=~/src/picocom/picocom monitor

errors out as the fallback monitor command is executed instead of the
picocom-specific one.  However, sometimes it's necessary to specify a
supported serial monitor with its full path, because e.g. the user
wants to tests a freshly compiled version before installing it.  Sure,
the user could just run the serial monitor directly, but that's
cumbersome because he has to pay attention to use the right baud rate
and USB port.

So strip all leading path components, if present, from MONITOR_CMD
using the 'nondir' make function before checking whether it's one of
the supported serial monitors.  This way commands like the above would
just work.

While at it, remove the single quotes around 'putty': they are both
unnecessary and inconsistent with similar constructs throughout
Arduino.mk.
2017-10-03 12:54:13 +01:00
John Whittington
c2d17c825a ardmk-init linted using pylint 2017-10-02 15:26:02 +01:00
Sudar Muthu
bc5092f25b Merge pull request from szeder/monitor-cmd-with-path
Recognize serial monitors with full path in MONITOR_CMD
2017-09-29 09:59:16 +05:30
John Whittington
a165a3bf26 ardmk-init usage added to README and HISTORY update 2017-09-28 13:51:08 +01:00
John Whittington
f3bb8249c1 ardmk-init arg parse options and made V1.0 2017-09-28 13:51:04 +01:00
John Whittington
8819e761fb WIP: ardmk-init more verbose about directory operating in 2017-09-28 13:50:51 +01:00
John Whittington
91604be7cc WIP: CLI project makefile generator 2017-09-28 13:45:27 +01:00
John Whittington
5245606f64 Add support for ISP_PROG Atmel Ice 2017-09-28 13:42:49 +01:00
John Whittington
1882a8024e Fix:Add to langmap not set ino,pde using ctags 2017-09-28 13:42:49 +01:00
SZEDER Gábor
c49af21700 Recognize serial monitors with full path in MONITOR_CMD
When assembling the command line for the various supported serial
monitors, MONITOR_CMD must match the name of one of the supported
commands to be recognized.  Serial monitors given with leading path
components are not recognized, and a command like

  make MONITOR_CMD=~/src/picocom/picocom monitor

errors out as the fallback monitor command is executed instead of the
picocom-specific one.  However, sometimes it's necessary to specify a
supported serial monitor with its full path, because e.g. the user
wants to tests a freshly compiled version before installing it.  Sure,
the user could just run the serial monitor directly, but that's
cumbersome because he has to pay attention to use the right baud rate
and USB port.

So strip all leading path components, if present, from MONITOR_CMD
using the 'nondir' make function before checking whether it's one of
the supported serial monitors.  This way commands like the above would
just work.

While at it, remove the single quotes around 'putty': they are both
unnecessary and inconsistent with similar constructs throughout
Arduino.mk.
2017-09-27 00:14:57 +02:00
Sudar Muthu
9708e8265d Merge pull request from tuna-f1sh/master
Update Windows documentation to allow non-relative paths
2017-09-10 18:48:55 -04:00
John Whittington
770d3a7080 Fix indenting 2017-09-06 09:48:04 +00:00
John Whittington
42b5d2dbd8 Auto detect Windows sketchbook path using USERPROFILE not HOME and spelling 2017-09-06 10:34:07 +01:00
John Whittington
e413feedbb Update HISTORY.md 2017-09-05 17:39:42 +01:00
John Whittington
11e2059009 Documentation changes for Windows usage 2017-09-05 17:12:22 +01:00
John Whittington
4519be5bac Detect Cygwin Python or user installed Windows Python and use according device port 2017-09-05 14:18:03 +01:00
Sudar Muthu
360db6f27c Merge pull request from tuna-f1sh/master
Support for generation of project tags file
2017-09-04 22:21:56 -04:00
John Whittington
73426bc233 Merge branch 'master' of https://github.com/sudar/Arduino-Makefile 2017-09-03 21:37:03 +01:00
Simon John
983db51764 Merge pull request from sej7278/master
Moved the LTO etc. flags from CXXFLAGS_STD to CXXFLAGS
2017-09-03 16:02:21 +01:00
John Whittington
04f0ee0728 rm old tags file made safer and only if it exists 2017-09-03 13:19:36 +01:00
John Whittington
85db740a1c Ido/ino typo in echo when building tags 2017-09-03 08:52:44 +01:00
Simon John
fa82c3a9db Moved the LTO etc. flags from CXXFLAGS_STD to CXXFLAGS 2017-09-02 15:32:52 +01:00
John Whittington
4c4c9ac2f0 Merge with upstream 2017-09-01 12:42:45 +00:00
John Whittington
62f2d70815 Use LOCAL_SRC variable due to proir assert and only scan libs if there are libs 2017-09-01 12:33:48 +00:00
Simon John
5fcd04cdef Merge pull request from szeder/quote-prefix-tag
Quote the prefix tag in the space_pad_to function
2017-08-11 09:27:10 +01:00
SZEDER Gábor
a80518e308 Quote the prefix tag in the space_pad_to function
POSIX shells treat an unquoted [abcd] as a pattern bracket expression
and apply it for filename expansion.  This kicks in and causes
troubles in the space_pad_to function when it's called to pad prefix
tags like '[AUTODETECT]', because the argument holding such a tag is
passed to a shell unquoted.  The result is funny output when the
directory containing the Makefile also contains any files or
directories, whose name is a single upper-case character that can be
found in any prefix tags:

  $ touch A B C D
  $ make
  -------------------------
  Arduino.mk Configuration:
  - A C D                CURRENT_OS = LINUX
  - [USER]               ARDUINO_DIR = /home/szeder/src/arduino/arduino-1.8.1
  - [USER]               ARDMK_DIR = /home/szeder/src/arduino/Arduino-Makefile
  - A C D                ARDUINO_VERSION = 181
  - A D                  ARCHITECTURE = avr
  - A D                  ARDMK_VENDOR = arduino
  - A D                  ARDUINO_SKETCHBOOK =
  <snip>

Prevent this by quoting space_pad_to's parameter when passing it to a
shell.
2017-08-08 23:41:28 +02:00
Simon John
c116e48418 Merge pull request from sej7278/master
Add -fno-devirtualize to CXXFLAGS_STD
2017-07-25 06:13:48 +01:00
Simon John
d1156e8fdf Add -fno-devirtualize to CXXFLAGS_STD to workaround a g++ bug. As this could impact performance we should track when the issue is fixed upstream to remove the flag again (see links from Issue )
Enabled colourised diagnostics from avr-gcc

We forgot to increase ARDMK_VERSION for the 1.6.0 release
2017-07-21 21:26:11 +01:00
John Whittington
81673d4666 Support for generation of project tags file
Considering the number of project files spread in different locations
when developing an Arduino project, proper use of tags can be difficult;
resolving beyond local functions.

I've added automatic generation of a tags file, which includes:

* Standard ctags source in project dir (.c, .cpp, .h)
* Arduino source in project dir (.ide, .pde)
* Arduino core based on detected project core from Arduino install.
* Included Arduino libraries from user library folder.

As a Vim user I find this hugely useful and think it would be a useful
addtion for others. Target has been added as `make tags`.
2017-06-04 10:47:04 +01:00
52 changed files with 3035 additions and 536 deletions

View file

@ -1,5 +1,15 @@
os: linux
dist: xenial
language: c
compiler:
- gcc
script: tests/script/runtests.sh
before_install: tests/script/bootstrap.sh
addons:
apt:
packages:
- "python3"
- "python3-pip"
env:
global:
- ARDMK_DIR=$TRAVIS_BUILD_DIR

View file

@ -62,20 +62,23 @@
# AVR_TOOLS_DIR = /usr
#
# On Windows declare this environmental variables using the windows
# configuration options. Control Panel > System > Advanced system settings
# Also take into account that when you set them you have to add '\' on
# all spaces and special characters.
# ARDUINO_DIR and AVR_TOOLS_DIR have to be relative and not absolute.
# This are just examples, you have to adapt this variables accordingly to
# your system.
# configuration options or Cygwin .bashrc. Control Panel > System > Advanced system settings
# The paths must use Unix style forward slash and not have any spaces
# or escape charactors. One must use a symbolic link if the path does
# contain spaces.
#
# ARDUINO_DIR =../../../../../Arduino
# AVR_TOOLS_DIR =../../../../../Arduino/hardware/tools/avr
# This are just examples, you have to adapt this variables accordingly to
# your system. Note the difference between ARDMK_DIR, which can use /cygdrive/
# and USER_LIB_PATH, which cannnot due to invoking with the build tools.
# It is best practice to avoid cygdrive all together.
#
# ARDUINO_DIR = C:/Arduino
# AVR_TOOLS_DIR = C:/Arduino/hardware/tools/avr
# ARDMK_DIR = /cygdrive/c/Users/"YourUser"/Arduino-Makefile
#
# On Windows it is highly recommended that you create a symbolic link directory
# for avoiding using the normal directories name of windows such as
# c:\Program Files (x86)\Arduino
# C:\Program Files (x86)\Arduino
# For this use the command mklink on the console.
#
#
@ -238,6 +241,9 @@ arduino_output =
# running for the first time (i.e., not after a restart after
# regenerating the dependency file), then output the configuration.
ifndef ARDUINO_QUIET
ARDUINO_QUIET = 0
endif
ifeq ($(ARDUINO_QUIET),0)
ifeq ($(MAKE_RESTARTS),)
ifeq ($(MAKELEVEL),0)
arduino_output = $(info $(1))
@ -258,7 +264,9 @@ else
endif
# include Common.mk now we know where it is
include $(ARDMK_DIR)/Common.mk
ifndef COMMON_INCLUDED
include $(ARDMK_DIR)/Common.mk
endif
# show_config_variable macro is available now. So let's print config details for ARDMK_DIR
ifndef ARDMK_DIR_MSG
@ -314,18 +322,19 @@ else
ifeq ($(ARCHITECTURE),avr)
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR
else
ifeq ($(ARCHITECTURE),sam)
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_SAM
else
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_$(shell echo $(ARCHITECTURE) | tr '[:lower:]' '[:upper:]')
endif
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_$(shell echo $(ARCHITECTURE) | tr '[:lower:]' '[:upper:]')
endif
endif
########################################################################
# 1.5.x vendor - defaults to arduino
ifndef ARDMK_VENDOR
ARDMK_VENDOR = arduino
ARCH_LINUX := $(shell grep "Arch Linux" /etc/os-release 2>/dev/null)
ifdef ARCH_LINUX
ARDMK_VENDOR = archlinux-arduino
else
ARDMK_VENDOR = arduino
endif
$(call show_config_variable,ARDMK_VENDOR,[DEFAULT])
else
$(call show_config_variable,ARDMK_VENDOR,[USER])
@ -364,9 +373,15 @@ ifndef ARDUINO_SKETCHBOOK
ifneq ($(ARDUINO_SKETCHBOOK),)
$(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(from arduino preferences file))
else
ARDUINO_SKETCHBOOK := $(firstword \
$(call dir_if_exists,$(HOME)/sketchbook) \
$(call dir_if_exists,$(HOME)/Documents/Arduino) )
ifeq ($(CURRENT_OS), WINDOWS)
ARDUINO_SKETCHBOOK := $(firstword \
$(call dir_if_exists,$(USERPROFILE)/sketchbook) \
$(call dir_if_exists,$(USERPROFILE)/Documents/Arduino) )
else
ARDUINO_SKETCHBOOK := $(firstword \
$(call dir_if_exists,$(HOME)/sketchbook) \
$(call dir_if_exists,$(HOME)/Documents/Arduino) )
endif
$(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT])
endif
else
@ -376,28 +391,129 @@ endif
########################################################################
# Arduino and system paths
# Third party hardware and core like ATtiny or ATmega 16
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE,[USER])
ifndef ALTERNATE_CORE_PATH
ALTERNATE_CORE_PATH = $(ARDUINO_SKETCHBOOK)/hardware/$(ALTERNATE_CORE)/$(ARCHITECTURE)
endif
endif
ifdef ALTERNATE_CORE_PATH
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE_PATH,[COMPUTED], (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE))
else
$(call show_config_variable,ALTERNATE_CORE_PATH,[USER])
endif
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
else
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,ARDUINO_VAR_PATH,[USER])
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,BOARDS_TXT,[USER])
endif
endif
ifeq (,$(wildcard $(BOARDS_TXT)))
$(error Currently BOARDS_TXT='$(BOARDS_TXT)', which is not an existing file or an invalid filename.)
endif
ifndef TOOL_PREFIX
TOOL_PREFIX = avr
endif
ifndef CC_NAME
CC_NAME = avr-gcc
CC_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gcc)
ifndef CC_NAME
CC_NAME := $(TOOL_PREFIX)-gcc
else
$(call show_config_variable,CC_NAME,[COMPUTED])
endif
endif
ifndef CXX_NAME
CXX_NAME = avr-g++
CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.g++)
ifndef CXX_NAME
CXX_NAME := $(TOOL_PREFIX)-g++
else
$(call show_config_variable,CXX_NAME,[COMPUTED])
endif
endif
ifndef AS_NAME
AS_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.as)
ifndef AS_NAME
AS_NAME := $(TOOL_PREFIX)-as
else
$(call show_config_variable,AS_NAME,[COMPUTED])
endif
endif
ifndef OBJCOPY_NAME
OBJCOPY_NAME = avr-objcopy
OBJCOPY_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objcopy)
ifndef OBJCOPY_NAME
OBJCOPY_NAME := $(TOOL_PREFIX)-objcopy
else
$(call show_config_variable,OBJCOPY_NAME,[COMPUTED])
endif
endif
ifndef OBJDUMP_NAME
OBJDUMP_NAME = avr-objdump
OBJDUMP_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objdump)
ifndef OBJDUMP_NAME
OBJDUMP_NAME := $(TOOL_PREFIX)-objdump
else
$(call show_config_variable,OBJDUMP_NAME,[COMPUTED])
endif
endif
ifndef AR_NAME
AR_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.ar)
ifndef AR_NAME
AR_NAME := $(TOOL_PREFIX)-ar
else
$(call show_config_variable,AR_NAME,[COMPUTED])
endif
endif
ifndef SIZE_NAME
SIZE_NAME = avr-size
SIZE_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.size)
ifndef SIZE_NAME
SIZE_NAME := $(TOOL_PREFIX)-size
else
$(call show_config_variable,SIZE_NAME,[COMPUTED])
endif
endif
ifndef NM_NAME
NM_NAME = avr-nm
NM_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.nm)
ifndef NM_NAME
NM_NAME := $(TOOL_PREFIX)-nm
else
$(call show_config_variable,NM_NAME,[COMPUTED])
endif
endif
ifndef AVR_TOOLS_DIR
@ -445,7 +561,14 @@ ifndef AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
$(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
else
echo $(error No AVR tools directory found)
# One last attempt using $(TOOL_PREFIX)-gcc in case using arm
SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $($(TOOL_PREFIX)-gcc)))/..))
ifdef SYSTEMPATH_AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
$(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
else
echo $(error No AVR tools directory found)
endif
endif # SYSTEMPATH_AVR_TOOLS_DIR
endif # BUNDLED_AVR_TOOLS_DIR
@ -464,8 +587,8 @@ else
endif #ndef AVR_TOOLS_DIR
ifndef AVR_TOOLS_PATH
AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin
ifndef TOOLS_PATH
TOOLS_PATH = $(AVR_TOOLS_DIR)/bin
endif
ifndef ARDUINO_LIB_PATH
@ -486,51 +609,6 @@ else
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER])
endif
# Third party hardware and core like ATtiny or ATmega 16
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE,[USER])
ifndef ALTERNATE_CORE_PATH
ALTERNATE_CORE_PATH = $(ARDUINO_SKETCHBOOK)/hardware/$(ALTERNATE_CORE)/$(ARCHITECTURE)
endif
endif
ifdef ALTERNATE_CORE_PATH
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE_PATH,[COMPUTED], (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE))
else
$(call show_config_variable,ALTERNATE_CORE_PATH,[USER])
endif
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
else
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,ARDUINO_VAR_PATH,[USER])
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,BOARDS_TXT,[USER])
endif
endif
########################################################################
# Miscellaneous
@ -566,9 +644,9 @@ else
$(call show_config_variable,BOARD_TAG,[USER])
endif
ifndef PARSE_BOARD
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_BOARD = $(shell grep -Ev '^\#' $(BOARDS_TXT) | grep -E "^[ \t]*$(1).$(2)=" | cut -d = -f 2 | cut -d : -f 2)
ifdef BOARD_CLOCK
BOARD_CLOCK := $(strip $(BOARD_CLOCK))
$(call show_config_variable,BOARD_CLOCK,[USER])
endif
# If NO_CORE is set, then we don't have to parse boards.txt file
@ -596,6 +674,16 @@ ifeq ($(strip $(NO_CORE)),)
$(call show_config_variable,VARIANT,[USER])
endif
ifndef BOARD
BOARD := $(call PARSE_BOARD,$(BOARD_TAG),build.board)
ifndef BOARD
BOARD := $(shell echo $(ARCHITECTURE)_$(BOARD_TAG) | tr '[:lower:]' '[:upper:]')
endif
$(call show_config_variable,BOARD,[COMPUTED],(from build.board))
else
$(call show_config_variable,BOARD,[USER])
endif
# see if we are a caterina device like leonardo or micro
CATERINA := $(findstring caterina,$(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.file))
ifndef CATERINA
@ -616,7 +704,12 @@ ifeq ($(strip $(NO_CORE)),)
endif
ifndef F_CPU
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.f_cpu)
ifdef BOARD_CLOCK
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).build.f_cpu)
endif
ifndef F_CPU
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.f_cpu)
endif
ifndef F_CPU
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
endif
@ -635,6 +728,25 @@ ifeq ($(strip $(NO_CORE)),)
USB_PID := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.pid)
endif
endif
ifndef USB_PRODUCT
USB_PRODUCT := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_product)
ifdef USB_PRODUCT
$(call show_config_variable,USB_PRODUCT,[COMPUTED])
endif
endif
ifndef USB_MANUFACTURER
USB_MANUFACTURER := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_manufacturer)
ifndef USB_MANUFACTURER
USB_MANUFACTURER = "Unknown"
else
$(call show_config_variable,USB_MANUFACTURER,[COMPUTED])
endif
endif
# add caterina flag to ARD_RESET_OPTS
ARD_RESET_OPTS += --caterina
endif
# normal programming info
@ -658,21 +770,36 @@ ifeq ($(strip $(NO_CORE)),)
endif
ifndef ISP_HIGH_FUSE
ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.high_fuses)
ifdef BOARD_CLOCK
ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.high_fuses)
endif
ifndef ISP_HIGH_FUSE
ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.high_fuses)
endif
ifndef ISP_HIGH_FUSE
ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.high_fuses)
endif
endif
ifndef ISP_LOW_FUSE
ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.low_fuses)
ifdef BOARD_CLOCK
ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.low_fuses)
endif
ifndef ISP_LOW_FUSE
ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.low_fuses)
endif
ifndef ISP_LOW_FUSE
ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.low_fuses)
endif
endif
ifndef ISP_EXT_FUSE
ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.extended_fuses)
ifdef BOARD_CLOCK
ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.extended_fuses)
endif
ifndef ISP_EXT_FUSE
ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.extended_fuses)
endif
ifndef ISP_EXT_FUSE
ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.extended_fuses)
endif
@ -736,25 +863,26 @@ endif
# Reset
ifndef RESET_CMD
ARD_RESET_ARDUINO := $(shell which ard-reset-arduino 2> /dev/null)
ifndef ARD_RESET_ARDUINO
# same level as *.mk in bin directory when checked out from git
# or in $PATH when packaged
ARD_RESET_ARDUINO = $(ARDMK_DIR)/bin/ard-reset-arduino
endif
ifneq ($(CATERINA),)
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(DEVICE_PATH)
else
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(call get_monitor_port)
endif
ARD_RESET_ARDUINO_PATH := $(shell which ard-reset-arduino 2> /dev/null)
ifndef ARD_RESET_ARDUINO_PATH
# same level as *.mk in bin directory when checked out from git
# or in $PATH when packaged
ARD_RESET_ARDUINO_PATH = $(ARDMK_DIR)/bin/ard-reset-arduino
endif
ARD_RESET_ARDUINO := $(PYTHON_CMD) $(ARD_RESET_ARDUINO_PATH)
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
# confirm user is using default cygwin unix Python (which uses ttySx) and not Windows Python (which uses COMx)
ifeq ($(PYTHON_CMD),/usr/bin/python)
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(DEVICE_PATH)
else
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)
endif
else
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(DEVICE_PATH)
else
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)
endif
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)
endif
$(call show_config_variable,RESET_CMD,[COMPUTED],(from PYTHON_CMD, ARD_RESET_OPTS and MONITOR_PORT))
else
$(call show_config_variable,RESET_CMD,[USER])
endif
ifneq ($(CATERINA),)
@ -796,7 +924,7 @@ ifeq ($(strip $(CHK_SOURCES)),)
$(call show_config_info,No .pde or .ino files found. If you are compiling .c or .cpp files then you need to explicitly include Arduino header files)
else
#TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49
$(error Need exactly one .pde or .ino file. This makefile doesn't support multiple .ino/.pde files yet)
$(error Need exactly one .pde or .ino file. This makefile doesn\'t support multiple .ino/.pde files yet)
endif
endif
@ -807,17 +935,46 @@ endif
ifeq ($(strip $(NO_CORE)),)
ifdef ARDUINO_CORE_PATH
CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c)
CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/avr-libc/*.c)
CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/$(TOOL_PREFIX)-libc/*.c)
CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
CORE_AS_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.S)
# ArduinoCore-API
CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/api/*.c)
CORE_CPP_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/api/*.cpp)
# USB Core if samd or sam
ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/avr/*.c) # avr core emulation files
CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/USB/*.c)
CORE_CPP_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/USB/*.cpp)
endif
ifneq ($(strip $(NO_CORE_MAIN_CPP)),)
CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS))
$(call show_config_info,NO_CORE_MAIN_CPP set so core library will not include main.cpp,[MANUAL])
endif
# Add core files for sam devices in CORE_OJBS filtering specific paths
ifdef SAM_CORE_PATH
SAM_CORE_OBJ_FILES = $(SAM_CORE_C_SRCS:.c=.c.o) $(SAM_CORE_CPP_SRCS:.cpp=.cpp.o) $(SAM_CORE_AS_SRCS:.S=.S.o)
# variant core files
CORE_OBJS += $(patsubst $(SAM_CORE_PATH)/%, \
$(OBJDIR)/core/%, $(filter $(SAM_CORE_PATH)/%, $(SAM_CORE_OBJ_FILES)))
# libsam on Due
ifdef SAM_LIBSAM_PATH
CORE_OBJS += $(patsubst $(SAM_LIBSAM_PATH)/source/%, \
$(OBJDIR)/core/%, $(filter $(SAM_LIBSAM_PATH)/source/%, $(SAM_CORE_OBJ_FILES)))
endif
# chip sources on Due
ifdef SAM_SYSTEM_PATH
CORE_OBJS += $(patsubst $(SAM_SYSTEM_PATH)/source/%, \
$(OBJDIR)/core/%, $(filter $(SAM_SYSTEM_PATH)/source/%, $(SAM_CORE_OBJ_FILES)))
endif
endif
CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.c.o) $(CORE_CPP_SRCS:.cpp=.cpp.o) $(CORE_AS_SRCS:.S=.S.o)
CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \
CORE_OBJS += $(patsubst $(ARDUINO_CORE_PATH)/%, \
$(OBJDIR)/core/%,$(CORE_OBJ_FILES))
endif
else
@ -861,7 +1018,7 @@ ifeq ($(strip $(NO_CORE)),)
$(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch))
endif
else
$(call show_config_variable,MONITOR_BAUDRATE, [USER])
$(call show_config_variable,MONITOR_BAUDRATE,[USER])
endif
ifndef MONITOR_CMD
@ -889,20 +1046,25 @@ endif
TARGET_HEX = $(OBJDIR)/$(TARGET).hex
TARGET_ELF = $(OBJDIR)/$(TARGET).elf
TARGET_EEP = $(OBJDIR)/$(TARGET).eep
TARGET_BIN = $(OBJDIR)/$(TARGET).bin
CORE_LIB = $(OBJDIR)/libcore.a
# Names of executables - chipKIT needs to override all to set paths to PIC32
# tools, and we can't use "?=" assignment because these are already implicitly
# Names of executables
# In the rare case of wanting to override a path and/or excecutable
# name, the OVERRIDE_EXECUTABLES variable must be defned and _all_
# the excecutables (CC, CXX, AS, OBJCOPY, OBJDUMP AR, SIZE and NM)
# _must_ be defined in the calling makefile.
# We can't use "?=" assignment because these are already implicitly
# defined by Make (e.g. $(CC) == cc).
ifndef OVERRIDE_EXECUTABLES
CC = $(AVR_TOOLS_PATH)/$(CC_NAME)
CXX = $(AVR_TOOLS_PATH)/$(CXX_NAME)
AS = $(AVR_TOOLS_PATH)/$(AS_NAME)
OBJCOPY = $(AVR_TOOLS_PATH)/$(OBJCOPY_NAME)
OBJDUMP = $(AVR_TOOLS_PATH)/$(OBJDUMP_NAME)
AR = $(AVR_TOOLS_PATH)/$(AR_NAME)
SIZE = $(AVR_TOOLS_PATH)/$(SIZE_NAME)
NM = $(AVR_TOOLS_PATH)/$(NM_NAME)
CC = $(TOOLS_PATH)/$(CC_NAME)
CXX = $(TOOLS_PATH)/$(CXX_NAME)
AS = $(TOOLS_PATH)/$(AS_NAME)
OBJCOPY = $(TOOLS_PATH)/$(OBJCOPY_NAME)
OBJDUMP = $(TOOLS_PATH)/$(OBJDUMP_NAME)
AR = $(TOOLS_PATH)/$(AR_NAME)
SIZE = $(TOOLS_PATH)/$(SIZE_NAME)
NM = $(TOOLS_PATH)/$(NM_NAME)
endif
REMOVE = rm -rf
@ -1004,6 +1166,7 @@ endif
# SoftwareSerial requires -Os (some delays are tuned for this optimization level)
%SoftwareSerial.cpp.o : OPTIMIZATION_FLAGS = -Os
%Uart.cpp.o : OPTIMIZATION_FLAGS = -Os
ifndef MCU_FLAG_NAME
MCU_FLAG_NAME = mmcu
@ -1013,11 +1176,18 @@ else
endif
# Using += instead of =, so that CPPFLAGS can be set per sketch level
CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) $(ARDUINO_ARCH_FLAG) -D__PROG_TYPES_COMPAT__ \
-I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_$(BOARD) $(ARDUINO_ARCH_FLAG) \
"-DARDUINO_BOARD=\"$(BOARD)\"" "-DARDUINO_VARIANT=\"$(VARIANT)\"" \
-I$(ARDUINO_CORE_PATH) -I$(ARDUINO_CORE_PATH)/api -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
$(SYS_INCLUDES) $(PLATFORM_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \
-fdata-sections
# PROG_TYPES_COMPAT is enabled by default for compatibility with the Arduino IDE.
# By placing it before the user-provided CPPFLAGS rather than after, we allow the
# the user to disable it if they like, by adding the negation of the flag
# (-U__PROG_TYPES_COMPAT__) to the user-provided CPPFLAGS.
CPPFLAGS := -D__PROG_TYPES_COMPAT__ $(CPPFLAGS)
ifdef DEBUG
OPTIMIZATION_FLAGS= $(DEBUG_FLAGS)
else
@ -1029,23 +1199,26 @@ CPPFLAGS += $(OPTIMIZATION_FLAGS)
# USB IDs for the Caterina devices like leonardo or micro
ifneq ($(CATERINA),)
CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID)
ifdef USB_PRODUCT
CPPFLAGS += -DUSB_PRODUCT='$(USB_PRODUCT)' -DUSB_MANUFACTURER='$(USB_MANUFACTURER)'
endif
endif
# avr-gcc version that we can do maths on
# $(TOOL_PREFIX)-gcc version that we can do maths on
CC_VERNUM = $(shell $(CC) -dumpversion | sed 's/\.//g')
# moved from above so we can find version-dependant ar
ifndef AR_NAME
ifeq ($(TOOL_PREFIX), avr)
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
AR_NAME = avr-gcc-ar
AR_NAME := $(TOOL_PREFIX)-gcc-ar
else
AR_NAME = avr-ar
AR_NAME := $(TOOL_PREFIX)-ar
endif
endif
ifndef CFLAGS_STD
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
CFLAGS_STD = -std=gnu11 -flto -fno-fat-lto-objects
CFLAGS_STD = -std=gnu11
else
CFLAGS_STD =
endif
@ -1056,7 +1229,7 @@ endif
ifndef CXXFLAGS_STD
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics -flto
CXXFLAGS_STD = -std=gnu++11
else
CXXFLAGS_STD =
endif
@ -1068,13 +1241,25 @@ endif
CFLAGS += $(CFLAGS_STD)
CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD)
ASFLAGS += -x assembler-with-cpp
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
ASFLAGS += -flto
DIAGNOSTICS_COLOR_WHEN ?= always
# Flags for AVR
ifeq ($(findstring avr, $(strip $(CC_NAME))), avr)
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
ASFLAGS += -flto
CXXFLAGS += -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)
CFLAGS += -flto -fno-fat-lto-objects -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)
LDFLAGS += -flto -fuse-linker-plugin
endif
# Flags for ARM (most set in Sam.mk)
else
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
CXXFLAGS += -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)
CFLAGS += -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)
endif
endif
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
LDFLAGS += -flto -fuse-linker-plugin
endif
SIZEFLAGS ?= --mcu=$(MCU) -C
# for backwards compatibility, grab ARDUINO_PORT if the user has it set
@ -1132,9 +1317,14 @@ ifneq (,$(findstring AVR,$(shell $(SIZE) --help)))
avr_size = $(SIZE) $(SIZEFLAGS) --format=avr $(1)
$(call show_config_info,Size utility: AVR-aware for enhanced output,[AUTODETECTED])
else
# We have a plain-old binutils version - just give it the hex.
avr_size = $(SIZE) $(2)
$(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED])
ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
avr_size = $(SIZE) $(SIZEFLAGS) $(1)
$(call show_config_info,Size utility: ARM,[AUTODETECTED])
else
# We have a plain-old binutils version - just give it the hex.
avr_size = $(SIZE) $(2)
$(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED])
endif
endif
ifneq (,$(strip $(ARDUINO_LIBS)))
@ -1164,7 +1354,7 @@ endif
########################################################################
# Tools version info
ARDMK_VERSION = 1.5
ARDMK_VERSION = 1.6
$(call show_config_variable,ARDMK_VERSION,[COMPUTED])
CC_VERSION := $(shell $(CC) -dumpversion)
@ -1281,7 +1471,33 @@ $(OBJDIR)/core/%.S.o: $(ARDUINO_CORE_PATH)/%.S $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
# sam core files
$(OBJDIR)/core/%.c.o: $(SAM_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/core/%.cpp.o: $(SAM_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(OBJDIR)/core/%.S.o: $(SAM_CORE_PATH)/%.S $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
# due specific sources from sam core as doesn't core doesn't have SystemInit startup file
$(OBJDIR)/core/%.c.o: $(SAM_LIBSAM_PATH)/source/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/core/%.c.o: $(SAM_SYSTEM_PATH)/source/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
# various object conversions
$(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(COMMON_DEPS)
@$(MKDIR) $(dir $@)
-$(OBJCOPY) -O binary $< $@
$(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS)
@$(MKDIR) $(dir $@)
$(OBJCOPY) -O ihex -R .eeprom $< $@
@ -1307,12 +1523,28 @@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS)
@$(MKDIR) $(dir $@)
$(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@
########################################################################
# Ctags
# Assume ctags is on path unless has been specified
ifndef CTAGS_EXEC
CTAGS_EXEC = ctags
endif
# Default to 'tags' unless user has specified a tags file
ifndef TAGS_FILE
TAGS_FILE = tags
endif
# ctags command: append, flags unsort (as will be sorted after) and specify filename
CTAGS_CMD = $(CTAGS_EXEC) $(CTAGS_OPTS) -auf
########################################################################
# Avrdude
# If avrdude is installed separately, it can find its own config file
ifndef AVRDUDE
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
AVRDUDE = $(TOOLS_PATH)/avrdude
endif
# Default avrdude options
@ -1338,7 +1570,11 @@ endif
# -D - Disable auto erase for flash memory
# Note: -D is needed for Mega boards.
# (See https://github.com/sudar/Arduino-Makefile/issues/114#issuecomment-25011005)
AVRDUDE_ARD_OPTS = -D -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P
ifeq ($(AVRDUDE_AUTOERASE_FLASH), yes)
else
AVRDUDE_ARD_OPTS = -D
endif
AVRDUDE_ARD_OPTS += -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P
ifeq ($(CURRENT_OS), WINDOWS)
# get_monitor_port checks to see if the monitor port exists, assuming it is
# a file. In Windows, avrdude needs the port in the format 'com1' which is
@ -1405,12 +1641,21 @@ endif
# so we do not set it by default.
AVRDUDE_ISP_OPTS = -c $(ISP_PROG) -b $(AVRDUDE_ISP_BAUDRATE)
ifndef $(ISP_PORT)
ifneq ($(strip $(ISP_PROG)),$(filter $(ISP_PROG), usbasp usbtiny gpio linuxgpio avrispmkii dragon_isp dragon_dw))
AVRDUDE_ISP_OPTS += -P $(call get_isp_port)
ifndef ISP_PORT
ifneq ($(strip $(ISP_PROG)),$(filter $(ISP_PROG), atmelice_isp usbasp usbtiny gpio linuxgpio avrispmkii dragon_isp dragon_dw))
# switch for sam devices as bootloader will be on usb serial if using stk500_v2
ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
AVRDUDE_ISP_OPTS += -P $(call get_monitor_port)
else
AVRDUDE_ISP_OPTS += -P $(call get_isp_port)
endif
endif
else
AVRDUDE_ISP_OPTS += -P $(call get_isp_port)
ifeq ($(CURRENT_OS), WINDOWS)
AVRDUDE_ISP_OPTS += -P $(ISP_PORT)
else
AVRDUDE_ISP_OPTS += -P $(call get_isp_port)
endif
endif
ifndef ISP_EEPROM
@ -1428,7 +1673,7 @@ endif
########################################################################
# Explicit targets start here
all: $(TARGET_EEP) $(TARGET_HEX)
all: $(TARGET_EEP) $(TARGET_BIN) $(TARGET_HEX)
# Rule to create $(OBJDIR) automatically. All rules with recipes that
# create a file within it, but do not already depend on a file within it
@ -1442,8 +1687,15 @@ $(OBJDIR): pre-build
pre-build:
$(call runscript_if_exists,$(PRE_BUILD_HOOK))
# copied from arduino with start-group, end-group
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS) -lc -lm $(LINKER_SCRIPTS)
# sam devices need start and end group, and must be linked using C++ compiler
ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
$(CXX) $(LINKER_SCRIPTS) -Wl,-Map=$(OBJDIR)/$(TARGET).map -o $@ $(LOCAL_OBJS) $(OTHER_OBJS) $(OTHER_LIBS) $(LDFLAGS) $(CORE_LIB) -Wl,--end-group
# otherwise traditional
else
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(OTHER_OBJS) $(OTHER_LIBS) $(CORE_LIB) -lc -lm $(LINKER_SCRIPTS)
endif
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
@ -1451,21 +1703,47 @@ $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
error_on_caterina:
$(ERROR_ON_CATERINA)
# Use submake so we can guarantee the reset happens
# before the upload, even with make -j
upload: $(TARGET_HEX) verify_size
ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
# do reset toggle at 1200 BAUD to enter bootloader if using avrdude or bossa
ifeq ($(strip $(UPLOAD_TOOL)), avrdude)
$(MAKE) reset
else ifeq ($(findstring bossac, $(strip $(UPLOAD_TOOL))), bossac)
$(MAKE) reset
endif
$(MAKE) do_sam_upload
else
$(MAKE) reset
$(MAKE) do_upload
endif
raw_upload: $(TARGET_HEX) verify_size
ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
$(MAKE) do_sam_upload
else
$(MAKE) error_on_caterina
$(MAKE) do_upload
endif
do_upload:
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
$(AVRDUDE_UPLOAD_HEX)
do_sam_upload: $(TARGET_BIN) verify_size
ifeq ($(findstring openocd, $(strip $(UPLOAD_TOOL))), openocd)
$(OPENOCD) $(OPENOCD_OPTS) -c "telnet_port disabled; program {{$(TARGET_BIN)}} verify reset $(BOOTLOADER_SIZE); shutdown"
else ifeq ($(findstring bossac, $(strip $(UPLOAD_TOOL))), bossac)
$(BOSSA) $(BOSSA_OPTS) $(TARGET_BIN)
else ifeq ($(findstring gdb, $(strip $(UPLOAD_TOOL))), gdb)
$(GDB) $(GDB_UPLOAD_OPTS)
else ifeq ($(strip $(UPLOAD_TOOL)), avrdude)
$(MAKE) ispload
else
@$(ECHO) "$(BOOTLOADER_UPLOAD_TOOL) not currently supported!\n\n"
endif
do_eeprom: $(TARGET_EEP) $(TARGET_HEX)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
$(AVRDUDE_UPLOAD_EEP)
@ -1494,23 +1772,31 @@ reset_stty:
$$STTYF $(call get_monitor_port) -hupcl
ispload: $(TARGET_EEP) $(TARGET_HEX) verify_size
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \
$(AVRDUDE_ISPLOAD_OPTS)
burn_bootloader:
ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE)
endif
ifneq ($(strip $(AVRDUDE_ISP_BURN_BOOTLOADER)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_BURN_BOOTLOADER)
endif
ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST)
ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam)
ifeq ($(strip $(BOOTLOADER_UPLOAD_TOOL)), openocd)
$(OPENOCD) $(OPENOCD_OPTS) -c "telnet_port disabled; init; halt; $(BOOTLOADER_UNPROTECT); program {{$(BOOTLOADER_PARENT)/$(BOOTLOADER_FILE)}} verify reset; shutdown"
else
@$(ECHO) "$(BOOTLOADER_UPLOAD_TOOL) not currently supported!\n\n"
endif
else
ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE)
endif
ifneq ($(strip $(AVRDUDE_ISP_BURN_BOOTLOADER)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_BURN_BOOTLOADER)
endif
ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST)
endif
endif
set_fuses:
ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_PRE)
endif
ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST)
@ -1529,20 +1815,26 @@ show_submenu:
@$(CAT) $(BOARDS_TXT) | grep -E '[a-zA-Z0-9_\-]+.menu.(cpu|chip).[a-zA-Z0-9_\-]+=' | sort -uf | sed 's/.menu.\(cpu\|chip\)./:/' | sed 's/=/:/' | column -s: -t
monitor:
ifeq ($(MONITOR_CMD), 'putty')
ifneq ($(strip $(MONITOR_PARAMS)),)
ifeq ($(notdir $(MONITOR_CMD)), putty)
ifneq ($(strip $(MONITOR_PARAMS)),)
$(MONITOR_CMD) -serial -sercfg $(MONITOR_BAUDRATE),$(MONITOR_PARAMS) $(call get_monitor_port)
else
else
$(MONITOR_CMD) -serial -sercfg $(MONITOR_BAUDRATE) $(call get_monitor_port)
endif
else ifeq ($(MONITOR_CMD), picocom)
endif
else ifeq ($(notdir $(MONITOR_CMD)), picocom)
$(MONITOR_CMD) -b $(MONITOR_BAUDRATE) $(MONITOR_PARAMS) $(call get_monitor_port)
else ifeq ($(MONITOR_CMD), cu)
else ifeq ($(notdir $(MONITOR_CMD)), cu)
$(MONITOR_CMD) -l $(call get_monitor_port) -s $(MONITOR_BAUDRATE)
else
$(MONITOR_CMD) $(call get_monitor_port) $(MONITOR_BAUDRATE)
endif
debug_init:
$(OPENOCD) $(OPENOCD_OPTS)
debug:
$(GDB) $(GDB_OPTS)
disasm: $(OBJDIR)/$(TARGET).lss
@$(ECHO) "The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss\n\n"
@ -1562,6 +1854,22 @@ generate_assembly: $(OBJDIR)/$(TARGET).s
generated_assembly: generate_assembly
@$(ECHO) "\"generated_assembly\" target is deprecated. Use \"generate_assembly\" target instead\n\n"
tags:
ifneq ($(words $(wildcard $(TAGS_FILE))), 0)
rm -f $(TAGS_FILE)
endif
@$(ECHO) "Generating tags for local sources (INO an PDE files as C++): "
$(CTAGS_CMD) $(TAGS_FILE) --langmap=c++:+.ino.pde $(LOCAL_SRCS)
ifneq ($(words $(ARDUINO_LIBS)), 0)
@$(ECHO) "Generating tags for project libraries: "
$(CTAGS_CMD) $(TAGS_FILE) $(foreach lib, $(ARDUINO_LIBS),$(USER_LIB_PATH)/$(lib)/*)
endif
@$(ECHO) "Generating tags for Arduino core: "
$(CTAGS_CMD) $(TAGS_FILE) $(ARDUINO_CORE_PATH)/*
@$(ECHO) "Sorting..\n"
@sort $(TAGS_FILE) -o $(TAGS_FILE)
@$(ECHO) "Tag file generation complete, output: $(TAGS_FILE)\n"
help_vars:
@$(CAT) $(ARDMK_DIR)/arduino-mk-vars.md
@ -1580,8 +1888,10 @@ help:
make show_boards - list all the boards defined in boards.txt\n\
make show_submenu - list all board submenus defined in boards.txt\n\
make monitor - connect to the Arduino's serial port\n\
make debug_init - start openocd gdb server\n\
make debug - connect to gdb target and begin debugging\n\
make size - show the size of the compiled output (relative to\n\
resources, if you have a patched avr-size).\n\
resources, if you have a patched $(TOOL_PREFIX)-size).\n\
make verify_size - verify that the size of the final file is less than\n\
the capacity of the micro controller.\n\
make symbol_sizes - generate a .sym file containing symbols and their\n\
@ -1593,6 +1903,7 @@ help:
generated assembly of the main sketch.\n\
make burn_bootloader - burn bootloader and fuses\n\
make set_fuses - set fuses without burning bootloader\n\
make tags - generate tags file including project libs and Arduino core\n\
make help_vars - print all variables that can be overridden\n\
make help - show this help\n\
"
@ -1600,7 +1911,7 @@ help:
.PHONY: all upload raw_upload raw_eeprom error_on_caterina reset reset_stty ispload \
clean depends size show_boards monitor disasm symbol_sizes generated_assembly \
generate_assembly verify_size burn_bootloader help pre-build
generate_assembly verify_size burn_bootloader help pre-build tags debug debug_init
# added - in the beginning, so that we don't get an error if the file is not present
-include $(DEPS)

View file

@ -1,9 +1,19 @@
COMMON_INCLUDED = TRUE
# Useful functions
# Returns the first argument (typically a directory), if the file or directory
# named by concatenating the first and optionally second argument
# (directory and optional filename) exists
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \
then \
$(GREP_CMD) -Ev '^\#' $(BOARDS_TXT) | \
$(GREP_CMD) -E "^[ \t]*$(1).$(2)=" | \
cut -d = -f 2- | \
cut -d : -f 2; \
fi)
# Run a shell script if it exists. Stops make on error.
runscript_if_exists = \
$(if $(wildcard $(1)), \
@ -14,7 +24,7 @@ runscript_if_exists = \
# For message printing: pad the right side of the first argument with spaces to
# the number of bytes indicated by the second argument.
space_pad_to = $(shell echo $(1) " " | head -c$(2))
space_pad_to = $(shell echo "$(1) " | head -c$(2))
# Call with some text, and a prefix tag if desired (like [AUTODETECTED]),
show_config_info = $(call arduino_output,- $(call space_pad_to,$(2),20) $(1))
@ -26,21 +36,33 @@ show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2))
# Just a nice simple visual separator
show_separator = $(call arduino_output,-------------------------)
# Master Arduino Makefile include (after user Makefile)
ardmk_include = $(shell basename $(word 2,$(MAKEFILE_LIST)))
$(call show_separator)
$(call arduino_output,Arduino.mk Configuration:)
$(call arduino_output,$(call ardmk_include) Configuration:)
########################################################################
#
# Detect OS
ifeq ($(OS),Windows_NT)
CURRENT_OS = WINDOWS
GREP_CMD = grep
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CURRENT_OS = LINUX
GREP_CMD = grep
endif
ifeq ($(UNAME_S),Darwin)
CURRENT_OS = MAC
ifeq (, $(shell which gggrep))
$(info Using macOS BSD grep, please install GNU grep to avoid warnings)
GREP_CMD = grep
else
GREP_CMD = ggrep
endif
endif
endif
$(call show_config_variable,CURRENT_OS,[AUTODETECTED])
@ -51,12 +73,20 @@ $(call show_config_variable,CURRENT_OS,[AUTODETECTED])
ifneq ($(TEST),)
DEPENDENCIES_DIR = /var/tmp/Arduino-Makefile-testing-dependencies
DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_DIR)/mpide-0023-linux64-20130817-test
DEPENDENCIES_MPIDE_DIR := $(shell find $(DEPENDENCIES_DIR) -name 'mpide-0023-*' -type d -exec ls -dt {} + | head -n 1)
ifeq ($(MPIDE_DIR),)
MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR)
endif
DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/arduino-1.0.6
ifndef ARDUINO_IDE_DIR
ifeq ($(CURRENT_OS),MAC)
ARDUINO_IDE_DIR = Arduino.app/Contents/Resources/Java
else
ARDUINO_IDE_DIR := $(shell basename $(basename $(basename $(lastword $(wildcard $(DEPENDENCIES_DIR)/arduino*)))))
endif
endif
DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/$(ARDUINO_IDE_DIR)
ifeq ($(ARDUINO_DIR),)
ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR)
endif
@ -81,7 +111,28 @@ else
endif
ifeq ($(CURRENT_OS),WINDOWS)
ifneq ($(shell echo $(ARDUINO_DIR) | egrep '^(/|[a-zA-Z]:\\)'),)
echo $(error On Windows, ARDUINO_DIR must be a relative path)
ifneq ($(shell echo $(ARDUINO_DIR) | egrep '\\|[[:space:]]|cygdrive'),)
echo $(error On Windows, ARDUINO_DIR and other defines must use forward slash and not contain spaces, special characters or be cygdrive relative)
endif
endif
########################################################################
# System Python
ifndef PYTHON_CMD
# try for Python 3 first
PYTHON_CMD := $(shell which python3 2> /dev/null)
ifdef PYTHON_CMD
$(call show_config_variable,PYTHON_CMD,[AUTODETECTED])
else
# fall-back to any Python
PYTHON_CMD := $(shell which python 2> /dev/null)
ifdef PYTHON_CMD
$(call show_config_variable,PYTHON_CMD,[AUTODETECTED])
else
echo $(error "Unable to find system Python! Utility scipts won't work. Override this error by defining PYTHON_CMD")
endif
endif
else
$(call show_config_variable,PYTHON_CMD,[USER])
endif

View file

@ -5,7 +5,38 @@ 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.
### In Development
- TBC
- Fix: Moved CORE_LIB to the last position of the defined linked objects. (https://github.com/wingunder)
- Fix: Moved ATtiny examples to ATtinyBlink, updated alternate core instructions (issue #537) (https://github.com/sej7278)
- Fix: Add -fno-devirtualize flag to workaround g++ segfault bug (issue #486). (https://github.com/sej7278)
- Fix: Quote the prefix tag in the space_pad_to function
- Fix: recognize serial monitors with full path in MONITOR_CMD
- Fix: Grab USB_PRODUCT and USB_MANUFACTURER from boards.txt for 32u4 boards (issue #594).
- Fix: Show the configuration when ARDUINO_QUIET=0
- Fix: Travis build and bring Arduino IDE upto date
- Fix: Builds for SAMD-based boards use the C++ compiler for linking (issue #644). (https://github.com/kpfleming)
- Tweak: Move chip erase flag from set_fuses to ispload to prevent sketch being nuked when setting fuses
- Tweak: Set ARDMK_VERSION to 1.6 (https://github.com/sej7278)
- Tweak: Move non-standard-related items from CxxFLAGS_STD to CxxFLAGS (issue #523) (https://github.com/sej7278)
- Tweak: Update Windows usage documentation and allow non-relative paths (issue #519) (https://github.com/tuna-f1sh)
- Tweak: Support Cygwin Unix Python and Windows installation on Windows to pass correct port binding. (https://github.com/tuna-f1sh)
- Tweak: Update how avr-size is called on Sam, also moved to gnu11 std (issue #602) (https://github.com/tuna-f1sh)
- Tweak: Detect most recent toolchain if multiple found, add `*_VER` variable to override (issue #611) (https://github.com/tuna-f1sh)
- New: Added -fdiagnostics-color to \*STD flags (https://github.com/sej7278)
- New: Made -fdiagnostics-color take a variiable DIAGNOSTICS_COLOR_WHEN: never, always, auto. (https://github.com/wingunder)
- New: Add generation of tags file using ctags, which automatically includes project libs and Arduino core. (https://github.com/tuna-f1sh)
- New: Add template Makefile and project boilerplate initialise script, `ardmk-init`. (https://github.com/tuna-f1sh)
- New: Support atmelice_isp JTAG tool as ISP programmer. (https://github.com/tuna-f1sh)
- New: Compatibility with deprecated pgmspace.h API can now be disabled since it sometimes causes bogus compiler warnings (issue #546)
- New: Support Arduino ARM SAMD devices (Zero, M0 Pro, Feather M0). (https://github.com/tuna-f1sh)
- New: Support Arduino ARM SAM devices (Due). (https://github.com/tuna-f1sh)
- New: Moved the PARSE_BOARD macro to Common.mk and use only this to parse the boards.txt file. (https://github.com/wingunder)
- New: Added the TOOL_PREFIX variable for setting up the executable tools centrally and generically. (https://github.com/wingunder)
- New: Add support for BOARD_CLOCK for board.menu.speed and board.menu.clock entries in boards.txt files. (https://github.com/dewhisna)
- New: Updated Arch instructions. (https://github.com/Akram-Chehaima)
- New: Add support for Robotis OpenCR 1.0 boards.
- New: Build the ArduinoCore API
- New: Support for Python 3 and multi-os Python installation using new PYTHON_CMD variable.
- New: Add "ARDUINO_{build.board}" to be able to detect board type.
### 1.6.0 (2017-07-11)
- Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278)
@ -17,6 +48,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
- New: Add support for good old cu as monitor command (issue #492) (https://github.com/mwm)
- New: Add a documentation how to setup Makefile for 3rd party boards (issue #499). (https://github.com/MilanV)
- New: Add support for Robotis OpenCM boards
- Fix: Syntax of inner conditional statements of monitor command evaluated when MONITOR_CMD = putty
### 1.5.2 (2017-01-11)

View file

@ -44,17 +44,12 @@ ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/boards.txt
endif
ifndef PARSE_OPENCM
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_OPENCM = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
endif
ifndef F_CPU
F_CPU := $(call PARSE_OPENCM,$(BOARD_TAG),build.f_cpu)
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
endif
# if boards.txt gets modified, look there, else hard code it
ARCHITECTURE = $(call PARSE_OPENCM,$(BOARD_TAG),build.architecture)
ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
ifeq ($(strip $(ARCHITECTURE)),)
ARCHITECTURE = arm
endif
@ -74,81 +69,11 @@ endif
########################################################################
# command names
ifndef CC_NAME
CC_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.gcc)
ifndef CC_NAME
CC_NAME := arm-none-eabi-gcc
else
$(call show_config_variable,CC_NAME,[COMPUTED])
endif
endif
ifndef CXX_NAME
CXX_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.g++)
ifndef CXX_NAME
CXX_NAME := arm-none-eabi-g++
else
$(call show_config_variable,CXX_NAME,[COMPUTED])
endif
endif
ifndef AS_NAME
AS_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.as)
ifndef AS_NAME
AS_NAME := arm-none-eabi-as
else
$(call show_config_variable,AS_NAME,[COMPUTED])
endif
endif
ifndef OBJDUMP_NAME
OBJDUMP_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.objdump)
ifndef OBJDUMP_NAME
OBJDUMP_NAME := arm-none-eabi-objdump
else
$(call show_config_variable,OBJDUMP_NAME,[COMPUTED])
endif
endif
ifndef AR_NAME
AR_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.ar)
ifndef AR_NAME
AR_NAME := arm-none-eabi-ar
else
$(call show_config_variable,AR_NAME,[COMPUTED])
endif
endif
ifndef SIZE_NAME
SIZE_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.size)
ifndef SIZE_NAME
SIZE_NAME := arm-none-eabi-size
else
$(call show_config_variable,SIZE_NAME,[COMPUTED])
endif
endif
ifndef NM_NAME
NM_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.nm)
ifndef NM_NAME
NM_NAME := arm-none-eabi-nm
else
$(call show_config_variable,NM_NAME,[COMPUTED])
endif
endif
ifndef OBJCOPY_NAME
OBJCOPY_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.objcopy)
ifndef OBJCOPY_NAME
OBJCOPY_NAME := arm-none-eabi-objcopy
else
$(call show_config_variable,OBJCOPY_NAME,[COMPUTED])
endif
endif
TOOL_PREFIX = arm-none-eabi
# processor stuff
ifndef MCU
MCU := $(call PARSE_OPENCM,$(BOARD_TAG),build.family)
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.family)
endif
ifndef MCU_FLAG_NAME
@ -161,20 +86,20 @@ ifndef USB_TYPE
USB_TYPE = USB_SERIAL
endif
CPPFLAGS += -DBOARD_$(call PARSE_OPENCM,$(BOARD_TAG),build.board)
CPPFLAGS += -DMCU_$(call PARSE_OPENCM,$(BOARD_TAG),build.mcu)
CPPFLAGS += -DBOARD_$(call PARSE_BOARD,$(BOARD_TAG),build.board)
CPPFLAGS += -DMCU_$(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
CPPFLAGS += -DSTM32_MEDIUM_DENSITY -DVECT_TAB_FLASH
CPPFLAGS += $(call PARSE_OPENCM,$(BOARD_TAG),build.option)
CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
CXXFLAGS += -fno-rtti
CXXFLAGS += $(call PARSE_OPENCM,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_OPENCM,$(BOARD_TAG),build.gnu0x)","true")
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
CXXFLAGS_STD += -std=gnu++0x
endif
ifeq ("$(call PARSE_OPENCM,$(BOARD_TAG),build.elide_constructors)", "true")
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
CXXFLAGS += -felide-constructors
endif
@ -209,7 +134,7 @@ ifeq ($(CURRENT_OS), WINDOWS)
else
override AVRDUDE_ARD_OPTS = $(call get_monitor_port)
endif
override AVRDUDE_UPLOAD_HEX = $(TARGET_HEX)
########################################################################

273
OpenCR.mk Normal file
View file

@ -0,0 +1,273 @@
########################################################################
#
# Support for Robotis OpenCR boards
#
# Written by Dowhan Jeong, EunJin Jeong
#
# Based on work that is copyright Jeremy Shaw, Sudar, Nicholas Zambetti,
# David A. Mellis & Hernando Barragan.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
########################################################################
ifndef ARDUINO_DIR
echo $(error ARDUINO_DIR should be specified)
endif
ifndef BOARD_TAG
echo $(error BOARD_TAG should be specified. check board list with 'make show_boards')
endif
ifndef ARDMK_DIR
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
endif
include $(ARDMK_DIR)/Common.mk
ifndef ARDUINO_PACKAGE_DIR
# attempt to find based on Linux, macOS and Windows default
ARDUINO_PACKAGE_DIR := $(firstword \
$(call dir_if_exists,$(HOME)/.arduino15/packages) \
$(call dir_if_exists,$(ARDUINO_DIR)/packages) \
$(call dir_if_exists,$(HOME)/Library/Arduino15/packages) \
$(call dir_if_exists,$(realpath $(USERPROFILE))/AppData/Local/Arduino15/packages) )
$(call show_config_variable,ARDUINO_PACKAGE_DIR,[AUTODETECTED],(from DEFAULT))
else
$(call show_config_variable,ARDUINO_PACKAGE_DIR,[USER])
endif
ifndef ARDMK_VENDOR
ARDMK_VENDOR = OpenCR
endif
ifndef ARCHITECTURE
ARCHITECTURE := OpenCR
endif
ifndef CORE_VER
CORE_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)/1.*)
ifneq ($(CORE_VER),)
CORE_VER := $(shell basename $(CORE_VER))
$(call show_config_variable,CORE_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
endif
else
$(call show_config_variable,CORE_VER,[USER])
endif
ARCHITECTURE := sam
arduino_output =
# When output is not suppressed and we're in the top-level makefile,
# running for the first time (i.e., not after a restart after
# regenerating the dependency file), then output the configuration.
ifndef ARDUINO_QUIET
ifeq ($(MAKE_RESTARTS),)
ifeq ($(MAKELEVEL),0)
arduino_output = $(info $(1))
endif
endif
endif
# Arduino Settings (will get shown in Arduino.mk as computed)
ifndef ALTERNATE_CORE_PATH
ifdef CORE_VER
ALTERNATE_CORE_PATH = $(ARDUINO_PACKAGE_DIR)/OpenCR/hardware/OpenCR/$(CORE_VER)
else
echo $(error Cannot find $(CORE_VER). Check directory settings.)
endif
endif
ifndef ARDUINO_CORE_PATH
ARDUINO_CORE_PATH= $(ALTERNATE_CORE_PATH)/cores/arduino
endif
ifndef BOARDS_TXT
BOARDS_TXT= $(ALTERNATE_CORE_PATH)/boards.txt
endif
ifndef VARIANT
VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),build.variant)
endif
ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants/$(VARIANT)
# Check boards file exists before continuing as parsing non-existant file can create problems
ifneq ($(findstring boards.txt, $(wildcard $(ALTERNATE_CORE_PATH)/*.txt)), boards.txt)
echo $(error $(CORE_VER) Cannot find boards file $(BOARDS_TXT). Check ?? and board support installed)
endif
# grab any sources in the variant core path.
# directorys were manually checked.
# Core sources(used to generate libcore.a archive)
OPENCR_CORE_C_SRCS_1 := $(wildcard $(ARDUINO_CORE_PATH)/avr/*.c)
OPENCR_CORE_C_SRCS_2 := $(wildcard $(ARDUINO_CORE_PATH)/*.c)
OPENCR_CORE_CPP_SRCS := $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
# library sources
OPENCR_LIB_C_SRCS_1 := $(wildcard $(ARDUINO_VAR_PATH)/bsp/opencr/*.c)
OPENCR_LIB_C_SRCS_2 := $(wildcard $(ARDUINO_VAR_PATH)/hw/*.c)
OPENCR_LIB_C_SRCS_3 := $(wildcard $(ARDUINO_VAR_PATH)/hw/driver/*.c)
OPENCR_LIB_C_SRCS_4 := $(wildcard $(ARDUINO_VAR_PATH)/hw/usb_cdc/*.c)
OPENCR_LIB_C_SRCS_5 := $(wildcard $(ARDUINO_VAR_PATH)/lib/STM32F7xx_HAL_Driver/Src/*.c)
OPENCR_LIB_CPP_SRCS := $(wildcard $(ARDUINO_VAR_PATH)/*.cpp)
OPENCR_LIB_S_SRCS := $(wildcard $(ARDUINO_VAR_PATH)/bsp/opencr/startup/*.S)
ifndef F_CPU
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
endif
OPENCR_LIB_OBJ_FILES = $(notdir $(OPENCR_LIB_C_SRCS_1:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_2:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_3:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_4:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_5:.c=.c.o)) $(notdir $(OPENCR_LIB_CPP_SRCS:.cpp=.cpp.o)) $(notdir $(OPENCR_LIB_S_SRCS:.S=.S.o))
OTHER_OBJS = $(patsubst %, \
$(OBJDIR)/OpenCRlib/%, $(OPENCR_LIB_OBJ_FILES))
OPENCR_CORE_OBJ_FILES = $(notdir $(OPENCR_CORE_C_SRCS_1:.c=.c.o)) $(notdir $(OPENCR_CORE_C_SRCS_2:.c=.c.o)) $(notdir $(OPENCR_CORE_CPP_SRCS:.cpp=.cpp.o))
# override is used since opencr dosen't need other sam core objects
override CORE_OBJS = $(patsubst %, \
$(OBJDIR)/core/%, $(OPENCR_CORE_OBJ_FILES))
ifndef AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_gcc/5.4.0-2016q2)
endif
ifeq ($(strip $(AVR_TOOLS_DIR)),)
echo $(error $(AVR_TOOLS_DIR) Cannot find AVR_TOOLS_DIR. Check AVR_TOOLS_DIR)
endif
# Robotis OpenCR platform library directory
ifndef ARDUINO_PLATFORM_LIB_PATH
ARDUINO_PLATFORM_LIB_PATH = $(ALTERNATE_CORE_PATH)/libraries
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from OPENCR_DIR))
endif
########################################################################
# command names
TOOL_PREFIX = arm-none-eabi
# processor stuff
ifndef MCU
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
endif
ifndef MCU_FLAG_NAME
MCU_FLAG_NAME=mcpu
endif
########################################################################
# FLAGS
ifndef USB_TYPE
USB_TYPE = USB_SERIAL
endif
# from platform.txt
CPPFLAGS += -DARDUINO_OpenCR
CPPFLAGS += -DARDUINO_ARCH_OPENCR
CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.common_flags)
OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc1)
OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc2)
OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc3)
OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc4)
OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc5)
OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc6)
OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc7)
CPPFLAGS += $(OPENCR_COMPILER_LIBS_C_FLAGS)
CFLAGS_STD += -c -g -O2 -std=gnu11 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_$(VARIANT)
CXXFLAGS_STD += -c -g -O2 -std=gnu++11 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_$(VARIANT)
ASFLAGS += -c -g -x assembler-with-cpp -MMD
LDFLAGS += -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-unresolved-symbols -Wl,--start-group -Wl,--whole-archive
LINKER_SCRIPTS = -T$(ARDUINO_VAR_PATH)/bsp/opencr/ldscript/opencr_flash.ld
########################################################################
# Reset is handled by upload script. OpenCR don't neet reset command.
override RESET_CMD =
########################################################################
# Object conversion & uploading magic, modified from Arduino.mk
override TARGET_HEX = $(OBJDIR)/$(TARGET).bin
override avr_size = $(SIZE) --target=binary $(2)
# Define UPLOAD_TOOL as avrdude to use avrdude upload recipe in Arduino.mk
override UPLOAD_TOOL = avrdude
ifeq ($(CURRENT_OS), WINDOWS)
override AVRDUDE = $(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_tools/1.0.0/win/opencr_ld.exe
else
override AVRDUDE = $(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_tools/1.0.0/linux/opencr_ld
endif
override AVRDUDE_COM_OPTS = $(DEVICE_PATH)
override AVRDUDE_ISP_OPTS = 115200 $(TARGET_HEX) 1
override AVRDUDE_ISPLOAD_OPTS =
########################################################################
# automatically include Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
########################################################################
# OpenCR core files
$(OBJDIR)/core/%.c.o: $(ARDUINO_CORE_PATH)/avr/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/core/%.c.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/core/%.cpp.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
# OpenCR lib files
$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/bsp/opencr/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/driver/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/usb_cdc/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/lib/STM32F7xx_HAL_Driver/Src/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/OpenCRlib/%.cpp.o: $(ARDUINO_VAR_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(OBJDIR)/OpenCRlib/%.S.o: $(ARDUINO_VAR_PATH)/bsp/opencr/startup/%.S $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
# Object conversion & uploading magic, modified from Arduino.mk
$(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(COMMON_DEPS)
@$(MKDIR) $(dir $@)
$(OBJCOPY) -v -Obinary $< $@
@$(ECHO) '\n'
$(call avr_size,$<,$@)
ifneq ($(strip $(HEX_MAXIMUM_SIZE)),)
@if [ `$(SIZE) --target=binary $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch $@.sizeok; fi
else
@$(ECHO) "Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less then $(BOARD_TAG)\'s flash memory"
@touch $@.sizeok
endif
CORE_LIB += -Wl,--no-whole-archive -lstdc++

197
README.md
View file

@ -7,8 +7,11 @@ This is a very simple Makefile which knows how to build Arduino sketches. It def
- Very robust
- Highly customizable
- Supports all official AVR-based Arduino boards
- Supports official ARM-based Arduino boards using Atmel SAM chip family
and includes on-device debugging targets.
- Supports chipKIT
- Supports Teensy 3.x (via Teensyduino)
- Supports Robotis OpenCR 1.0
- Works on all three major OS (Mac, Linux, Windows)
- Auto detects serial baud rate and libraries used
- Support for `*.ino` and `*.pde` sketches as well as raw `*.c` and `*.cpp`
@ -51,10 +54,10 @@ $ brew install --HEAD arduino-mk
#### Arch Linux
Arch Linux users can use the unofficial AUR package [arduino-mk](https://aur.archlinux.org/packages/arduino-mk/).
It can be installed using the following command.
It can be installed with [AUR] helper using the following command.
```sh
yaourt -S arduino-mk
yay -S arduino-mk
```
#### Fedora
@ -80,14 +83,14 @@ installer or download the distribution zip file and extract it.
The Makefile also delegates resetting the board to a short Python program.
You'll need to install [`pySerial`](https://pypi.python.org/pypi/pyserial) to use it though.
On most systems you should be able to install it using either `pip` or `easy_install`.
On most systems you should be able to install it using either `pip3` or `easy_install3`.
```sh
pip install pyserial
pip3 install pyserial
# or if you prefer easy_install
easy_install -U pyserial
easy_install3 -U pyserial
```
If you prefer to install it as a package, then you can do that as well.
@ -95,48 +98,60 @@ If you prefer to install it as a package, then you can do that as well.
On Debian or Ubuntu:
```sh
apt-get install python-serial
apt-get install python3-serial
```
On Fedora:
```sh
yum install pyserial
# or on Fedora 22+
dnf install pyserial
dnf install python3-pyserial
```
On openSUSE:
```sh
zypper install python-serial
zypper install python3-serial
```
On Mac using MacPorts:
On Arch:
```sh
sudo port install py27-serial
sudo pacman -S python-pyserial
```
On macOS using Homebrew (one can install to System Python but this is not recommend or good practice):
```sh
brew install python
pip3 install pyserial
```
On Windows:
You need to install Cygwin and its packages for Make, Perl and the following Serial library.
You need to install Cygwin and its packages for Make, Perl, Python3 and the following Serial library.
Assuming you included Python in your Cygwin installation:
1. download PySerial source package from [https://pypi.python.org/pypi/pyserial](https://pypi.python.org/pypi/pyserial)
2. extract downloaded package running
```tar xvzf dowloaded_package_name.tar.gz```
2. extract downloaded package running `tar xvzf dowloaded_package_name.tar.gz`
3. navigate to extracted package folder
4. build and install Python module:
```
python setup.py build
python setup.py install
python3 setup.py build
python3 setup.py install
```
Alternatively, if you have setup Cygwin to use a Windows Python installation,
simply install using pip:
```
pip3 install pyserial
```
Arduino-Makefile should automatically detect the Python installation type and
use the correct device port binding.
## Usage
Download a copy of this repo somewhere to your system or install it through a package by following the above installation instruction.
@ -144,7 +159,7 @@ Download a copy of this repo somewhere to your system or install it through a pa
Sample makefiles are provided in the `examples/` directory. E.g. [Makefile-example](examples/MakefileExample/Makefile-example.mk) demonstrates some of the more advanced options,
whilst [Blink](examples/Blink/Makefile) demonstrates the minimal settings required for various boards like the Uno, Nano, Mega, Teensy, ATtiny etc.
MAC:
### Mac
On the Mac with IDE 1.0 you might want to set:
@ -158,24 +173,28 @@ On the Mac with IDE 1.0 you might want to set:
On the Mac with IDE 1.5+ it's like above but with
```
```make
ARDUINO_DIR = /Applications/Arduino.app/Contents/Java
```
LINUX:
### Linux
You can either declare following variables in your project's makefile or set them as environmental variables.
```make
ARDUINO_DIR Directory where Arduino is installed
ARDMK_DIR Directory where you have copied the makefile
AVR_TOOLS_DIR Directory where avr tools are installed
```
Keep in mind, that Arduino 1.5.x+ comes with it's own copy of avr tools which you can leverage in your build process here.
Example of ~/.bashrc file:
export ARDUINO_DIR=/home/sudar/apps/arduino-1.0.5
export ARDMK_DIR=/home/sudar/Dropbox/code/Arduino-Makefile
export AVR_TOOLS_DIR=/usr/include
```make
export ARDUINO_DIR=/home/sudar/apps/arduino-1.0.5
export ARDMK_DIR=/home/sudar/Dropbox/code/Arduino-Makefile
export AVR_TOOLS_DIR=/usr/include
```
Example of the project's make file:
@ -184,66 +203,79 @@ Example of the project's make file:
MONITOR_PORT = /dev/ttyACM0
```
WINDOWS:
### Windows
On Windows (using cygwin), you might want to set:
On Windows (using Cygwin), you might want to set:
```make
ARDUINO_DIR = ../../arduino
# Symbolic link to Arduino installation directory - see below
ARDUINO_DIR = C:/Arduino
ARDMK_DIR = path/to/mkfile
MONITOR_PORT = com3
BOARD_TAG = mega2560
```
**NOTE: Use forward slash not backslash and there should be no spaces or
special characters in the Windows paths (due to Win/Unix crossover). The paths
should not be *cygdrive* paths.**
On Windows (using MSYS and PuTTY), you might want to set the following extra parameters:
```make
MONITOR_CMD = putty
MONITOR_PARMS = 8,1,n,N
MONITOR_PARAMS = 8,1,n,N
```
On Arduino 1.5+ installs, you should set the architecture to either `avr` or `sam` and if using a submenu CPU type, then also set that:
```make
ARCHITECTURE = avr
ARCHITECTURE = avr
BOARD_TAG = atmegang
BOARD_SUB = atmega168
```
It is recommended in Windows that you create a symbolic link to avoid problems with file naming conventions on Windows. For example, if your your Arduino directory is in:
#### Symbolic Link
c:\Program Files (x86)\Arduino
It is recommended in Windows that you create a symbolic link to avoid problems with file naming conventions on Windows; unless one installs to a non-default location. For example, if your your Arduino directory is in:
C:\Program Files (x86)\Arduino
You will get problems with the special characters on the directory name. More details about this can be found in [issue #94](https://github.com/sudar/Arduino-Makefile/issues/94)
To create a symbolic link, you can use the command “mklink” on Windows, e.g.
```sh
mklink /d c:\Arduino c:\Program Files (x86)\Arduino
mklink /d C:\Arduino C:\Program Files (x86)\Arduino
```
Alternatively if you've setup Cygwin hard symbolic links ([CYGWIN=winsymlinks:native](https://www.cygwin.com/cygwin-ug-net/using-cygwinenv.html)):
```sh
ln -s /cygdrive/c/Program Files\ \(x86\)/Arduino/ C:/Arduino
```
After which, the variables should be:
```make
ARDUINO_DIR=../../../../../Arduino
ARDUINO_DIR=C:/Arduino
```
Instead of:
```make
ARDUINO_DIR=../../../../../Program\ Files\ \(x86\)/Arduino
ARDUINO_DIR=C:/Program\ Files\ \(x86\)/Arduino
```
Usefull Variables:
### Useful Variables
The list of all variables that can be overridden is available at [arduino-mk-vars.md](arduino-mk-vars.md) file.
- `BOARD_TAG` - Type of board, for a list see boards.txt or `make show_boards`
- `MONITOR_PORT` - The port where your Arduino is plugged in, usually `/dev/ttyACM0` or `/dev/ttyUSB0` in Linux or Mac OS X and `com3`, `com4`, etc. in Windows.
- `ARDUINO_DIR` - Path to Arduino installation. In Cygwin in Windows this path must be
relative, not absolute (e.g. "../../arduino" and not "/c/cygwin/Arduino").
- `ARDMK_DIR` - Path where the `*.mk` are present. If you installed the package, then it is usually `/usr/share/arduino`
- `AVR_TOOLS_DIR` - Path where the avr tools chain binaries are present. If you are going to use the binaries that came with Arduino installation, then you don't have to set it. Otherwise set it realtive and not absolute.
- `ARDUINO_DIR` - Path to Arduino installation. Using Windows with Cygwin,
this path must use Unix / and not Windows \\ (eg "C:/Arduino" not
"C:\\Arduino).
- `ARDMK_DIR` - Path where the `*.mk` are present. If you installed the package, then it is usually `/usr/share/arduino`. On Windows, this should be a path without spaces and no special characters, it can be a *cygdrive* path if necessary and must use / not \\.
- `AVR_TOOLS_DIR` - Path where the avr tools chain binaries are present. If you are going to use the binaries that came with Arduino installation, then you don't have to set it. Otherwise set it relative and not absolute.
@ -266,7 +298,7 @@ The makefile can autodetect the libraries that are included from your sketch and
## avrdude
To upload compiled files, `avrdude` is used. This Makefile tries to find `avrdude` and it's config (`avrdude.conf`) below `ARDUINO_DIR`. If you like to use the one installed on your system instead of the one which came with Arduino, you can try to set the variables `AVRDUDE` and `AVRDUDE_CONF`. On a typical Linux system these could be set to
To upload compiled files, `avrdude` is used. This Makefile tries to find `avrdude` and its config (`avrdude.conf`) below `ARDUINO_DIR`. If you like to use the one installed on your system instead of the one which came with Arduino, you can try to set the variables `AVRDUDE` and `AVRDUDE_CONF`. On a typical Linux system these could be set to
```make
AVRDUDE = /usr/bin/avrdude
@ -287,6 +319,72 @@ See examples/BlinkOpenCM for example usage.
For large Robotis projects, [libmaple](https://github.com/Rhoban/Maple) may be more appropriate, as the OpenCM IDE uses a very old compiler release.
## Arduino ARM Boards
For Arduino boards using ARM architechure, specifically the Atmel SAM series
((SAM3X8E) Due; (SAMD21) Arduino M0 [Pro], Zero, MKR1000, Feather M0, etc.), first
install the board support package from the IDE or other distribution channels.
Define`ARDUINO_PACKAGE_DIR` as the root path containing the ARM support
package (the manufacturer folder) and the `BOARD_TAG` (see `make show_boards`
for help) within your project Makefile. Include 'Sam.mk' rather than
'Arduino.mk' at the end of your file - see examples/ZeroBlink,
examples/MZeroBlink and examples/DueBlink for example usage.
**Note**: The Arduino IDE does not install board support packages to
the base Arduino installation directory (the directory that will work with AVR
Makefiles). They are generally installed to a '.arduino15/packages' folder in
the users home directory. This is the reason for the new `ARDUINO_PACKAGE_DIR`
define. On Windows, the package directory is often in the user home directory
so advice is to create a symblic link to avoid slash/space in path problems.
You can also manually install support packages in your Sketchbook 'hardware'
folder, then define ARDUINO_PACKAGE_DIR as this path.
If using a SAM board from a manufacturer other than Arduino, one must still
install the Arduino board support as above (unless using externally defined
toolchain) and then define the location of the manufacturer board support core
using the ALTERNATIVE_CORE_PATH define. For example: `ALTERNATE_CORE_PATH =
$(ARDUINO_SKETCHBOOK)/hardware/sparkfun/samd`
The programing method will auto-detect based on the `BOARD_TAG` settings read
from boards.txt:
Programming using OpenOCD CMSIS-DAP with the Programming/debug USB is
currently supported (the same method used by the IDE), including burning
bootloaders. External CMSIS tools such as Atmel Ice will also work with this
method. Black Magic Probe (BMP) support is also included using GDB for both
uploading and debugging.
Native USB programing using Bossa (Due, Zero, MKR1000, Feather style bootloaders)
and avrdude (M0 bootloaders) is supported. The bootloaders on these devices
requires a double press of the reset button or open/closing the serial port at
1200 BAUD. The automatic entry of the bootloader is attempted using
`ard-reset-arduino` when using the general `make upload` target by polling
attached devices until the bootloader port re-attaches (same method as the
IDE). On Windows, the USB enumerates as differnt COM ports for the CDC Serial
and bootloader and these must be defined. On encountering problems, one can
manually enter the bootloader then upload using the `make raw_upload` target.
Note that the `make reset` target will enter the bootloader on these devices;
there is no way to reset over USB.
If using system installed tools, be aware that `openocd` and `bossa` were
orginally forked for Arduino support and system distributions may not be up
to date with merged changes. `bossa` must be version 1.7->. `openocd` should
work but there may be problems at run time
[ref](https://github.com/pda/arduino-zero-without-ide). Ideally, use the
support packaged version or compile and install the Arduino fork.
With the ARM chipset and using a CMSIS-DAP tool, on-device debugging is made available:
* `debug_init` and `debug` targets for on-device debugging using GDB. To use
this, one must start the GDB server with `make debug_init &`, followed by
connecting to the target with `make debug`. If using a Black Magic Probe,
one can just use `make debug`. At the moment, a system wide `arm-none-eabi-gdb` must be
installed as the one supplied with the Arduino toolchain
does not appear to work.
* Example usage: https://asciinema.org/a/Jarz7Pr3gD6mqaZvCACQBzqix
* See the examples/MZeroBlink Makefile for a commented example.
## Versioning
The current version of the makefile is `1.6.0`. You can find the full history in the [HISTORY.md](HISTORY.md) file
@ -306,9 +404,8 @@ Also checkout the [contribution guide](CONTRIBUTING.md) for more details.
If you are looking for ideas to work on, then check out the following TODO items or the [issue tracker](https://github.com/sudar/Arduino-Makefile/issues/).
## Limitations / Know Issues / TODO's
## Limitations / Known Issues / TODO's
- Doesn't support SAM boards yet.
- Since it doesn't do any pre processing like Arduino IDE, you have to declare all methods before you use them ([issue #59](https://github.com/sudar/Arduino-Makefile/issues/59))
- More than one .ino or .pde file is not supported yet ([issue #49](https://github.com/sudar/Arduino-Makefile/issues/49))
- When you compile for the first time, it builds all libs inside Arduino directory even if it is not needed. But while linking only the relevant files are linked. ([issue #29](https://github.com/sudar/Arduino-Makefile/issues/29)). Even Arduino IDE does the same thing though.
@ -402,6 +499,20 @@ all of the examples. The bootstrap script is primarily intended for use by a
continuous integration server, specifically Travis CI. It is not intended for
normal users.
## Makefile Generator and Project Initialisation
`ardmk-init` within the bin/ folder is a utility Python script to create a
Arduino-mk Makefile for a project and also has option to create a traditional *tree*
organization (src, lib, bin). It can be used as with commanline arguments or
prompted - see examples below (append `$ARDMK_DIR/bin/` to command if not on path):
* Run prompted within current working directory: `ardmk-init`
* Create Arduino Uno Makefile (useful within a library example): `ardmk-init -qb uno`
* Create boilerplate Arduino Uno project in current working directory of same
name: `ardmk-init -b uno --quiet --project`
* Create Arduino-mk nano Makefile in current working directory with template .ino: `ardmk-init -b nano -u atmega328 -qtn my-project`
* See `ardmk-init --help` for more.
### Bare-ArduinoProject
If you are planning on using this makefile in a larger/professional project, you might want to take a look at the [Bare-ArduinoProject](https://github.com/WeAreLeka/Bare-Arduino-Project) framework.

463
Sam.mk Normal file
View file

@ -0,0 +1,463 @@
########################################################################
#
# Support for Arduino Atmel SAM boards (sam and samd)
#
# You must install a SAM board hardware support package (such as Arduino Zero)
# to use this, then define ARDUINO_PACKAGE_DIR as the path to the root
# directory containing the support package.
#
# 2018 John Whittington @j_whittington
#
########################################################################
arduino_output =
# When output is not suppressed and we're in the top-level makefile,
# running for the first time (i.e., not after a restart after
# regenerating the dependency file), then output the configuration.
ifndef ARDUINO_QUIET
ifeq ($(MAKE_RESTARTS),)
ifeq ($(MAKELEVEL),0)
arduino_output = $(info $(1))
endif
endif
endif
ifndef ARDMK_DIR
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
endif
# include Common.mk now we know where it is
ifndef COMMON_INCLUDED
include $(ARDMK_DIR)/Common.mk
endif
ifneq ($(TEST),)
CORE_VER = 1.8.6
CMSIS_VER = 4.5.0
CMSIS_ATMEL_VER = 1.2.0
ALTERNATE_CORE_PATH = $(DEPENDENCIES_DIR)/samd
CMSIS_DIR = $(DEPENDENCIES_DIR)/CMSIS/CMSIS
CMSIS_ATMEL_DIR = $(DEPENDENCIES_DIR)/CMSIS-Atmel/CMSIS
ARM_TOOLS_DIR := $(basename $(basename $(firstword $(wildcard $(DEPENDENCIES_DIR)/gcc-arm-none-eabi*))))
endif
ifndef ARDUINO_PACKAGE_DIR
# attempt to find based on Linux, macOS and Windows default
ARDUINO_PACKAGE_DIR := $(firstword \
$(call dir_if_exists,$(HOME)/.arduino15/packages) \
$(call dir_if_exists,$(ARDUINO_DIR)/packages) \
$(call dir_if_exists,$(HOME)/Library/Arduino15/packages) \
$(call dir_if_exists,$(USERPROFILE)/AppData/Local/Arduino15/packages) )
$(call show_config_variable,ARDUINO_PACKAGE_DIR,[AUTODETECTED],(from DEFAULT))
else
$(call show_config_variable,ARDUINO_PACKAGE_DIR,[USER])
endif
ifndef ARDMK_VENDOR
ARDMK_VENDOR := arduino
endif
ifndef ARCHITECTURE
ARCHITECTURE := samd
endif
ifndef CORE_VER
CORE_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)/1.*)
ifneq ($(CORE_VER),)
CORE_VER := $(shell basename $(CORE_VER))
$(call show_config_variable,CORE_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
endif
else
$(call show_config_variable,CORE_VER,[USER])
endif
ifndef CMSIS_VER
CMSIS_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS/4.*)
ifneq ($(CMSIS_VER),)
CMSIS_VER := $(shell basename $(CMSIS_VER))
$(call show_config_variable,CMSIS_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
endif
else
$(call show_config_variable,CMSIS_VER,[USER])
endif
ifndef CMSIS_ATMEL_VER
CMSIS_ATMEL_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS-Atmel/1.*)
ifneq ($(CMSIS_ATMEL_VER),)
CMSIS_ATMEL_VER := $(shell basename $(CMSIS_ATMEL_VER))
$(call show_config_variable,CMSIS_ATMEL_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
endif
else
$(call show_config_variable,CMSIS_ATMEL_VER,[USER])
endif
ifndef CMSIS_DIR
ifeq ($(findstring samd, $(strip $(ARCHITECTURE))), samd)
CMSIS_DIR := $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS/$(CMSIS_VER)/CMSIS
else
CMSIS_DIR = $(ALTERNATE_CORE_PATH)/system/CMSIS/CMSIS
endif
$(call show_config_variable,CMSIS_DIR,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
else
$(call show_config_variable,CMSIS_DIR,[USER])
endif
ifndef CMSIS_ATMEL_DIR
ifeq ($(findstring samd, $(strip $(ARCHITECTURE))), samd)
CMSIS_ATMEL_DIR := $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS-Atmel/$(CMSIS_ATMEL_VER)/CMSIS
else
CMSIS_ATMEL_DIR = $(ALTERNATE_CORE_PATH)/system/CMSIS
endif
$(call show_config_variable,CMSIS_ATMEL_DIR,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
else
$(call show_config_variable,CMSIS_ATMEL_DIR,[USER])
endif
# Arduino Settings (will get shown in Arduino.mk as computed)
ifndef ALTERNATE_CORE_PATH
ifdef CORE_VER
ALTERNATE_CORE_PATH = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)/$(CORE_VER)
else
ALTERNATE_CORE_PATH = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)
endif
endif
ifndef ARDUINO_CORE_PATH
ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/arduino
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt
endif
# Check boards file exists before continuing as parsing non-existant file can create problems
ifneq ($(findstring boards.txt, $(wildcard $(ALTERNATE_CORE_PATH)/*.txt)), boards.txt)
echo $(error $(CORE_VER) Cannot find boards file $(BOARDS_TXT). Check ARDUINO_PACKAGE_DIR path: $(ARDUINO_PACKAGE_DIR) and board support installed)
endif
# add CMSIS includes
CPPFLAGS += -I$(CMSIS_DIR)/Include/
CPPFLAGS += -I$(CMSIS_ATMEL_DIR)/Device/ATMEL
# path for Cortex library
LIB_PATH = $(CMSIS_DIR)/Lib/GCC
BOOTLOADER_PARENT = $(ALTERNATE_CORE_PATH)/bootloaders
ifndef VARIANT
VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.variant)
ifndef VARIANT
VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),build.variant)
endif
endif
# grab any sources in the variant core path (variant.cpp defines pin/port mapping on SAM devices)
ifndef SAM_CORE_PATH
SAM_CORE_PATH := $(ALTERNATE_CORE_PATH)/variants/$(VARIANT)
endif
SAM_CORE_C_SRCS := $(wildcard $(SAM_CORE_PATH)/*.c)
SAM_CORE_CPP_SRCS := $(wildcard $(SAM_CORE_PATH)/*.cpp)
SAM_CORE_S_SRCS := $(wildcard $(SAM_CORE_PATH)/*.S)
# due/sam specific paths hard define chip type for SystemInit function in system_CHIP.c as not included in core like samd
ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due)
ifndef SAM_SYSTEM_PATH
SAM_SYSTEM_PATH := $(CMSIS_ATMEL_DIR)/Device/ATMEL/sam3xa
endif
ifndef SAM_LIBSAM_PATH
SAM_LIBSAM_PATH := $(ALTERNATE_CORE_PATH)/system/libsam
endif
CPPFLAGS += -I$(SAM_SYSTEM_PATH)/include
CPPFLAGS += -I$(SAM_LIBSAM_PATH)
CPPFLAGS += -I$(SAM_LIBSAM_PATH)/include
SAM_CORE_C_SRCS += $(wildcard $(SAM_LIBSAM_PATH)/source/*.c)
SAM_CORE_C_SRCS += $(wildcard $(SAM_SYSTEM_PATH)/source/*.c)
endif
# define plaform lib dir from Arduino ARM support
ifndef ARDUINO_PLATFORM_LIB_PATH
ARDUINO_PLATFORM_LIB_PATH := $(ALTERNATE_CORE_PATH)/libraries
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_PACKAGE_DIR))
endif
########################################################################
# command names
TOOL_PREFIX = arm-none-eabi
# Use arm-toolchain from Arduino package install if exists and user has not defined global version
# if undefined, AVR_TOOLS_DIR will resolve in Arduino.mk as a last resort as Arduino now installs with arm-gcc
ifndef ARM_TOOLS_DIR
ifndef ARM_TOOLS_VER
ARM_TOOLS_VER := $(shell basename $(lastword $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/*)))
endif
ARM_TOOLS_DIR = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/$(ARM_TOOLS_VER)
ifdef ARM_TOOLS_DIR
$(call show_config_variable,ARM_TOOLS_DIR,[COMPUTED],(from ARDUINO_PACKAGE_DIR))
endif
else
$(call show_config_variable,ARM_TOOLS_DIR,[USER])
endif
ifndef GDB_NAME
GDB_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gdb)
ifndef GDB_NAME
GDB_NAME := $(TOOL_PREFIX)-gdb
else
$(call show_config_variable,GDB_NAME,[COMPUTED])
endif
endif
ifndef UPLOAD_TOOL
UPLOAD_TOOL := $(call PARSE_BOARD,$(BOARD_TAG),upload.tool)
ifndef UPLOAD_TOOL
UPLOAD_TOOL := openocd
else
$(call show_config_variable,UPLOAD_TOOL,[COMPUTED])
endif
endif
ifndef BOOTLOADER_UPLOAD_TOOL
BOOTLOADER_UPLOAD_TOOL := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.tool)
ifndef BOOTLOADER_UPLOAD_TOOL
BOOTLOADER_UPLOAD_TOOL := openocd
else
$(call show_config_variable,BOOTLOADER_UPLOAD_TOOL,[COMPUTED])
endif
endif
# processor stuff
ifndef MCU
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
endif
ifndef MCU_FLAG_NAME
MCU_FLAG_NAME=mcpu
endif
# native port emulates an AVR chip to use AVRDUDE
ifndef AVRDUDE_MCU
AVRDUDE_MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.emu.mcu)
endif
# GDP settings
ifndef GDB_PORT
# default to localhost default OpenOCD port
GDB_PORT = localhost:3333
endif
ifndef GDB_OPTS
# if using BMP do a scan and attach
ifeq ($(findstring /dev/tty, $(strip $(GDB_PORT))), /dev/tty)
GDB_OPTS = -ex "target extended-remote $(GDB_PORT)" -ex "monitor swdp_scan" -ex "attach 1" -ex "load" -d $(OBJDIR) $(TARGET_ELF)
else
GDB_OPTS = -ex "target extended-remote $(GDB_PORT)" -ex "load" -d $(OBJDIR) $(TARGET_ELF)
endif
endif
ifndef GDB_UPLOAD_OPTS
GDB_UPLOAD_OPTS = $(GDB_OPTS) -ex "set confirm off" -ex "set target-async off" -ex "set remotetimeout 30" -ex "detach" -ex "kill" -ex "quit"
endif
########################################################################
# OpenOCD for SAM devices
ifndef OPENOCD
BUNDLED_OPENOCD_DIR := $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/openocd)
# Try Arduino support package first
ifdef BUNDLED_OPENOCD_DIR
ifndef OPENOCD_VER
OPENOCD_VER := $(shell basename $(lastword $(wildcard $(BUNDLED_OPENOCD_DIR)/*)))
endif
OPENOCD = $(BUNDLED_OPENOCD_DIR)/$(OPENOCD_VER)/bin/openocd -s $(BUNDLED_OPENOCD_DIR)/$(OPENOCD_VER)/share/openocd/scripts/
$(call show_config_variable,OPENOCD,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
else
# Otherwise look on user path
OPENOCD := $(shell which openocd 2>/dev/null)
ifdef OPENOCD
$(call show_config_variable,OPENOCD,[AUTODETECTED],(found in $$PATH))
endif
endif
else
$(call show_config_variable,OPENOCD,[USER])
endif
ifndef OPENOCD_OPTS
OPENOCD_OPTS += -d2 -f $(ALTERNATE_CORE_PATH)/variants/$(VARIANT)/$(OPENOCD_SCRIPT)
endif
########################################################################
# Bossa for SAM devices
ifndef BOSSA
BUNDLED_BOSSA_DIR := $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/bossac)
# Try Arduino support package first
ifdef BUNDLED_BOSSA_DIR
ifndef BOSSA_VER
BOSSA_VER := $(shell basename $(lastword $(wildcard $(BUNDLED_BOSSA_DIR)/*)))
endif
BOSSA = $(BUNDLED_BOSSA_DIR)/$(BOSSA_VER)/bossac
$(call show_config_variable,BOSSA,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
else
# Otherwise look on user path
BOSSA := $(shell which bossac 2>/dev/null)
ifdef BOSSA
$(call show_config_variable,BOSSA,[AUTODETECTED],(found in $$PATH))
endif
endif
else
$(call show_config_variable,BOSSA,[USER])
endif
ifndef BOSSA_OPTS
BOSSA_OPTS += -d --info --erase --write --verify --reset
# Arduino Due forces RS-232 mode and boots from flash
ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due)
BOSSA_OPTS += -U false -b
endif
endif
get_bootloader = $(shell $(RESET_CMD) | tail -1)
# if not bootloader port defined (ISP_PORT), automatically grab first port after reset
# if not on windows
ifndef ISP_PORT
ifeq ($(CURRENT_OS), WINDOWS)
BOSSA_OPTS += --port=$(COM_STYLE_MONITOR_PORT)
else
BOSSA_OPTS += --port=$(notdir $(call get_monitor_port))
endif
else
BOSSA_OPTS += --port=$(ISP_PORT)
endif
########################################################################
# EXECUTABLES
# Define them here to use ARM_TOOLS_PATH and allow auto finding of AVR_TOOLS_PATH
AVR_TOOLS_DIR := $(ARM_TOOLS_DIR)
#GDB = $(ARM_TOOLS_PATH)/$(GDB_NAME)
# Use system gdb for now as Arduino supplied has lib error?
GDB = $(GDB_NAME)
########################################################################
# FLAGS
ifndef USB_TYPE
USB_TYPE = USBCON
endif
ifndef USB_PRODUCT
USB_PRODUCT := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_product)
ifdef USB_PRODUCT
$(call show_config_variable,USB_PRODUCT,[COMPUTED])
endif
endif
ifndef USB_MANUFACTURER
USB_MANUFACTURER := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_manufacturer)
ifndef USB_MANUFACTURER
USB_MANUFACTURER = "Unknown"
else
$(call show_config_variable,USB_MANUFACTURER,[COMPUTED])
endif
endif
ifndef USB_VID
USB_VID := $(call PARSE_BOARD,$(BOARD_TAG),build.vid)
ifdef USB_VID
$(call show_config_variable,USB_VID,[COMPUTED])
endif
endif
ifndef USB_PID
USB_PID := $(call PARSE_BOARD,$(BOARD_TAG),build.pid)
ifdef USB_PID
$(call show_config_variable,USB_PID,[COMPUTED])
endif
endif
# Bootloader settings
ifndef BOOTLOADER_SIZE
BOOTLOADER_SIZE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.size)
ifndef BOOTLOADER_SIZE
BOOTLOADER_SIZE := 0x2000
else
$(call show_config_variable,BOOTLOADER_SIZE,[COMPUTED])
endif
endif
ifndef BOOTLOADER_UNPROTECT
BOOTLOADER_UNPROTECT := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.cmd_unprotect)
ifndef BOOTLOADER_UNPROTECT
BOOTLOADER_UNPROTECT := at91samd bootloader 0
else
$(call show_config_variable,BOOTLOADER_UNPROTECT,[COMPUTED])
endif
endif
ifndef BOOTLOADER_PROTECT
BOOTLOADER_PROTECT := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.cmd_protect)
ifndef BOOTLOADER_PROTECT
BOOTLOADER_PROTECT := at91samd bootloader 16384
else
$(call show_config_variable,BOOTLOADER_PROTECT,[COMPUTED])
endif
endif
ifndef BOOTLOADER_PROTECT_VERIFY
BOOTLOADER_PROTECT_VERIFY := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.cmd_protect_verify)
ifndef BOOTLOADER_PROTECT_VERIFY
BOOTLOADER_PROTECT_VERIFY := at91samd bootloader
else
$(call show_config_variable,BOOTLOADER_PROTECT_VERIFY,[COMPUTED])
endif
endif
CFLAGS_STD += -std=gnu11
CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)'
# Get extra define flags from boards.txt
EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP_CMD) -oE '(-D)\w+')
# Strip only defines from extra flags as boards file appends user {build.usb}
CPPFLAGS += $(EXFLAGS)
CPPFLAGS += -DUSB_VID=$(USB_VID)
CPPFLAGS += -DUSB_PID=$(USB_PID)
# Cortex compiler flags
CPPFLAGS += -mthumb -nostdlib --param max-inline-insns-single=500 -fno-exceptions -Wl,-Map=$(OBJDIR)/$(TARGET).map
CXXFLAGS += -fno-rtti -fno-threadsafe-statics -std=gnu++11
ifndef SIZEFLAGS
SIZEFLAGS += -B
endif
AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
BOARD_LINKER_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG),build.ldscript)
OPENOCD_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG),build.openocdscript)
LINKER_SCRIPTS := -T$(ALTERNATE_CORE_PATH)/variants/$(VARIANT)/$(BOARD_LINKER_SCRIPT)
OTHER_LIBS := $(call PARSE_BOARD,$(BOARD_TAG),build.flags.libs)
# Due and SAMD boards have different flags/chip specific libs
ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due)
CPPFLAGS += -Dprintf=iprintf -DARDUINO_SAM_DUE
LDFLAGS += -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
LDFLAGS += -L$(LIB_PATH) -lm # -larm_cortexM3l_math # IDE doesn't include Cortex-M3 math lib on Due for some reason
OTHER_LIBS += $(ALTERNATE_CORE_PATH)/variants/$(VARIANT)/libsam_sam3x8e_gcc_rel.a
else
LDFLAGS += --specs=nano.specs --specs=nosys.specs -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group
LDFLAGS += -larm_cortexM0l_math -L$(LIB_PATH) -lm
endif
# OpenOCD reset command only for now
ifeq ($(strip $(UPLOAD_TOOL)), openocd)
RESET_CMD = $(OPENOCD) $(OPENOCD_OPTS) -c "telnet_port disabled; init; targets; reset run; shutdown"
else
# Set zero flag for ard-reset for 1200 baud boot to bootloader
ARD_RESET_OPTS += --zero
endif
########################################################################
# automatially include Arduino.mk for the user
$(call show_separator)
$(call arduino_output,Arduino.mk Configuration:)
include $(ARDMK_DIR)/Arduino.mk
print-% : ; @echo $* = $($*)

126
Teensy.mk
View file

@ -38,25 +38,19 @@ ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt
ifndef PARSE_TEENSY
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_TEENSY = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
endif
ifndef F_CPU
ifndef BOARD_SUB
SPEEDS := $(call PARSE_TEENSY,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies.
SPEEDS := $(call PARSE_BOARD,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies.
SPEEDS := $(shell printf "%d\n" $(SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works.
F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed.
#$(info "speeds is " $(SPEEDS)) # Good for debugging
else
F_CPU := $(call PARSE_TEENSY,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
endif
endif
# if boards.txt gets modified, look there, else hard code it
ARCHITECTURE = $(call PARSE_TEENSY,$(BOARD_TAG),build.architecture)
ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
ifeq ($(strip $(ARCHITECTURE)),)
ARCHITECTURE = arm
endif
@ -72,81 +66,11 @@ endif
########################################################################
# command names
ifndef CC_NAME
CC_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.gcc)
ifndef CC_NAME
CC_NAME := arm-none-eabi-gcc
else
$(call show_config_variable,CC_NAME,[COMPUTED])
endif
endif
ifndef CXX_NAME
CXX_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.g++)
ifndef CXX_NAME
CXX_NAME := arm-none-eabi-g++
else
$(call show_config_variable,CXX_NAME,[COMPUTED])
endif
endif
ifndef AS_NAME
AS_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.as)
ifndef AS_NAME
AS_NAME := arm-none-eabi-gcc-as
else
$(call show_config_variable,AS_NAME,[COMPUTED])
endif
endif
ifndef OBJCOPY_NAME
OBJCOPY_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.objcopy)
ifndef OBJCOPY_NAME
OBJCOPY_NAME := arm-none-eabi-objcopy
else
$(call show_config_variable,OBJCOPY_NAME,[COMPUTED])
endif
endif
ifndef OBJDUMP_NAME
OBJDUMP_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.objdump)
ifndef OBJDUMP_NAME
OBJDUMP_NAME := arm-none-eabi-objdump
else
$(call show_config_variable,OBJDUMP_NAME,[COMPUTED])
endif
endif
ifndef AR_NAME
AR_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.ar)
ifndef AR_NAME
AR_NAME := arm-none-eabi-ar
else
$(call show_config_variable,AR_NAME,[COMPUTED])
endif
endif
ifndef SIZE_NAME
SIZE_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.size)
ifndef SIZE_NAME
SIZE_NAME := arm-none-eabi-size
else
$(call show_config_variable,SIZE_NAME,[COMPUTED])
endif
endif
ifndef NM_NAME
NM_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.nm)
ifndef NM_NAME
NM_NAME := arm-none-eabi-gcc-nm
else
$(call show_config_variable,NM_NAME,[COMPUTED])
endif
endif
TOOL_PREFIX = arm-none-eabi
# processor stuff
ifndef MCU
MCU := $(call PARSE_TEENSY,$(BOARD_TAG),build.cpu)
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
endif
ifndef MCU_FLAG_NAME
@ -161,39 +85,39 @@ endif
CPPFLAGS += -DLAYOUT_US_ENGLISH -D$(USB_TYPE)
CPPFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.option)
CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.gnu0x)","true")
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
CXXFLAGS_STD += -std=gnu++0x
endif
ifeq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.elide_constructors)", "true")
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
CXXFLAGS += -felide-constructors
endif
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpp)
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpp)
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common)
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs)
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.S)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.S)
LDFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
LDFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
AMCU := $(call PARSE_TEENSY,$(BOARD_TAG),build.mcu)
AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
LDFLAGS += -Wl,--gc-sections,--relax
LINKER_SCRIPTS = -T${ARDUINO_CORE_PATH}/${AMCU}.ld
OTHER_LIBS = $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.libs)
LINKER_SCRIPTS ?= -T${ARDUINO_CORE_PATH}/${AMCU}.ld
OTHER_LIBS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.libs)
CPUFLAGS = $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
CPUFLAGS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
# usually defined as per teensy31.build.mcu=mk20dx256 but that isn't valid switch
MCU := $(shell echo ${CPUFLAGS} | sed -n -e 's/.*-mcpu=\([a-zA-Z0-9_-]*\).*/\1/p')

60
ardmk-init.1 Normal file
View file

@ -0,0 +1,60 @@
.TH ARDMK-INIT "1" "Nov 2017" "ardmk-init" "Arduino Makefile Generator"
.SH NAME
ardmk-init - Generate Arduino Makefile environments
.SH SYNOPSIS
.B ardmk-init
[OPTION]...
.SH OPTIONS
.B \-v, \-\-verbose
Print file contents during creation.
.B \-d, \-\-directory
Directory to run generator.
.B \-b, \-\-board
Board tag.
.B \-u, \-\-micro
Microcontroller on board.
.B \-f, \-\-freq
Clock frequency.
.B \-p, \-\-port
Monitor port.
.B \-n, \-\-name
Project name.
.B \-\-cli
Run with user prompts rather than arguments.
.B \-p, \-\-project
Create boilerplate project with src, lib and bin folder structure.
.B \-t, \-\-template
Create bare minimum Arduino source file.
.SH DESCRIPTION
Creates a Makefile and project tree structure from templates.
.SH EXAMPLE
ardmk-init -b uno # create Arduino uno Makefile
.PP
ardmk-init --cli # run with user prompts
.PP
ardmk-init --board uno --project --template --name my-project # create Arduino uno project and template with name "my-project"
.SH BUGS
Problems may reported on the github project page at:
.PP
https://github.com/sudar/Arduino-Makefile
.SH AUTHOR
John Whittington, git@jbrengineering.co.uk
.SH LICENSE
This is under MIT license.

View file

@ -11,6 +11,8 @@ The following are the different variables that can be overwritten in the user ma
* [Avrdude setting variables](#avrdude-setting-variables)
* [Bootloader variables](#bootloader-variables)
* [ChipKIT variables](#chipkit-variables)
* [ARM variables](#arm-variables)
* [Ctags variables](#ctags-variables)
## Global variables
@ -72,6 +74,48 @@ AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr
----
### ARM_TOOLS_DIR
**Description:**
Directory where the arm toolchain is installed. `arm-none-eabi-*` should be
within a /bin subdirectory.
Can usually be detected from `$ARDUINO_PACKAGE_DIR` /tools subdirectory when ARM
device support is installed.
**Example:**
```Makefile
ARM_TOOLS_DIR = /usr
# or
ARM_TOOLS_DIR =
/usr/share/arduino/hardware/tools/arm-none-eabi-gcc/VERSION
```
**Requirement:** *Optional*
----
### ARM_TOOLS_VER
**Description:**
Sub-directory where the arm toolchain is installed - usually the tool version.
Can usually be detected from `$ARDUINO_PACKAGE_DIR` /tools subdirectory when ARM
device support is installed. Will resolve latest version if multiple found.
**Example:**
```Makefile
ARM_TOOLS_VER = 7-2017q4
```
**Requirement:** *Optional*
----
### RESET_CMD
**Description:**
@ -90,6 +134,38 @@ RESET_CMD = $(HOME)/gertduino/reset
----
### PYTHON_CMD
**Description:**
Path to Python binary. Requires pyserial module installed. Makefile will error if unable to auto-find as utility scripts will not work. To override this, give it an empty define.
**Example:**
```Makefile
PYTHON_CMD = /usr/bin/python3
```
**Requirement:** *Optional*
----
### GREP_CMD
**Description:**
Path to GNU grep binary. Only added for macOS, which has BSD grep by default but results in some parsing warnings. macOS users should install GNU grep using Homebrew.
**Example:**
```Makefile
GREP_CMD = /bin/grep
```
**Requirement:** *Optional*
----
## Arduino IDE variables
### ARDUINO_DIR
@ -113,6 +189,27 @@ ARDUINO_DIR = /Applications/Arduino.app/Contents/Java
----
### ARDUINO_PACKAGE_DIR
**Description:**
Directory where the Arduino package support files are stored. Can auto-detect based on default OS IDE locations.
**Example:**
```Makefile
# Linux
ARDUINO_PACKAGE_DIR = $(HOME)/.arduino15/packages
# Mac OS X
ARDUINO_PACKAGE_DIR = $(HOME)/Library/Arduino15/packages
# Windows
ARDUINO_PACKAGE_DIR = $(USERPROFILE)/AppData/Local/Arduino15/packages
```
**Requirement:** *Optional*
----
### ARDUINO_PLATFORM_LIB_PATH
**Description:**
@ -154,12 +251,13 @@ ARDUINO_VERSION = 105
Architecture for Arduino 1.5+
Defaults to unset for 1.0 or `avr` for 1.5+
Defaults to unset for 1.0 or `avr` for 1.5+. This value is not literally the chip architecture but will often be
the chip series within a vendor's 'hardware' folder. For example, will default to `samd` if using Sam.mk.
**Example:**
```Makefile
ARCHITECTURE = sam
ARCHITECTURE = arm
```
**Requirement:** *Optional*
@ -170,9 +268,9 @@ ARCHITECTURE = sam
**Description:**
Board vendor/maintainer.
Board vendor/maintainer/series.
Defaults to `arduino`
Defaults to `arduino`.
**Example:**
@ -297,6 +395,33 @@ BOARD_SUB=atmega168
----
### BOARD_CLOCK
**Description:**
Allow selection of f_cpu and fuses specified in `boards.txt` as `{BOARD_TAG}.menu.clock.{BOARD_CLOCK}`.
This works for microprocessor board definitions like ATtiny that specify not only the clock speed but fuse settings as clock overrides.
It also works for f_cpu values specified in `boards.txt` as `{BOARD_TAG}.menu.speed.{BOARD_CLOCK}`.
For example, the Watterott ATmega328PB library [https://github.com/watterott/ATmega328PB-Testing](https://github.com/watterott/ATmega328PB-Testing).
**Example:**
```Makefile
# Select external 16 MHz clock
BOARD_CLOCK=external16
```
**Example:**
```Makefile
# Select 20MHz speed
BOARD_CLOCK=20mhz
```
**Requirement:** *Optional to override main board f_cpu and/or fuse settings.*
----
### MONITOR_PORT
**Description:**
@ -458,6 +583,26 @@ CORE = tiny
----
### BOARD
**Description:**
Board identifier that passes to a compile option as -DARDUINO_$(BOARD).
Usually can be auto-detected as `build.board` from `boards.txt`.
If not found build.board entry, use upper-case converted "$(ARCHITECTURE)_$(BOARD_TAG)".
**Example:**
```Makefile
BOARD = AVR_LEONARD
```
**Requirement:** *Optional*
----
### VARIANT
**Description:**
@ -657,7 +802,8 @@ ISP_PROG = stk500v1
**Description:**
Device path to ArduinoISP. Not needed for hardware ISP's.
Device path to ArduinoISP. Not needed for hardware ISP's. Also used to define
bootloader port on SAMD devices.
**Example:**
@ -762,6 +908,37 @@ CC_NAME = pic32-gcc
----
## Compiler/Executable variables
### TOOL_PREFIX
**Description:**
The tool prefix, which gets prepended to the tools like $(TOOL_PREFIX)-gcc, $(TOOL_PREFIX)-g++, etc.
The following tools will be prefixed with '$(TOOL_PREFIX)-':
* gcc
* g++
* as
* objcopy
* objdump
* ar
* size
* nm
Defaults to `avr`
**Example:**
```Makefile
TOOL_PREFIX = arm-none-eabi
TOOL_PREFIX = pic32
```
**Requirement:** *Optional*
----
### CXX_NAME
**Description:**
@ -870,6 +1047,18 @@ NM_NAME = pic32-nm
----
### GDB_NAME
**Description:**
GDB utility.
Defaults to `arm-none-eabi-gdb`
**Requirement:** *Optional*
----
### OPTIMIZATION_LEVEL
**Description:**
@ -912,7 +1101,7 @@ OTHER_LIBS = -lsomeplatformlib
Controls, *exclusively*, which C standard is to be used for compilation.
Defaults to `undefined` on 1.0.x or `-std=gnu11 -flto -fno-fat-lto-objects` on 1.5+ or if you install AVR toolchain > 4.9.0
Defaults to `undefined` on 1.0.x or `-std=gnu11` on 1.5+ or if you install AVR toolchain > 4.9.0
Possible values:
@ -927,14 +1116,14 @@ Possible values:
* `-std=c11`
* `-std=gnu89`
* `-std=gnu99`
* `-std=gnu11 -flto -fno-fat-lto-objects` - This is the default for C code
* `-std=gnu11` - This is the default for C code
For more information, please refer to the [Options Controlling C Dialect](https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html)
**Example:**
```Makefile
CFLAGS_STD = = -std=gnu89
CFLAGS_STD = -std=gnu89
```
**Requirement:** *Optional*
@ -947,7 +1136,7 @@ CFLAGS_STD = = -std=gnu89
Controls, *exclusively*, which C++ standard is to be used for compilation.
Defaults to `undefined` on 1.0 or `-std=gnu++11 -fno-threadsafe-statics -flto` on AVR toolchain > 4.9.0 (e.g. IDE 1.6.10+)
Defaults to `undefined` on 1.0 or `-std=gnu++11` on AVR toolchain > 4.9.0 (e.g. IDE 1.6.10+)
Possible values:
@ -964,7 +1153,7 @@ Possible values:
* `-std=c++1y`
* `-std=c++14`
* `-std=gnu++98`
* `-std=gnu++11 -fno-threadsafe-statics -flto` - This is the default for C++ code
* `-std=gnu++11` - This is the default for C++ code
* `-std=gnu++1y`
* `-std=gnu++14`
@ -973,7 +1162,7 @@ For more information, please refer to the [Options Controlling C Dialect](https:
**Example:**
```Makefile
CXXFLAGS_STD = = -std=gnu++98
CXXFLAGS_STD = -std=gnu++98
```
**Requirement:** *Optional*
@ -987,7 +1176,7 @@ CXXFLAGS_STD = = -std=gnu++98
Flags passed to compiler for files compiled as C. Add more flags to this
variable using `+=`.
Defaults to all flags required for a typical build.
Defaults to `undefined` on 1.0 or `-flto -fno-fat-lto-objects -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN)` on AVR toolchain > 4.9.0 (e.g. IDE 1.6.10+)
**Example:**
@ -1006,7 +1195,9 @@ CFLAGS += -my-c-only-flag
Flags passed to the compiler for files compiled as C++. Add more flags to this
variable using `+=`.
Defaults to `-fpermissive -fno-exceptions`
Defaults to `-fpermissive -fno-exceptions` on 1.0
or `-fpermissive -fno-exceptions -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color`
on AVR toolchain > 4.9.0 (e.g. IDE 1.6.10+)
**Example:**
@ -1018,6 +1209,30 @@ CXXFLAGS += -my-c++-onlyflag
----
### DIAGNOSTICS_COLOR_WHEN
**Description:**
This variable controls the compiler's diagnostics-color setting, as defined
in CFLAGS or CXXFLAGS, on AVR toolchain > 4.9.0.
Supported values are: `always`, `never` and `auto`.
For more details, see: [Options to Control Diagnostic Messages Formatting]
(https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Language-Independent-Options.html#Language-Independent-Options)
Defaults to `always`.
**Example:**
```Makefile
DIAGNOSTICS_COLOR_WHEN = never
# or
DIAGNOSTICS_COLOR_WHEN = auto
```
**Requirement:** *Optional*
----
### ASFLAGS
**Description:**
@ -1041,7 +1256,7 @@ ASFLAGS += -my-as-only-flag
**Description:**
Flags passed to the C pre-processor (for C, C++ and assembly source flies). Add
Flags passed to the C pre-processor (for C, C++ and assembly source files). Add
more flags to this variable using `+=`.
Defaults to all flags required for a typical build.
@ -1060,14 +1275,27 @@ CPPFLAGS += -DMY_DEFINE_FOR_ALL_SOURCE_TYPES
**Description:**
Override the default build tools.
Override the default build tool paths and names.
If set to `1`, each tool (`CC`, `CXX`, `AS`, `OBJCOPY`, `OBJDUMP`, `AR`, `SIZE`, `NM`) must have its path explicitly defined. See `chipKIT.mk`.
If OVERRIDE_EXECUTABLES is defined, all tools (`CC`, `CXX`, `AS`,
`OBJCOPY`, `OBJDUMP`, `AR`, `SIZE`, `NM`) must have their paths
explicitly defined. This may be used in the rare case where
overriding a path and/or executable name is required.
The "?=" assignment cannot be used because the executable tags
are already implicitly defined by Make (e.g. $(CC) == cc).
**Example:**
```Makefile
OVERRIDE_EXECUTABLES = 1
CC = /usr/bin/avr-gcc
CXX = /usr/bin/avr-g++
AS = /usr/bin/avr-as
OBJCOPY = /usr/bin/avr-objcopy
OBJDUMP = /usr/bin/avr-objdump
AR = /usr/bin/avr-ar
SIZE = /some_path/alternative_avr-size
NM = /some_path/alternative_avr-nm
```
**Requirement:** *Optional*
@ -1092,6 +1320,24 @@ MONITOR_CMD = minicom
----
### MONITOR_PARAMS
**Description:**
Additional parameters for the putty -sercfg command line argument.
Interpreted as a comma-separated list of configuration options.
**Example:**
```Makefile
MONITOR_PARAMS = 8,1,n,N
```
**Requirement:** *Optional*
----
### PRE_BUILD_HOOK
**Description:**
@ -1151,6 +1397,24 @@ AVRDUDE_CONF = /usr/share/arduino/hardware/tools/avrdude.conf
----
### AVRDUDE_AUTOERASE_FLASH
**Description:**
Enable autoerase flash.
By default disabled.
**Example:**
```Makefile
AVRDUDE_AUTOERASE_FLASH = yes
```
**Requirement:** *Optional*
----
### AVR_TOOLS_PATH
**Description:**
@ -1226,6 +1490,54 @@ ALTERNATE_CORE_PATH = $(HOME)/sketchbook/hardware/arduino-tiny/cores/tiny
----
### CORE_VER
**Description:**
Alternate core release version. The Arduino board support packages are within
a sub-directory indicated by this define.
Defaults to package current release.
**Example:**
```Makefile
CORE_VER = 1.6.17
```
**Requirement:** *Optional*
----
### CMSIS_DIR
**Description:**
Path to ARM CMSIS. Normally installed as part of ARM board support.
Defaults to `ARDUINO_PACKAGE_DIR/tools/CMSIS/4.5.0/CMSIS`
**Example:**
```Makefile
CMSIS_DIR = /usr/share/CMSIS
```
**Requirement:** *Optional*
----
### CMSIS_ATMEL_DIR
**Description:**
Path to CMSIS-Atmel directory. Installed with ARM support package.
Defaults to `ARDUINO_PACKAGE_DIR/tools/CMSIS-Atmel/1.1.0/CMSIS`
**Requirement:** *Optional*
----
### BOARDS_TXT
**Description:**
@ -1382,6 +1694,67 @@ Would result in an absolute path to the bootloader hex file of `$(HOME)/sketchbo
----
### BOOTLOADER_SIZE
**Description:**
Size of bootloader on ARM devices, ensures correct start address when flashing
application area. Normally parsed from boards.txt
Defaults to `0x2000`
**Requirement:** *Optional*
----
### BOOTLOADER_UNPROTECT
**Description:**
Bootloader unprotect sequence for upload tool. Normally parsed from boards.txt
Defaults to `at91samd bootloader 0`
**Requirement:** *Optional*
----
### BOOTLOADER_PROTECT
**Description:**
Bootloader protect sequence for upload tool. Normally parsed from boards.txt
Defaults to `at91samd bootloader 16384`
**Requirement:** *Optional*
----
### BOOTLOADER_PROTECT_VERIFY
**Description:**
Bootloader protect and verify sequence for upload tool. Normally parsed from boards.txt
Defaults to `at91samd bootloader`
**Requirement:** *Optional*
----
### BOOTLOADER_UPLOAD_TOOL
**Description:**
Bootloader upload binary to use. Normally parsed from boards.txt.
Defaults to `openocd`
**Requirement:** *Optional*
----
## ChipKIT variables
### MPIDE_DIR
@ -1417,3 +1790,213 @@ MPIDE_PREFERENCES_PATH = $(HOME)/chipkit/preferences.txt
```
**Requirement:** *Optional*
----
## ARM variables
### UPLOAD_TOOL
**Description:**
Tool to upload binary to device. Normally parsed from boards.txt.
Defaults to `openocd`
**Example:**
```Makefile
UPLOAD_TOOL = gdb
```
**Requirement:** *Optional*
----
### DEBUG
**Description:**
Define to set `DEBUG_FLAGS` and allow stepping of code using GDB.
Defaults to undefined.
**Example:**
```Makefile
DEBUG = 1
```
**Requirement:** *Optional*
----
### GDB_PORT
**Description:**
Server port to use for GDB debugging or upload. Default assumes server running
on localhost but can re-define to use Black Magic Probe serial port.
Defaults to `localhost:3333`
**Example:**
```Makefile
GDB_PORT = /dev/ttyACM0
```
**Requirement:** *Optional*
----
### GDB_OPTS
**Description:**
Optional arguments to parse to GDB command.
Defaults to `-ex "target extended-remote $(GDB_PORT)" -ex "monitor swdp_scan" -ex "attach 1" -ex "load" -d $(OBJDIR) $(TARGET_ELF)`
**Requirement:** *Optional*
----
### GDB_UPLOAD_OPTS
**Description:**
Optional arguments to parse to GDB command when uploading binary only.
Defaults to `GDB_UPLOAD_OPTS = $(GDB_OPTS) -ex "set confirm off" -ex "set target-async off" -ex "set remotetimeout 30" -ex "detach" -ex "kill" -ex "quit"`
**Requirement:** *Optional*
----
### BOSSA
**Description:**
Path to bossac binary.
Can usually be detected from `$ARDUINO_PACKAGE_DIR` /tools subdirectory when ARM
device support is installed.
**Requirement:** *Optional*
----
### BOSSA_VER
**Description:**
`bossa` sub-directory - usually the tool version. Will auto-detect to highest version found.
**Requirement:** *Optional*
----
### BOSSA_OPTS
**Description:**
Flags to pass to bossac command.
Defaults to `-d --info --erase --write --verify --reset`
**Requirement:** *Optional*
----
### OPENOCD
**Description:**
Path to openocd binary.
Can usually be detected from `$ARDUINO_PACKAGE_DIR` /tools subdirectory when ARM
device support is installed.
**Requirement:** *Optional*
----
### OPENOCD_VER
**Description:**
`openocd` sub-directory - usually the tool version. Will auto-detect to highest version found.
**Requirement:** *Optional*
----
### OPENOCD_OPTS
**Description:**
Flags to pass to openocd command. If using openocd from non-Arduino
distributions, one should define this with the path to the Arduino openocd script.
Defaults to `-d2`
Example:
```Makefile
OPENOCD_OPTS = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/openocd/0.9.0-arduino6-static/share/openocd/scripts/ -f $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/samd/1.6.17/variants/$(VARIANT)/$(OPENOCD_SCRIPT)
```
**Requirement:** *Optional*
----
## Ctags variables
### TAGS_FILE
**Description:**
Output file name for tags. Defaults to 'tags'.
**Example:**
```Makefile
TAGS_FILE = .tags
```
**Requirement:** *Optional*
----
### CTAGS_OPTS
**Description:**
Additional options to pass to `ctags` command.
**Example:**
```Makefile
# Run ctags in verbose mode
CTAGS_OPTS = -V
```
**Requirement:** *Optional*
----
### CTAGS_EXEC
**Description:**
Path to the `ctags` binary. Defaults to user path.
**Example:**
```Makefile
CTAGS_EXEC = /usr/local/bin/ctags
```
**Requirement:** *Optional*

View file

@ -1,25 +1,102 @@
#!/usr/bin/env python
#!/usr/bin/python3
from __future__ import print_function
import serial
import serial.tools.list_ports
import os.path
import argparse
from time import sleep
pyserial_version = None
try:
pyserial_version = int(serial.VERSION[0])
except:
pyserial_version = 2 # less than 2.3
parser = argparse.ArgumentParser(description='Reset an Arduino')
parser.add_argument('--zero', action='store_true', help='Reset Arduino Zero or similar Native USB to enter bootloader')
parser.add_argument('--caterina', action='store_true', help='Reset a Leonardo, Micro, Robot or LilyPadUSB.')
parser.add_argument('--verbose', action='store_true', help="Watch what's going on on STDERR.")
parser.add_argument('--period', default=0.1, help='Specify the DTR pulse width in seconds.')
parser.add_argument('port', nargs=1, help='Serial device e.g. /dev/ttyACM0')
args = parser.parse_args()
if args.caterina:
def list_ports(output=False):
""" Lists serial ports attached
:returns
A list of paths to serial ports on system
"""
ports = serial.tools.list_ports.comports()
connected = [port[0] for port in ports]
if output:
print(connected)
return connected
def new_port(old, new):
""" Checks if a new port has attached
Args:
old: previous list of ports to check
new: current list of ports to check
Returns:
index of port in 'new' if new port found, otherwise -1
"""
new_port = -1
for port in new:
if port not in old:
new_port = new.index(port)
break
return new_port
if args.zero:
# number of trys to attempt
zero_attempts = 20 # ~2 seconds
initial_ports = list_ports(args.verbose)
if args.verbose:
print('Attempting to enter bootloader using 1200 bps open/close on port %s' % args.port[0])
ser = serial.Serial(args.port[0], 57600)
ser.close()
ser.baudrate = 1200
# do the open/close at 1200 BAUD
ser.open()
ser.close()
if args.verbose:
print('Done. Waiting for bootloader port to attach...')
# get new list of ports
reset_ports = list_ports(args.verbose)
# wait for new port or port to return
port_index = new_port(initial_ports, reset_ports)
# keep checking until new port appears or timeout
while port_index < 0:
# count down attempts and leave if expired
zero_attempts -= 1
if zero_attempts < 0:
break
sleep(0.1)
# get list of ports after bootloader toggle performed
reset_ports = list_ports(args.verbose)
# if a port drops, set initial ports to reset ports so that
# next attached device will be new port
if (len(reset_ports) < len(initial_ports)):
initial_ports = reset_ports
# check if a new port has attached and return the index if it has
port_index = new_port(initial_ports, reset_ports)
# return the new port if detected, otherwise return passed port
if port_index == -1:
bootloader_port = args.port[0]
else:
bootloader_port = reset_ports[port_index]
# print so that `tail -1` can be piped for bootloader port
print(bootloader_port)
elif args.caterina:
if args.verbose: print('Forcing reset using 1200bps open/close on port %s' % args.port[0])
ser = serial.Serial(args.port[0], 57600)
ser.close()

278
bin/ardmk-init Executable file
View file

@ -0,0 +1,278 @@
#!/usr/bin/python3
"""
Arduino-mk Makefile and project initialiser
This script can be used in its basic form create a project specific Makefile
for use with Arduino-mk. Addionally, it can be used to create a template
Arduino source file and a traditional boilerplate project file structure.
Example:
* Run prompted within current working directory (requires Clint): `ardmk-init --cli`
* Create Arduino Uno Makefile (useful within a library example): `ardmk-init -b uno`
* Create boilerplate Arduino Uno project in current working directory of same
name: `ardmk-init -b uno --project`
* Create Arduino-mk nano Makefile in current working directory with template .ino:
`ardmk-init -b nano -u atmega328 -tn my-project`
See `armk-init --help` for CLI arguments
"""
import os
import argparse
## Global Vars
VERSION = "1.2"
ARD_TEMPLATE = "\n\
#include <Arduino.h>\n\
#include <Wire.h>\n\
\n\
\n\
void setup() {\n\
}\n\
\n\
void loop() {\n\
}\n\
"
## Command Parser
PARSER = argparse.ArgumentParser(prog='ardmk-init',
description='Arduino Makefile and boilerplate project generator.\
For use with Ard-Makefile: https://github.com/sudar/Arduino-Makefile.\
Script created by John Whittington https://github.com/tuna-f1sh 2017\
\n\nVersion: ' + VERSION)
PARSER.add_argument('-v', '--verbose', action='store_true',
help="print file contents during creation")
PARSER.add_argument('-d', '--directory', default=os.getcwd(), help='directory to run generator, default cwd')
PARSER.add_argument('-b', '--board', default='uno', help='board tag')
PARSER.add_argument('-u', '--micro', default='AUTO', help='microcontroller on board')
PARSER.add_argument('-f', '--freq', default='AUTO', help='clock frequency')
PARSER.add_argument('-p', '--port', default='AUTO', help='monitor port')
PARSER.add_argument('-n', '--name', default=os.path.basename(os.getcwd()), help='project name')
PARSER.add_argument('-s', '--sam', action='store_true', help='sam device, will include Sam.mk rather than Arduino.mk')
PARSER.add_argument('--cli', action='store_true', help='run with user prompts (requires "Clint" module), rather than args')
PARSER.add_argument('-P', '--project', action='store_true',
help='create boilerplate project with src, lib and bin folder structure')
PARSER.add_argument('-t', '--template', action='store_true',
help='create bare minimum Arduino source file')
PARSER.add_argument('-V', '--version', action='version', version='%(prog)s '+ VERSION)
ARGS = PARSER.parse_args()
try:
from clint.textui import prompt, validators
except ImportError:
if ARGS.cli:
print("Python module 'clint' is required for running prompted. Install the module or run with arguments only")
quit()
def generate_makefile():
"""
Generate the Makefile content using prompts or parsed arguments
"""
# Header
file_content = "# Generated by ard-make version " + VERSION + "\n\n"
# Basic
if ARGS.cli:
print("Generating Arduino Ard-Makefile project in "
+ os.path.abspath(ARGS.directory))
btag = prompt.query('Board tag?', default='uno')
if btag != 'uno':
bsub = prompt.query('Board sub micro?', default='atmega328')
f_cpu = prompt.query('Board frequency', default='16000000L')
else:
bsub = 'AUTO'
f_cpu = 'AUTO'
monitor_port = prompt.query('Arduino port?', default='AUTO')
else:
btag = ARGS.board
bsub = ARGS.micro
f_cpu = ARGS.freq
monitor_port = ARGS.port
file_content += check_define('BOARD_TAG', btag)
file_content += check_define('BOARD_SUB', bsub)
file_content += check_define('F_CPU', f_cpu)
file_content += check_define('MONITOR_PORT', monitor_port)
# Extended
if ARGS.cli:
if not prompt.yn('Extended options?', default='n'):
if not prompt.yn('Define local folders?', default='n'):
src_dir = prompt.query('Sources folder (Makefile will be created here)?',
default='', validators=[])
userlibs = prompt.query('Library folder (will create if does not exist) - AUTO is Sketchbook directory?',
default='AUTO', validators=[])
obj_dir = prompt.query('Output directory?', default='AUTO', validators=[])
else:
src_dir = ''
userlibs = 'AUTO'
obj_dir = 'AUTO'
boards_txt = prompt.query('Boards file?', default='AUTO')
isp_prog = prompt.query('ISP programmer?', default='atmelice_isp')
isp_port = prompt.query('ISP port?', default='AUTO')
if not prompt.yn('Quiet make?', default='n'):
file_content += "ARDUINO_QUIET = 1\n"
file_content += check_define('ISP_PROG', isp_prog)
file_content += check_define('ISP_PORT', isp_port)
file_content += check_define('BOARDS_TXT', boards_txt)
# Check andd create folders
check_create_folder(src_dir)
check_create_folder(userlibs)
check_create_folder(obj_dir)
# Makefile will be in src_dir so lib and bin must be relative
if src_dir:
userlibs = "../" + userlibs
obj_dir = "../" + obj_dir
file_content += check_define('USER_LIB_PATH', userlibs)
file_content += check_define('OBJDIR', obj_dir)
else:
src_dir = ''
if ARGS.template or not prompt.yn('Create template Arduino source?', default='n'):
source_filename = prompt.query('Name of project?',
default=os.path.basename(os.getcwd()))
if src_dir:
write_template(src_dir + "/" + source_filename)
else:
write_template(source_filename)
file_content += check_define('TARGET', source_filename)
else:
if ARGS.project:
src_dir = 'src'
userlibs = 'lib'
obj_dir = 'bin'
else:
src_dir = ''
userlibs = 'AUTO'
obj_dir = 'AUTO'
# Check andd create folders
check_create_folder(src_dir)
check_create_folder(userlibs)
check_create_folder(obj_dir)
# Makefile will be in src_dir so lib and bin must be relative
if src_dir:
userlibs = "../" + userlibs
obj_dir = "../" + obj_dir
file_content += check_define('USER_LIB_PATH', userlibs)
file_content += check_define('OBJDIR', obj_dir)
if ARGS.project or ARGS.template:
if src_dir:
write_template(src_dir + "/" + ARGS.name)
else:
write_template(ARGS.name)
file_content += check_define('TARGET', ARGS.name)
if not "ARDMK_DIR" in os.environ:
if not ARGS.cli:
print("Warning: ARDMK_DIR environment variable not defined. \
Must be defined for Makefile to work")
else:
ardmk = prompt.query('Arduino Makefile path?',
default='/usr/share/arduino',
validators=[validators.PathValidator()])
ardmk = "ARDMK_DIR := " + ardmk + "\n"
if ARGS.sam:
file_content += "\ninclude $(ARDMK_DIR)/Sam.mk"
else:
file_content += "\ninclude $(ARDMK_DIR)/Arduino.mk"
# Add forward slash if source directory exists
if src_dir:
write_to_makefile(file_content, (src_dir + "/"))
else:
write_to_makefile(file_content, "")
return file_content
def write_to_makefile(file_content, path):
"""
Write the Makefile file
"""
makefile = open(path + "Makefile", 'w')
print("Writing Makefile...")
if ARGS.verbose:
print(file_content)
makefile.write(file_content)
makefile.close()
def write_template(filename):
"""
Write template Arduino .ino source
"""
print("Writing " + os.path.abspath(filename) + ".ino...")
if os.path.isfile(filename + '.ino'):
if not ARGS.cli:
print(filename + '.ino' + ' already exists! Stopping.')
return
print(filename + '.ino' + ' already exists! Overwrite?')
if prompt.yn('Continue?', default='n'):
return
src = open((filename + ".ino"), 'w')
if ARGS.verbose:
print(ARD_TEMPLATE)
src.write("/* Project: " + filename + " */\n" + ARD_TEMPLATE)
src.close()
def check_create_folder(folder):
"""
Check if folder exists and make it if it doesn't and hasn't been set to AUTO
"""
if folder and not folder == 'AUTO':
if not os.path.exists(folder):
print("Creating " + os.path.abspath(folder) + " folder")
os.makedirs(folder)
def check_define(define, user):
"""
Check whether user has set define and return Makefile formatted string if they have
"""
# Return is empty unless user has passed value
string = ""
# Set define only if not empty or set to AUTO
if user and not user == 'AUTO':
string = define + " = " + user + "\n"
return string
def check_args():
"""
Check input args will work with Makefile
"""
# Micro should be defined for non uno boards
if ARGS.board != 'uno' and ARGS.micro == 'AUTO':
print('\n!!! Warning: --micro should be defined and not left AUTO for non-Uno boards\n')
if __name__ == '__main__':
# Create directory if not exist
check_create_folder(ARGS.directory)
# Check input args
check_args()
# Change to dir so all commands are run relative
os.chdir(ARGS.directory)
if os.path.isfile('Makefile'):
if not ARGS.cli:
print('Makefile in ' + os.path.abspath(ARGS.directory)
+ ' already exists! Please remove before generating. Stopping.')
quit()
# Confirm with user if not quiet mode
print('Makefile in ' + os.path.abspath(ARGS.directory)
+ ' already exists! Overwrite?')
if prompt.yn('Continue?', default='n'):
quit()
# Run it
generate_makefile()

View file

@ -1,8 +1,8 @@
#!/usr/bin/python
#!/usr/bin/python3
# This script sends a program on a robotis board (OpenCM9.04 or CM900)
# using the robotis bootloader (used in OpenCM IDE)
#
#
# Usage:
# python robotis-loader.py <serial port> <binary>
#

View file

@ -72,8 +72,7 @@ ifeq ($(CURRENT_OS),LINUX)
AVRDUDE_CONF = $(AVRDUDE_DIR)/avrdude.conf
endif
PIC32_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools
PIC32_TOOLS_PATH = $(PIC32_TOOLS_DIR)/bin
AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools
ALTERNATE_CORE = pic32
ALTERNATE_CORE_PATH = $(MPIDE_DIR)/hardware/pic32
@ -89,23 +88,7 @@ CORE_AS_SRCS = $(ARDUINO_CORE_PATH)/vector_table.S \
ARDUINO_VERSION = 23
CC_NAME = pic32-gcc
CXX_NAME = pic32-g++
AR_NAME = pic32-ar
OBJDUMP_NAME = pic32-objdump
OBJCOPY_NAME = pic32-objcopy
SIZE_NAME = pic32-size
NM_NAME = pic32-nm
OVERRIDE_EXECUTABLES = 1
CC = $(PIC32_TOOLS_PATH)/$(CC_NAME)
CXX = $(PIC32_TOOLS_PATH)/$(CXX_NAME)
AS = $(PIC32_TOOLS_PATH)/$(AS_NAME)
OBJCOPY = $(PIC32_TOOLS_PATH)/$(OBJCOPY_NAME)
OBJDUMP = $(PIC32_TOOLS_PATH)/$(OBJDUMP_NAME)
AR = $(PIC32_TOOLS_PATH)/$(AR_NAME)
SIZE = $(PIC32_TOOLS_PATH)/$(SIZE_NAME)
NM = $(PIC32_TOOLS_PATH)/$(NM_NAME)
TOOL_PREFIX = pic32
LDSCRIPT = $(call PARSE_BOARD,$(BOARD_TAG),ldscript)
LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT)

View file

@ -1,13 +1,59 @@
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
# if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone.
ALTERNATE_CORE = attiny
# If not, you might have to include the full path.
#ALTERNATE_CORE_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/
# Set this if the IDE is not in your $PATH or you want to use a specific version:
ARDUINO_DIR = $(HOME)/arduino-1.8.5
BOARD_TAG = attiny85-8
ISP_PORT = /dev/ttyACM*
# Programmer type:
ISP_PROG = usbasp
# Examples - obviously pick only one and comment/delete the rest:
# ------------------------------------------------------------------ #
# https://github.com/SpenceKonde/ATTinyCore (1.5+)
ALTERNATE_CORE = ATTinyCore
BOARD_TAG = attinyx4
BOARD_SUB = 84
VARIANT = tinyX4
F_CPU = 8000000L
#BOARD_TAG = attinyx313
#BOARD_SUB = 4313
#BOARD_TAG = attinyx61
#BOARD_SUB = 861
#F_CPU = 8000000L
# ------------------------------------------------------------------ #
# https://github.com/Coding-Badly/TinyCore1 (1.5+)
ALTERNATE_CORE = tiny
BOARD_TAG = attiny85at8
#BOARD_TAG = attiny2313at1
# https://github.com/Coding-Badly/arduino-tiny (1.0)
ALTERNATE_CORE = tiny
BOARD_TAG = attiny85at8
#BOARD_TAG = attiny44at8
#BOARD_TAG = attiny84at8
ARDUINO_VAR_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny
ARDUINO_CORE_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny
# ------------------------------------------------------------------ #
# https://github.com/damellis/attiny (1.5+)
ALTERNATE_CORE = attiny-master
BOARD_TAG = attiny
BOARD_SUB = attiny85
F_CPU = 16000000L
# https://github.com/damellis/attiny (1.0)
ALTERNATE_CORE = attiny-master
BOARD_TAG = attiny85
#BOARD_TAG = attiny44-8
#BOARD_TAG = attiny84-20
# ------------------------------------------------------------------ #
# Path to the Arduino Makefile
include $(ARDMK_DIR)/Arduino.mk
# !!! Important. You have to use make ispload to upload when using ISP programmer
# !!! Important. You have to use 'make ispload' when using an ISP.

View file

@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -1,7 +1,7 @@
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
BOARD_TAG = uno
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
@ -45,8 +45,8 @@ include ../../Arduino.mk
#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/promicro/bootloaders
#BOOTLOADER_PATH = caterina
#BOOTLOADER_FILE = Caterina-promicro16.hex
#ISP_PROG = usbasp
#AVRDUDE_OPTS = -v
#ISP_PROG = usbasp
#AVRDUDE_OPTS = -v
#include /usr/share/arduino/Arduino.mk
# --- chipkit
@ -75,40 +75,8 @@ include ../../Arduino.mk
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
#include /usr/share/arduino/Arduino.mk
# --- arduino-tiny ide 1.0
#ISP_PROG = usbasp
#BOARD_TAG = attiny85at8
#ALTERNATE_CORE = tiny
#ARDUINO_VAR_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny
#ARDUINO_CORE_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny
#AVRDUDE_OPTS = -v
#include /usr/share/arduino/Arduino.mk
# --- arduino-tiny ide 1.6
#ISP_PROG = usbasp
#BOARD_TAG = attiny85at8
#ALTERNATE_CORE = tiny
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
#include /usr/share/arduino/Arduino.mk
# --- damellis attiny ide 1.0
#ISP_PROG = usbasp
#BOARD_TAG = attiny85
#ALTERNATE_CORE = attiny-master
#AVRDUDE_OPTS = -v
#include /usr/share/arduino/Arduino.mk
# --- damellis attiny ide 1.6
#ISP_PROG = usbasp
#BOARD_TAG = attiny
#BOARD_SUB = attiny85
#ALTERNATE_CORE = attiny
#F_CPU = 16000000L
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
#include /usr/share/arduino/Arduino.mk
# --- teensy3
#BOARD_TAG = teensy31
#BOARD_TAG = teensy31
#ARDUINO_DIR = /where/you/installed/the/patched/teensy/arduino-1.0.6
#include /usr/share/arduino/Teensy.mk
@ -118,8 +86,31 @@ include ../../Arduino.mk
#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/mighty-1284p/bootloaders
#BOOTLOADER_PATH = optiboot
#BOOTLOADER_FILE = optiboot_atmega1284p.hex
#ISP_PROG = usbasp
#AVRDUDE_OPTS = -v
#ISP_PROG = usbasp
#AVRDUDE_OPTS = -v
#include /usr/share/arduino/Arduino.mk
# --- mightycore
#ALTERNATE_CORE = MightyCore
#BOARD_TAG = 1284
#MCU = atmega1284p
#BOARD_TAG = 644
#MCU = atmega644p
#VARIANT = standard
#F_CPU = 16000000L
#include /usr/share/arduino/Arduino.mk
# --- megacore
#BOARD_TAG = 128
#ALTERNATE_CORE = megacore
#F_CPU = 16000000L
#include /usr/share/arduino/Arduino.mk
# --- sanguino 644p
#BOARD_TAG = atmega644p
#ALTERNATE_CORE = sanguino
#ISP_PROG = usbasp
#AVRDUDE_OPTS = -v
#include /usr/share/arduino/Arduino.mk
# --- atmega328p on breadboard

View file

@ -0,0 +1,23 @@
// A derived Blink, that uses an example 3rd party library.
// Turns on an LED on for one second, then off for one second, repeatedly.
// This example code is in the public domain.
#include <TogglePin.h>
#ifdef ARDUINO
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#endif // ARDUINO
int main()
{
init();
TogglePin led(13, false);
while (true) {
delay(1000);
led.toggle();
}
}

View file

@ -0,0 +1,24 @@
# This program is free software and is licensed under the same conditions as
# describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
# This is an example Makefile, that demonstrates the linking of a third party
# library. In this case the third party library resides in the ./Toggle
# sub-directory. Note that the archive TOGGLE_ARCHIVE _only_ contains the
# compiled Toggle.c.o object. The TOGGLE_ARCHIVE is thus very lean, but it
# requires the Arduino libraries, which are being build in this directory,
# together with Blink, the 'main' program.
include board.mk
TOGGLE_ARCHIVE = build-$(BOARD_TAG)/libtoggle.a
CXXFLAGS += -IToggle
OTHER_OBJS = Toggle/$(TOGGLE_ARCHIVE)
include $(ARDMK_DIR)/Arduino.mk
Toggle/$(TOGGLE_ARCHIVE):
$(MAKE) -C Toggle $(TOGGLE_ARCHIVE)
clean::
$(MAKE) -C Toggle clean

View file

@ -0,0 +1,14 @@
# This program is free software and is licensed under the same conditions as
# describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
# This is an example Makefile, that is being used to build an archive
# from locally compiled objects.
#
# All source files in this directory will automatically get compiled
# and archived into the build-$(BOARD_TAG)/libtoggle.a target.
include ../board.mk
include $(ARDMK_DIR)/Arduino.mk
build-$(BOARD_TAG)/libtoggle.a: $(LOCAL_OBJS)
$(AR) rcs $@ $(LOCAL_OBJS)

View file

@ -0,0 +1,27 @@
// This program is free software and is licensed under the same conditions as
// describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
#include "TogglePin.h"
#ifdef ARDUINO
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#endif // ARDUINO
TogglePin::TogglePin(int pinNumber, bool state)
: _pinNumber(pinNumber), _state(state)
{
pinMode(_pinNumber, OUTPUT);
digitalWrite(_pinNumber, _state ? HIGH : LOW);
}
bool
TogglePin::toggle()
{
_state = !_state;
digitalWrite(_pinNumber, _state ? HIGH : LOW);
return _state;
}

View file

@ -0,0 +1,19 @@
// This program is free software and is licensed under the same conditions as
// describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
#ifndef TOGGLEPIN_H_
#define TOGGLEPIN_H_
class TogglePin
{
public:
TogglePin(int pinNumber, bool state);
bool toggle();
private:
const int _pinNumber;
bool _state;
};
#endif

View file

@ -0,0 +1,7 @@
# This program is free software and is licensed under the same conditions as
# describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt
# The following can be overridden at make-time, by setting an environment
# variable with the same name. eg. BOARD_TAG=pro5v328 make
BOARD_TAG ?= uno

View file

@ -1,5 +1,5 @@
BOARD_TAG = mega_pic32
ARDUINO_LIBS =
include ../../chipKIT.mk
include $(ARDMK_DIR)/chipKIT.mk

View file

@ -11,6 +11,6 @@ F_CPU = 8000000L
ISP_PROG = stk500v1
AVRDUDE_ISP_BAUDRATE = 19200
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
# !!! Important. You have to use make ispload to upload when using ISP programmer

View file

@ -16,7 +16,7 @@ AVRDUDE_CONF=/usr/local/etc/avrdude.conf
FORCE_MONITOR_PORT=true
MONITOR_PORT=/dev/spidev0.0
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
# Additional rules to use a remote Raspberry Pi programmer

View file

@ -0,0 +1,48 @@
/*
* Blink(LED)
*/
#define BDPIN_LED_USER_1 22
#define BDPIN_LED_USER_2 23
#define BDPIN_LED_USER_3 24
#define BDPIN_LED_USER_4 25
int led_pin = 13;
int led_pin_user[4] = { BDPIN_LED_USER_1, BDPIN_LED_USER_2, BDPIN_LED_USER_3, BDPIN_LED_USER_4 };
void setup() {
// Set up the built-in LED pin as an output:
pinMode(led_pin, OUTPUT);
pinMode(led_pin_user[0], OUTPUT);
pinMode(led_pin_user[1], OUTPUT);
pinMode(led_pin_user[2], OUTPUT);
pinMode(led_pin_user[3], OUTPUT);
Serial.begin(115200);
}
void loop() {
int i;
digitalWrite(led_pin, HIGH); // set to as HIGH LED is turn-off
delay(100); // Wait for 0.1 second
digitalWrite(led_pin, LOW); // set to as LOW LED is turn-on
delay(100); // Wait for 0.1 second
for( i=0; i<4; i++ )
{
digitalWrite(led_pin_user[i], HIGH);
delay(100);
}
for( i=0; i<4; i++ )
{
digitalWrite(led_pin_user[i], LOW);
delay(100);
}
Serial.println( String(10) );
}

View file

@ -0,0 +1,8 @@
BOARD_TAG = OpenCR
ARDUINO_LIBS =
#MONITOR_PORT = /dev/ttyACM0
include ../../OpenCR.mk

View file

@ -1,4 +1,4 @@
BOARD_TAG = teensy31
ARDUINO_LIBS =
include ../../Teensy.mk
include $(ARDMK_DIR)/Teensy.mk

View file

@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -0,0 +1,19 @@
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}

View file

@ -0,0 +1,19 @@
# Arduino Due uses SAM3X8E SAM chip
BOARD_TAG = arduino_due_x
ARCHITECTURE = sam
# Define ARM toolchain dir if not using Arduino supplied
#ARM_TOOLS_DIR = /usr
# Define AVR toolchain dir if not using Arduino supplied and using native port
#AVR_TOOLS_DIR = /usr
# Define Arduino support package installation path where SAM device support has been installed
# Linux
#ARDUINO_PACKAGE_DIR := $(HOME)/.arduino15/packages
# macOS
#ARDUINO_PACKAGE_DIR := $(HOME)/Library/Arduino15/packages
# Windows
#ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages"
include ../../Sam.mk

View file

@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS = LiquidCrystal
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -0,0 +1,19 @@
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}

View file

@ -0,0 +1,24 @@
# Arduino M0 Pro Programming Port
BOARD_TAG = mzero_pro_bl_dbg
# Define debug if you want to use gdb
#DEBUG = 1
# Define port if using Black Magic Probe rather than default localhost:3333
#GDB_PORT = /dev/ttyACM0
# Define ARM toolchain dir if not using Arduino supplied
#ARM_TOOLS_DIR = /usr
# Define AVR toolchain dir if not using Arduino supplied and using native port
#AVR_TOOLS_DIR = /usr
# Define Arduino support package installation path where SAM device support has been installed
# Linux
# ARDUINO_PACKAGE_DIR := $(HOME)/.arduino15/packages
# macOS
# ARDUINO_PACKAGE_DIR := $(HOME)/Library/Arduino15/packages
# Windows
# ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages"
include ../../Sam.mk

View file

@ -52,5 +52,5 @@ ARDUINO_SKETCHBOOK = $(HOME)/sketchbook
ALTERNATE_CORE = sparkfun
BOARD_TAG = promicro
BOARD_SUB = 8MHzatmega32U4
include /usr/share/arduino/Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -2,4 +2,4 @@
BOARD_TAG = uno
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -17,4 +17,4 @@ F_CPU = 16000000L
ARDUINO_LIBS = SoftwareSerial
include /usr/share/arduino/Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -3,4 +3,4 @@
BOARD_TAG = uno
ARDUINO_LIBS = Ethernet SPI
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -0,0 +1,30 @@
# Arduino Zero Native Port (should work with Feather, MKR1000 etc.)
# BOOTLOADER: The bootloader on these devices loaded when reset is pressed twice
# or the port is opened/closed at 1200 BAUD. If there is no program on the device,
# you may have to manually enter bootloader by toggling reset twice.
# see http://www.avdweb.nl/arduino/samd21/virus.html
BOARD_TAG = arduino_zero_native
# Define alternative core path if using another board supplier
#ALTERNATE_CORE_PATH = $(HOME)/Arduino/hardware/sparkfun/samd
# Define monitor port and isp port (bootloader port).
# Will automatically detect if Linux/macOS but MUST be defined on Windows
#MONITOR_PORT = com40 # CDC serial
#ISP_PORT = com39 # bootloader
# Define ARM toolchain dir if not using Arduino supplied
#ARM_TOOLS_DIR = /usr
# Define AVR toolchain dir if not using Arduino supplied and using native port
#AVR_TOOLS_DIR = /usr
# Define Arduino support package installation path where SAM device support has been installed
# Linux
#ARDUINO_PACKAGE_DIR := $(HOME)/.arduino15/packages
# macOS
#ARDUINO_PACKAGE_DIR := $(HOME)/Library/Arduino15/packages
# Windows
#ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages"
include ../../Sam.mk

View file

@ -0,0 +1,19 @@
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}

View file

@ -3,4 +3,4 @@
BOARD_TAG = uno
ARDUINO_LIBS = Wire
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =
include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk

View file

@ -1,6 +1,6 @@
Name: arduino-mk
Version: 1.6.0
Release: 1%{dist}
Release: 2%{dist}
Summary: Program your Arduino from the command line
Packager: Simon John <git@the-jedi.co.uk>
URL: https://github.com/sudar/Arduino-Makefile
@ -9,8 +9,7 @@ Group: Development/Tools
License: LGPLv2+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
Requires: arduino-core pyserial
BuildRequires: arduino-core
Requires: arduino-core python3-pyserial
%description
Arduino is an open-source electronics prototyping platform based on
@ -39,6 +38,8 @@ install -m 755 bin/ard-reset-arduino %{buildroot}/%{_bindir}/ard-reset-arduino
install -m 644 ard-reset-arduino.1 %{buildroot}/%{_mandir}/man1
install -m 755 bin/robotis-loader %{buildroot}/%{_bindir}/robotis-loader
install -m 644 robotis-loader.1 %{buildroot}/%{_mandir}/man1
install -m 755 bin/ardmk-init %{buildroot}/%{_bindir}/ardmk-init
install -m 644 ardmk-init.1 %{buildroot}/%{_mandir}/man1
%clean
rm -rf %{buildroot}
@ -49,6 +50,8 @@ rm -rf %{buildroot}
%{_mandir}/man1/ard-reset-arduino.1*
%{_bindir}/robotis-loader
%{_mandir}/man1/robotis-loader.1*
%{_bindir}/ardmk-init
%{_mandir}/man1/ardmk-init.1*
%{_datadir}/arduino/*.mk
%{_datadir}/arduino/arduino-mk-vars.md
%doc %{_docdir}/%{name}/licence.txt
@ -56,6 +59,10 @@ rm -rf %{buildroot}
%{_docdir}/%{name}/examples
%changelog
* Thu Oct 24 2019 Simon John <git@the-jedi.co.uk>
- Removed BuildRequires
* Thu Oct 05 2017 Simon John <git@the-jedi.co.uk>
- Added ardmk-init binary and manpage
* Tue Jul 11 2017 Karl Semich <fuzzyTew@gmail.com>
- Added robotis-loader binary and manpage
* Sat Apr 12 2014 Simon John <git@the-jedi.co.uk>

View file

@ -7,3 +7,4 @@ pushd $SCRIPTS_DIR/..
source $SCRIPTS_DIR/bootstrap/chipkit.sh
source $SCRIPTS_DIR/bootstrap/arduino.sh
source $SCRIPTS_DIR/bootstrap/samd.sh

View file

@ -8,7 +8,8 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then
echo "Installing Arduino..."
ARDUINO_BASENAME="arduino-1.0.6"
ARDUINO_BASENAME="arduino-1.8.11"
if [ $OS == "cygwin" ]; then
ARDUINO_FILE="$ARDUINO_BASENAME-windows".zip
EXTRACT_COMMAND="unzip -q"
@ -16,8 +17,8 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then
ARDUINO_FILE="$ARDUINO_BASENAME-macosx".zip
EXTRACT_COMMAND="unzip -q"
else
ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tgz
EXTRACT_COMMAND="tar -xzf"
ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tar.xz
EXTRACT_COMMAND="tar -xf"
fi
ARDUINO_URL=http://arduino.cc/download.php?f=/$ARDUINO_FILE
@ -33,6 +34,7 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then
then
echo "Installing Arduino to local folder..."
$EXTRACT_COMMAND $ARDUINO_FILE
mv $ARDUINO_BASENAME arduino
echo "Arduino installed"
fi

View file

@ -160,22 +160,14 @@ if [ -z $COMMON_SOURCED ]; then
fi
fi
if ! command -v python >/dev/null 2>&1; then
if ! command -v python3 >/dev/null 2>&1; then
echo "Installing Python..."
_install "python"
_install "python3"
fi
if ! command -v pip >/dev/null 2>&1; then
if ! command -v pip3 >/dev/null 2>&1; then
echo "Installing Pip..."
if ! command -v easy_install >/dev/null 2>&1; then
_install "python-setuptools"
fi
if ! command -v easy_install >/dev/null 2>&1; then
die "easy_install not available, can't install pip"
fi
$SUDO_CMD easy_install pip
_install "python3-pip"
fi
PIP_SUDO_CMD=
@ -184,7 +176,7 @@ if [ -z $COMMON_SOURCED ]; then
PIP_SUDO_CMD=$SUDO_CMD
fi
$PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt
$PIP_SUDO_CMD pip3 install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt
COMMON_SOURCED=1
fi

View file

@ -1 +1 @@
pyserial==2.7
pyserial==3.4

View file

@ -0,0 +1,46 @@
set -e
BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $BOOTSTRAP_DIR/common.sh
echo "Installing dependencies for building for the SAMD boards"
# these extract to dirs without versions...
SAMD_PACKAGE="samd-1.8.6"
CMSIS_PACKAGE="CMSIS-4.5.0"
CMSIS_ATMEL_PACKAGE="CMSIS-Atmel-1.2.0"
if [ $OS == "mac" ]; then
TOOLCHAIN_PACKAGE="gcc-arm-none-eabi-7-2017-q4-major-mac"
else
TOOLCHAIN_PACKAGE="gcc-arm-none-eabi-7-2017-q4-major-linux"
fi
ARDUINO_URL=https://downloads.arduino.cc
TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4
EXTRACT_COMMAND="tar -xjf"
_pushd $DEPENDENCIES_FOLDER
if ! test -e $SAMD_PACKAGE
then
echo "Downloading SAMD packages..."
download $ARDUINO_URL/cores/$SAMD_PACKAGE.tar.bz2 $SAMD_PACKAGE.tar.bz2
download $ARDUINO_URL/$CMSIS_PACKAGE.tar.bz2 $CMSIS_PACKAGE.tar.bz2
download $ARDUINO_URL/$CMSIS_ATMEL_PACKAGE.tar.bz2 $CMSIS_ATMEL_PACKAGE.tar.bz2
download $TOOLCHAIN_URL/$TOOLCHAIN_PACKAGE.tar.bz2 $TOOLCHAIN_PACKAGE.tar.bz2
fi
if ! test -d $SAMD_PACKAGE
then
echo "Installing packages to local folder..."
$EXTRACT_COMMAND $SAMD_PACKAGE.tar.bz2
$EXTRACT_COMMAND $CMSIS_PACKAGE.tar.bz2
$EXTRACT_COMMAND $CMSIS_ATMEL_PACKAGE.tar.bz2
$EXTRACT_COMMAND $TOOLCHAIN_PACKAGE.tar.bz2
echo "SAMD support installed"
fi
_popd
echo
echo "${bldgreen}SAMD dependencies installed.$txtrst"

View file

@ -1,13 +1,45 @@
#!/usr/bin/env bash
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TESTS_DIR=examples
export ARDMK_DIR="${ARDMK_DIR:-$SCRIPTS_DIR/../..}"
failures=()
if [[ "$1" == "-q" ]]; then
QUIET=1
fi
runtest() {
if [[ $QUIET ]]; then
make $* TEST=1 > /dev/null 2>&1
else
output=`make $* TEST=1`
fi
}
run() {
if [[ $QUIET ]]; then
"$@" > /dev/null 2>&1
else
"$@"
fi
}
info() {
if [[ $QUIET ]]; then
return
fi
echo "$@"
}
run pushd $SCRIPTS_DIR/../..
# These examples cannot be tested easily at the moment as they require
# alternate cores. The MakefileExample doesn't actually contain any source code
# to compile.
NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkTeensy BlinkNetworkRPi BlinkInAVRC)
NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkOpenCR BlinkTeensy BlinkNetworkRPi BlinkInAVRC DueBlink)
for dir in $TESTS_DIR/*/
do
@ -22,46 +54,47 @@ do
done
if ! $example_is_testable; then
echo "Skipping non-testable example $example..."
info "Skipping non-testable example $example..."
continue
fi
pushd $dir
echo "Compiling $example..."
make_output=`make clean TEST=1`
make_output=`make TEST=1`
run pushd $dir
info "Compiling $example..."
runtest clean
runtest
if [[ $? -ne 0 ]]; then
failures+=("$example")
echo "Example $example failed"
info "Example $example failed"
fi
make_output=`make disasm TEST=1`
runtest disasm
if [[ $? -ne 0 ]]; then
failures+=("$example disasm")
echo "Example $example disasm failed"
info "Example $example disasm failed"
fi
make_output=`make generate_assembly TEST=1`
runtest generate_assembly
if [[ $? -ne 0 ]]; then
failures+=("$example generate_assembly")
echo "Example $example generate_assembly failed"
info "Example $example generate_assembly failed"
fi
make_output=`make symbol_sizes TEST=1`
runtest symbol_sizes
if [[ $? -ne 0 ]]; then
failures+=("$example symbol_sizes")
echo "Example $example symbol_sizes failed"
info "Example $example symbol_sizes failed"
fi
popd
done
for failure in "${failures[@]}"; do
echo "Example $failure failed"
run popd
done
if [[ ${#failures[@]} -eq 0 ]]; then
echo "All tests passed."
else
exit 1
for failure in "${failures[@]}"; do
echo "Example $failure failed"
done
exit 1
fi