From 668a4470548514b96311a976d6b3527a5a532f38 Mon Sep 17 00:00:00 2001 From: tinyladi Date: Thu, 27 Feb 2014 20:57:43 +0100 Subject: [PATCH 01/15] Add a reference makefile, with real-world example --- HISTORY.md | 3 +- README.md | 4 +- examples/MakefileExample/Makefile-example.mk | 55 ++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 examples/MakefileExample/Makefile-example.mk diff --git a/HISTORY.md b/HISTORY.md index 99711e5..b40aa21 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: Add avr-libc/malloc.c and realloc.c to included core files. Fixes issue #163 (https://github.com/sej7278) - Fix: Add "gpio" to the list of isp that don't have a port. (Issue #165, #166) (https://github.com/sej7278) - Fix: Add "-D__PROG_TYPES_COMPAT__" to the avr-g++ compiler flags to match IDE. (https://github.com/sej7278) +- New: Create `Makefile-example-mk`, a *real life* `Makefile` example, to be used as a reference. (https://github.com/tinyladi) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) @@ -21,7 +22,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Tweak: Don't hard code MONITOR_PORT in examples, for more flexible testing. (Issue #157) (https://github.com/peplin) - Tweak: Silence the stderr output from call to `which`. (Issue #158) (https://github.com/peplin) - Fix: Override complete compiler tool paths for chipKIT. (Issue #159) (https://github.com/peplin) -- New: The makefile is compatible with Windows +- New: The makefile is compatible with Windows - New: Update `README.md` file about usage and Windows compatibility ### 1.2.0 (2014-01-14) diff --git a/README.md b/README.md index 28d85e6..d658789 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,9 @@ On other systems: ## Usage -You can also find more [detailed instructions in this guide](http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile) or also checkout the sample makefiles inside the examples/ folder +You can also find more [detailed instructions in this guide](http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile). + +You can also checkout the sample makefiles inside the `examples/` folder or take a look at a *real* [Makefile-example](examples/MakefileExample/Makefile-example.mk). Download a copy of this repo some where in your system or install it through a package. diff --git a/examples/MakefileExample/Makefile-example.mk b/examples/MakefileExample/Makefile-example.mk new file mode 100644 index 0000000..8d64a83 --- /dev/null +++ b/examples/MakefileExample/Makefile-example.mk @@ -0,0 +1,55 @@ +### DISCLAIMER +### This is an example Makefile and it MUST be configured to suit your needs. +### For detailled explanations about all the avalaible options, +### please refer to https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md + +### PROJECT_DIR +### This is the path to where you have created/cloned your project +PROJECT_DIR = /Users/Ladislas/dev/leka/moti + +### ARDMK_DIR +### Path to the Arduino-Makefile directory. +ARDMK_DIR = $(PROJECT_DIR)/arduino-mk + +### ARDUINO_DIR +### Path to the Arduino application and ressources directory. +ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java + +### USER_LIB_PATH +### Path to where the your project's libraries are stored. +USER_LIB_PATH := $(PROJECT_DIR)/lib + +### BOARD_TAG +### It must be set to the board you are currently using. (i.e uno, mega2560, etc.) +BOARD_TAG = mega2560 + +### MONITOR_BAUDRATE +### It must be set to Serial baudrate value you are using. +MONITOR_BAUDRATE = 115200 + +### AVR_TOOLS_DIR +### Path to the AVR tools directory such as avr-gcc, avr-g++, etc. +AVR_TOOLS_DIR = /usr/local + +### AVRDDUDE +### Path to avrdude directory. +AVRDDUDE = /usr/local/bin/avrdude + +### CPPFLAGS +### Flags you might want to set for debugging purpose. Comment to stop. +CPPFLAGS = -pedantic -Wall -Wextra + +### MONITOR_PORT +### The port your board is connected to. Using an '*' tries all the ports and finds the right one. +MONITOR_PORT = /dev/tty.usbmodem* + +### don't touch this +CURRENT_DIR = $(shell basename $(CURDIR)) + +### OBJDIR +### This is were you put the binaries you just compile using 'make' +OBJDIR = $(PROJECT_DIR)/bin/$(BOARD_TAG)/$(CURRENT_DIR) + +### path to Arduino.mk, inside the ARDMK_DIR, don't touch. +include $(ARDMK_DIR)/Arduino.mk + From 5c4328dd29f28ed7fb8c02e12b72bce6c6a6deab Mon Sep 17 00:00:00 2001 From: tinyladi Date: Thu, 27 Feb 2014 22:22:59 +0100 Subject: [PATCH 02/15] Add `OBJDIR` reference to `arduino-mk-vars.md` Signed-off-by: tinyladi --- HISTORY.md | 1 + arduino-mk-vars.md | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index b40aa21..d60f544 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -10,6 +10,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: Add "gpio" to the list of isp that don't have a port. (Issue #165, #166) (https://github.com/sej7278) - Fix: Add "-D__PROG_TYPES_COMPAT__" to the avr-g++ compiler flags to match IDE. (https://github.com/sej7278) - New: Create `Makefile-example-mk`, a *real life* `Makefile` example, to be used as a reference. (https://github.com/tinyladi) +- Tweak: Add `OBJDIR` to `arduino-mk-vars.md` (https://github.com/tinyladi) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 37ebfd3..5c12f88 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -129,6 +129,24 @@ Defaults to 'libraries' directory within user's sketchbook. Optional. +### OBJDIR + +**Description:** + +Directory where binaries and compiled files are put. + +Defaults to `build-$(BOARD_TAG)` in your `Makefile` directory. + +**Example:** + +```Makefile +OBJDIR = /path/to/my/project-directory/bin +``` + +**Status:** *Optional* + +---- + ### ALTERNATE_CORE Non-standard core for Arduino-unsupported chips like the ATtiny. From a06136aafcf9bacbff679971db02762e65a6ce2d Mon Sep 17 00:00:00 2001 From: tinyladi Date: Thu, 27 Feb 2014 22:20:38 +0100 Subject: [PATCH 03/15] Beautify arduino-mk-vars.md Clean up markdown and add code blocks where needed Fix #171 --- HISTORY.md | 1 + arduino-mk-vars.md | 900 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 718 insertions(+), 183 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index d60f544..6a8befc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -11,6 +11,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: Add "-D__PROG_TYPES_COMPAT__" to the avr-g++ compiler flags to match IDE. (https://github.com/sej7278) - New: Create `Makefile-example-mk`, a *real life* `Makefile` example, to be used as a reference. (https://github.com/tinyladi) - Tweak: Add `OBJDIR` to `arduino-mk-vars.md` (https://github.com/tinyladi) +- Tweak: *Beautify* `arduino-mk-vars.md` with code blocks. (https://github.com/tinyladi) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 5c12f88..f8eb9a8 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -1,133 +1,268 @@ -# Documentation of variables +# Documentation of variables The following are the different variables that can be overwritten in the user makefiles. -- [Global variables](#global-variables) -- [Installation/Directory variables](#installationdirectory-variables) -- [Arduino IDE variables](#arduino-ide-variables) -- [Sketch related variables](#sketch-related-variables) -- [ISP programming variables](#isp-programming-variables) -- [Compiler/Executable variables](#compilerexecutable-variables) -- [Avrdude setting variables](#avrdude-setting-variables) -- [Bootloader variables](#bootloader-variables) -- [ChipKIT variables](#chipkit-variables) +* [Global variables](#global-variables) +* [Installation/Directory variables](#installationdirectory-variables) +* [Arduino IDE variables](#arduino-ide-variables) +* [Sketch related variables](#sketch-related-variables) +* [ISP programming variables](#isp-programming-variables) +* [Compiler/Executable variables](#compilerexecutable-variables) +* [Avrdude setting variables](#avrdude-setting-variables) +* [Bootloader variables](#bootloader-variables) +* [ChipKIT variables](#chipkit-variables) ## Global variables ### ARDUINO_QUIET + +**Description:** + Suppress printing of Arduino-Makefile configuration. -Defaults to unset/disabled. +Defaults to `0` (unset/disabled). -*Example*: 1 +**Example:** -Optional. +```Makefile +ARDUINO_QUIET = 1 +``` + +**Requirement:** *Optional* + +---- ## Installation/Directory variables ### ARDMK_DIR + +**Description:** + Directory where the `*.mk` files are stored. -Usually can be auto-detected as `AUTO_ARDUINO_DIR` (parent of Arduino.mk). +Usually can be auto-detected as `AUTO_ARDUINO_DIR` (parent of `Arduino.mk`). -*Example*: /usr/share/arduino +**Example:** -Optional. +```Makefile +ARDMK_DIR = /usr/share/arduino +``` + +**Requirement:** *Optional* + +---- ### AVR_TOOLS_DIR -Directory where tools such as avrdude, avr-g++, avr-gcc etc. are stored in the bin/ subdirectory. + +**Description:** + +Directory where tools such as `avrdude`, `avr-g++`, `avr-gcc`, etc. are stored in the `bin/` subdirectory. Usually can be auto-detected from `$PATH` as `SYSTEMPATH_AVR_TOOLS_DIR` or as `BUNDLED_AVR_TOOLS_DIR` within the Arduino distribution. -*Example*: /usr or /usr/share/arduino/hardware/tools/avr +**Example:** -Optional. +```Makefile +AVR_TOOLS_DIR = /usr +# or +AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr +``` + +**Requirement:** *Optional* + +---- ### RESET_CMD + +**Description:** + Command to reset the MCU. -Defaults to ard-reset-arduino with the extra --caterina flag for atmega32u4 boards. +Defaults to `ard-reset-arduino` with the extra `--caterina` flag for atmega32u4 boards. -*Example*: ~/gertduino/reset +**Example:** -Optional. +```Makefile +RESET_CMD = ~/gertduino/reset +``` + +**Requirement:** *Optional* + +---- ## Arduino IDE variables ### ARDUINO_DIR + +**Description:** + Directory where the Arduino IDE and/or core files are stored. -*Example*: /usr/share/arduino (Linux) or /Applications/Arduino.app/Contents/Resources/Java (OSX) +**Example:** -Optional. +```Makefile +# Linux +ARDUINO_DIR = /usr/share/arduino +# Mac OS X +ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java +``` + +**Requirement:** *Optional* + +---- ### ARDUINO_VERSION + +**Description:** + Version string for Arduino IDE and/or core. -Usually can be auto-detected as `AUTO_ARDUINO_VERSION` from /usr/share/arduino/lib/version.txt +Usually can be auto-detected as `AUTO_ARDUINO_VERSION` from `/usr/share/arduino/lib/version.txt` -*Example*: 105 +**Example:** -Optional. +```Makefile +ARDUINO_VERSION = 105 +``` -### ARDUINO_SKETCHBOOK -Path to sketchbook directory. +**Requirement:** *Optional* -Usually can be auto-detected from the Arduino preferences.txt file or the default ~/sketchbook +---- -*Example*: ~/sketches +### ARDUINO_VERSION -Optional. +**Description:** + +Path to `sketchbook` directory. + +Usually can be auto-detected from the Arduino `preferences.txt` file or the default `~/sketchbook` + +**Example:** + +```Makefile +ARDUINO_VERSION = ~/sketches +``` + +**Requirement:** *Optional* + +---- ### ARDUINO_PREFERENCES_PATH -Path to Arduino preferences.txt file. -Usually can be auto-detected as `AUTO_ARDUINO_PREFERENCES` from the defaults ~/.arduino/preferences.txt (Linux) or ~/Library/Arduino/preferences.txt (OSX) +**Description:** -*Example*: ~/sketches/preferences.txt +Path to Arduino `preferences.txt` file. -Optional. +Usually can be auto-detected as `AUTO_ARDUINO_PREFERENCES` from the defaults: + +* on Linux : `~/.arduino/preferences.txt` +* on Mac OS X : `~/Library/Arduino/preferences.txt` + +**Example:** + +```Makefile +ARDUINO_PREFERENCES_PATH = ~/sketches/preferences.txt +``` + +**Requirement:** *Optional* + +---- ### ARDUINO_CORE_PATH + +**Description:** + Path to standard Arduino core files. -*Example*: /usr/share/arduino/hardware/arduino/cores/arduino +**Example:** -Optional. +```Makefile +ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino/cores/arduino +``` + +**Requirement:** *Optional* + +---- ## Sketch related variables ### ARDUINO_LIBS + +**Description:** + Any libraries you intend to include. -Usually can be auto-detected from the sketch. Separated by spaces. If the library has a /utility folder (like SD or Wire library), then the utility folder should also be specified. +Usually can be auto-detected from the sketch. Separated by spaces. If the library has a `/utility` folder (like `SD` or `Wire` library), then the utility folder should also be specified. -*Example*: SD SD/utility Wire Wire/utility +**Example:** -Optional. +```Makefile +ARDUINO_LIBS = SD SD/utility Wire Wire/utility +``` + +**Requirement:** *Optional* + +---- ### BOARD_TAG -Device type as listed in boards.txt or `make show_boards`. -*Example*: uno or mega2560 +**Description:** -Mandatory. +Device type as listed in `boards.txt` or `make show_boards`. + +**Example:** + +```Makefile +BOARD_TAG = uno or mega2560 +``` + +**Requirement:** *Mandatory* + +---- ### MONITOR_PORT + +**Description:** + Path to serial (USB) device used for uploading/serial comms. -*Example*: /dev/ttyUSB0 or /dev/ttyACM0 (Linux) or /dev/cu.usb* (OSX) or com3 (Windows) +**Example:** -Mandatory. +```Makefile +# Linux +MONITOR_PORT = /dev/ttyUSB0 +# or +MONITOR_PORT = /dev/ttyACM0 +# Mac OS X +MONITOR_PORT = /dev/cu.usb* +# Windows +MONITOR_PORT = com3 +``` + +**Requirement:** *Mandatory* + +---- ### USER_LIB_PATH + +**Description:** + Directory where additional libraries are stored. -Defaults to 'libraries' directory within user's sketchbook. +Defaults to `libraries` directory within user's sketchbook. -*Example*: ~/sketchbook/libraries (Linux) +**Example:** -Optional. +```Makefile +# Linux +USER_LIB_PATH = ~/sketchbook/libraries +# For a random project on *nix +USER_LIB_PATH = /path/to/my/project +``` + +**Requirement:** *Optional* + +---- ### OBJDIR @@ -143,386 +278,785 @@ Defaults to `build-$(BOARD_TAG)` in your `Makefile` directory. OBJDIR = /path/to/my/project-directory/bin ``` -**Status:** *Optional* +**Requirement:** *Optional* ---- ### ALTERNATE_CORE + +**Description:** + Non-standard core for Arduino-unsupported chips like the ATtiny. -*Example*: attiny-master or arduino-tiny or tiny2 +**Example:** -Optional. +```Makefile +# HLT core +ALTERNATE_CORE = attiny-master +# tiny core +ALTERNATE_CORE = arduino-tiny +# tiny core 2 +ALTERNATE_CORE = tiny2 +``` + +**Requirement:** *Optional* + +---- ### ARDUINO_VAR_PATH + +**Description:** + Path to non-standard core's variant files. -*Example*: ~/sketchbook/hardware/arduino-tiny/cores/tiny +**Example:** -Optional. +```Makefile +ARDUINO_VAR_PATH = ~/sketchbook/hardware/arduino-tiny/cores/tiny +``` + +**Requirement:** *Optional* + +---- ### VARIANT + +**Description:** + Variant of a standard board design. -Usually can be auto-detected as build.variant from boards.txt +Usually can be auto-detected as `build.variant` from `boards.txt`. -*Example*: leonardo +**Example:** -Optional. +```Makefile +VARIANT = leonardo +``` + +**Requirement:** *Optional* + +---- ### USB_VID -Override USB VID for atmega32u4 boards. -Usually can be auto-detected as build.vid from boards.txt +**Description:** -*Example*: 0x2341 +Override `USB VID` for atmega32u4 boards. -Optional. +Usually can be auto-detected as `build.vid` from `boards.txt` + +**Example:** + +```Makefile +USB_VID = 0x2341 +``` + +**Requirement:** *Optional* + +---- ### USB_PID -Override USB PID for atmega32u4 boards. -Usually can be auto-detected as build.pid from boards.txt +**Description:** -*Example*: 0x8039 +Override `USB PID` for atmega32u4 boards. -Optional. +Usually can be auto-detected as `build.pid` from `boards.txt` + +**Example:** + +```Makefile +USB_PID = 0x8039 +``` + +**Requirement:** *Optional* + +---- ### F_CPU + +**Description:** + CPU speed in Hz -Usually can be auto-detected as build.f_cpu from boards.txt +Usually can be auto-detected as `build.f_cpu` from `boards.txt` -*Example*: 8000000L +**Example:** -Optional. +```Makefile +F_CPU = 8000000L +``` + +**Requirement:** *Optional* + +---- ### HEX_MAXIMUM_SIZE + +**Description:** + Maximum hex file size -Usually can be auto-detected as upload.maximum_size from boards.txt +Usually can be auto-detected as `upload.maximum_size` from `boards.txt` -*Example*: 14336 +**Example:** -Optional. +```Makefile +HEX_MAXIMUM_SIZE = 14336 +``` + +**Requirement:** *Optional* + +---- ### MCU + +**Description:** + Microcontroller model. -Usually can be auto-detected as build.mcu from boards.txt +Usually can be auto-detected as `build.mcu` from `boards.txt` -*Example*: atmega32u4 +**Example:** -Optional. +```Makefile +MCU = atmega32u4 +``` + +**Requirement:** *Optional* + +---- ### MCU_FLAG_NAME + +**Description:** + Override default MCU flags. -Defaults to mmcu +Defaults to `mmcu` -*Example*: mprocessor +**Example:** -Optional. +```Makefile +MCU_FLAG_NAME = mprocessor +``` + +**Requirement:** *Optional* + +---- ### MONITOR_BAUDRATE + +**Description:** + Baudrate of the serial monitor. -Defaults to 9600 if it can't find it in the sketch Serial.begin() +Defaults to `9600` if it can't find it in the sketch `Serial.begin()` -*Example*: 57600 +**Example:** -Optional. +```Makefile +MONITOR_BAUDRATE = 57600 +``` + +**Requirement:** *Optional* + +---- ## ISP programming variables ### ISP_PROG + +**Description:** + Type of ISP. Either a USB device or ArduinoISP protocol. -*Example*: usbasp or usbtiny or stk500v2 or stk500v1 +**Example:** -Optional. +```Makefile +ISP_PROG = usbasp +# or +ISP_PROG = usbtiny +# or +ISP_PROG = stk500v2 +# or +ISP_PROG = stk500v1 +``` + +**Requirement:** *Optional* + +---- ### ISP_PORT + +**Description:** + Device path to ArduinoISP. Not needed for hardware ISP's. -*Example*: /dev/ttyACM0 (Linux) +**Example:** -Optional. +```Makefile +# Linux +ISP_PORT = /dev/ttyACM0 +``` + +**Requirement:** *Optional* + +---- ### ISP_LOCK_FUSE_PRE + +**Description:** + Bootloader unlock bits. -Usually can be auto-detected from boards.txt +Usually can be auto-detected from `boards.txt` -*Example*: 0x3f +**Example:** -Optional. +```Makefile +ISP_LOCK_FUSE_PRE = 0x3f +``` + +**Requirement:** *Optional* + +---- ### ISP_LOCK_FUSE_POST + +**Description:** + Bootloader lock bits. -Usually can be auto-detected from boards.txt +Usually can be auto-detected from `boards.txt` -*Example*: 0xcf +**Example:** -Optional. +```Makefile +ISP_LOCK_FUSE_POST = 0xcf +``` + +**Requirement:** *Optional* + +---- ### ISP_HIGH_FUSE -SP_LOW_FUSE/ISP_EXT_FUSE - high/low/extended fuse bits. -Usually can be auto-detected from boards.txt +**Description:** -*Example*: 0xdf or 0xff or 0x01 +`ISP_LOW_FUSE/ISP_EXT_FUSE` - high/low/extended fuse bits. -Optional. +Usually can be auto-detected from `boards.txt` + +**Example:** + +```Makefile +ISP_HIGH_FUSE = 0xdf # or 0xff or 0x01 +``` + +**Requirement:** *Optional* + +---- ### ISP_EEPROM + +**Description:** + Whether to upload the EEPROM file or not. -Defaults to 0 +Defaults to `0` -*Example*: 1 +**Example:** -Optional. +```Makefile +ISP_EEPROM = 1 +``` + +**Requirement:** *Optional* + +---- ## Compiler/Executable variables ### CC_NAME + +**Description:** + C compiler. -Defaults to avr-gcc +Defaults to `avr-gcc` -*Example*: pic32-gcc +**Example:** -Optional. +```Makefile +CC_NAME = pic32-gcc +``` + +**Requirement:** *Optional* + +---- ### CXX_NAME + +**Description:** + C++ compiler. -Defaults to avr-g++ +Defaults to `avr-g++` -*Example*: pic32-g++ +**Example:** -Optional. +```Makefile +CXX_NAME = pic32-g++ +``` + +**Requirement:** *Optional* + +---- ### OBJCOPY_NAME + +**Description:** + Objcopy utility. -Defaults to avr-objcopy +Defaults to `avr-objcopy` -*Example*: pic32-objcopy +**Example:** -Optional. +```Makefile +OBJCOPY_NAME = pic32-objcopy +``` + +**Requirement:** *Optional* + +---- ### OBJDUMP_NAME + +**Description:** + Objdump utility. -Defaults to avr-objdump +Defaults to `avr-objdump` -*Example*: pic32-objdump +**Example:** -Optional. +```Makefile +OBJDUMP_NAME = pic32-objdump +``` + +**Requirement:** *Optional* + +---- ### AR_NAME + +**Description:** + Archive utility. -Defaults to avr-ar +Defaults to `avr-ar` -*Example*: pic32-ar +**Example:** -Optional. +```Makefile +AR_NAME = pic32-ar +``` + +**Requirement:** *Optional* + +---- ### SIZE_NAME + +**Description:** + Size utility. -Defaults to avr-size +Defaults to `avr-size` -*Example*: pic32-size +**Example:** -Optional. +```Makefile +SIZE_NAME = pic32-size +``` + +**Requirement:** *Optional* + +---- ### NM_NAME + +**Description:** + Nm utility. -Defaults to avr-nm +Defaults to `avr-nm` -*Example*: pic32-nm +**Example:** -Optional. +```Makefile +NM_NAME = pic32-nm +``` + +**Requirement:** *Optional* + +---- ### OPTIMIZATION_LEVEL -Linker's -O flag -Defaults to s, which shouldn't really be changed as it breaks SoftwareSerial and usually results in bigger hex files. +**Description:** -*Example*: 3 +Linker's `-O` flag -Optional. +Defaults to `s`, which shouldn't really be changed as it breaks `SoftwareSerial` and usually results in bigger hex files. + +**Example:** + +```Makefile +OPTIMIZATION_LEVEL = 3 +``` + +**Requirement:** *Optional* + +---- ### CFLAGS_STD + +**Description:** + Flags to pass to the C compiler. -Defaults to -std=gnu99 +Defaults to `-std=gnu99` -*Example*: +**Example:** -Optional. +```Makefile + +``` + +**Requirement:** *Optional* + +---- ### OVERRIDE_EXECUTABLES + +**Description:** + Override the default build tools. -If set to 1 each tool (CC, CXX, AS, OBJCOPY, OBJDUMP, AR, SIZE, NM) must have its path explicitly defined. See chipKIT.mk +If set to `1`, each tool (`CC`, `CXX`, `AS`, `OBJCOPY`, `OBJDUMP`, `AR`, `SIZE`, `NM`) must have its path explicitly defined. See `chipKIT.mk`. -*Example*: 1 +**Example:** -Optional. +```Makefile +OVERRIDE_EXECUTABLES = 1 +``` + +**Requirement:** *Optional* + +---- ### MONITOR_CMD + +**Description:** + Command to run the serial monitor. -Defaults to screen +Defaults to `screen` -*Example*: minicom +**Example:** -Optional. +```Makefile +MONITOR_CMD = minicom +``` + +**Requirement:** *Optional* + +---- ## Avrdude setting variables ### AVRDUDE -Path to avrdude utility -Usually can be auto-detected within the parent of `AVR_TOOLS_DIR` or in the $PATH +**Description:** -*Example*: /usr/bin/avrdude +Path to `avrdude` utility -Optional. +Usually can be auto-detected within the parent of `AVR_TOOLS_DIR` or in the `$PATH` + +**Example:** + +```Makefile +AVRDUDE = /usr/bin/avrdude +``` + +**Requirement:** *Optional* + +---- ### AVRDUDE_CONF -Path to avrdude.conf file -Usually can be auto-detected within the parent of `AVR_TOOLS_DIR` +**Description:** -*Example*: /etc/avrdude.conf or /usr/share/arduino/hardware/tools/avrdude.conf +Path to `avrdude.conf` file -Optional. +Usually can be auto-detected within the parent of `AVR_TOOLS_DIR` + +**Example:** + +```Makefile +AVRDUDE_CONF = /etc/avrdude.conf +# or +AVRDUDE_CONF = /usr/share/arduino/hardware/tools/avrdude.conf +``` + +**Requirement:** *Optional* + +---- ### AVR_TOOLS_PATH -Directory where tools such as avrdude, avr-g++, avr-gcc etc. are stored. -Usually can be auto-detected from AVR_TOOLS_DIR/bin +**Description:** -*Example*: /usr/bin or /usr/share/arduino/hardware/tools/avr/bin +Directory where tools such as `avrdude`, `avr-g++`, `avr-gcc` etc. are stored. -Optional. +Usually can be auto-detected from `AVR_TOOLS_DIR/bin` + +**Example:** + +```Makefile +AVR_TOOLS_PATH = /usr/bin +# or +AVR_TOOLS_PATH = /usr/share/arduino/hardware/tools/avr/bin +``` + +**Requirement:** *Optional* + +---- ### ARDUINO_LIB_PATH + +**Description:** + Directory where the standard Arduino libraries are stored. -Defaults to ARDUINO_DIR/libraries +Defaults to `ARDUINO_DIR/libraries` -*Example*: /usr/share/arduino/libraries (Linux) +**Example:** -Optional. +```Makefile +# Linux +ARDUINO_LIB_PATH = /usr/share/arduino/libraries +``` + +**Requirement:** *Optional* + +---- ### ARDUINO_CORE_PATH + +**Description:** + Directory where the standard Arduino cores are stored. -Defaults to ARDUINO_DIR/hardware/arduino/cores/arduino +Defaults to `ARDUINO_DIR/hardware/arduino/cores/arduino` -*Example*: /usr/share/arduino/hardware/arduino/cores/robot +**Example:** -Optional. +```Makefile +ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino/cores/robot +``` + +**Requirement:** *Optional* + +---- ### ALTERNATE_CORE_PATH + +**Description:** + Path to non-standard cores. -Defaults to ARDUINO_SKETCHBOOK/hardware/ALTERNATE_CORE +Defaults to `ARDUINO_SKETCHBOOK/hardware/ALTERNATE_CORE` -*Example*: ~/sketchbook/hardware/arduino-tiny/cores/tiny +**Example:** -Optional. +```Makefile +ALTERNATE_CORE_PATH = ~/sketchbook/hardware/arduino-tiny/cores/tiny +``` + +**Requirement:** *Optional* + +---- ### BOARDS_TXT -Path to boards.txt -Defaults to ARDUINO_DIR/hardware/arduino/boards.txt +**Description:** -*Example*: ~/sketchbook/hardware/boards.txt or /usr/share/arduino/hardware/arduino/boards.txt (Linux) +Path to `boards.txt` -Optional. +Defaults to `ARDUINO_DIR/hardware/arduino/boards.txt` + +**Example:** + +```Makefile +BOARD_TXT = ~/sketchbook/hardware/boards.txt +# or +BOARD_TXT = /usr/share/arduino/hardware/arduino/boards.txt +``` + +**Requirement:** *Optional* + +---- ### AVRDUDE_ARD_BAUDRATE + +**Description:** + Upload speed -Usually can be auto-detected as upload.speed from boards.txt +Usually can be auto-detected as `upload.speed` from `boards.txt` -*Example*: 19200 +**Example:** -Optional. +```Makefile +AVRDUDE_ARD_BAUDRATE = 19200 +``` + +**Requirement:** *Optional* + +---- ### AVRDUDE_ARD_PROGRAMMER + +**Description:** + Upload protocol -Usually can be auto-detected as upload.protocol from boards.txt +Usually can be auto-detected as `upload.protocol` from `boards.txt` -*Example*: stk500v1 +**Example:** -Optional. +```Makefile +AVRDUDE_ARD_PROGRAMMER = stk500v1 +``` + +**Requirement:** *Optional* + +---- ### AVRDUDE_ISP_BAUDRATE -ISP speed if different to upload.speed -Defaults to same as `AVRDUDE_ARD_BAUDRATE` or 19200 +**Description:** -*Example*: 19200 +ISP speed if different to `upload.speed` -Optional. +Defaults to same as `AVRDUDE_ARD_BAUDRATE` or `19200` + +**Example:** + +```Makefile +AVRDUDE_ISP_BAUDRATE = 19200 +``` + +**Requirement:** *Optional* + +---- ### AVRDUDE_OPTS -Options to pass to avrdude. -Defaults to '-q -V -D' (quiet, don't verify, don't auto-erase). User values are not ANDed to the defaults, you have to set each option you require. +**Description:** -*Example*: -v +Options to pass to `avrdude`. -Optional. +Defaults to `-q -V -D` (quiet, don't verify, don't auto-erase). User values are not *ANDed* to the defaults, you have to set each option you require. + +**Example:** + +```Makefile +AVRDUDE_OPTS = -v +``` + +**Requirement:** *Optional* + +---- ## Bootloader variables ### BOOTLOADER_FILE + +**Description:** + File for bootloader. -Usually can be auto-detected as bootloader.file from boards.txt +Usually can be auto-detected as `bootloader.file` from `boards.txt` -*Example*: optiboot_atmega328.hex +**Example:** -Optional. +```Makefile +BOOTLOADER_FILE = optiboot_atmega328.hex +``` + +**Requirement:** *Optional* + +---- ### BOOTLOADER_PATH + +**Description:** + Path to bootloader file. -Usually can be auto-detected as a relative bootloader.path from boards.txt +Usually can be auto-detected as a relative `bootloader.path` from `boards.txt` -*Example*: optiboot or arduino:atmega or /usr/share/arduino/hardware/arduino/bootloaders/caterina/Caterina-Esplora.hex +**Example:** -Optional. +```Makefile +BOOTLOADER_PATH = optiboot +# or +BOOTLOADER_PATH = arduino:atmega +# or +BOOTLOADER_PATH = /usr/share/arduino/hardware/arduino/bootloaders/caterina/Caterina-Esplora.hex +``` + +**Requirement:** *Optional* + +---- ## ChipKIT variables ### MPIDE_DIR + +**Description:** + Path to chipKIT MP IDE -Usually can be auto-detected as `AUTO_MPIDE_DIR` from the defaults /usr/share/mpide (Linux) or /Applications/Mpide.app/Contents/Resources/Java (OSX) +Usually can be auto-detected as `AUTO_MPIDE_DIR` from the defaults `/usr/share/mpide` (Linux) or `/Applications/Mpide.app/Contents/Resources/Java` (OSX) -*Example*: ~/mpide +**Example:** -Optional. +```Makefile +MPIDE_DIR = ~/mpide +``` + +**Requirement:** *Optional* + +---- ### MPIDE_PREFERENCES_PATH -Path to chipKIT preferences.txt file. -Usually can be auto-detected as `AUTO_MPIDE_PREFERENCES_PATH` from the defaults ~/.mpide/preferences.txt (Linux) or ~/Library/Mpide/preferences.txt (OSX) +**Description:** -*Example*: ~/chipkit/preferences.txt +Path to chipKIT `preferences.txt` file. -Optional. +Usually can be auto-detected as `AUTO_MPIDE_PREFERENCES_PATH` from the defaults `~/.mpide/preferences.txt` (Linux) or `~/Library/Mpide/preferences.txt` (OSX) + +**Example:** + +```Makefile +MPIDE_PREFERENCES_PATH = ~/chipkit/preferences.txt +``` + +**Requirement:** *Optional* From f1a79dbb3f6a5d06e9d6ddbacc8d6a378dcaec47 Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Mon, 10 Mar 2014 12:50:06 -0400 Subject: [PATCH 04/15] Fix AVR tools paths for chipKIT in Linux. Fix #175 Fix #174 --- HISTORY.md | 1 + chipKIT.mk | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 6a8befc..469a835 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,6 +12,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - New: Create `Makefile-example-mk`, a *real life* `Makefile` example, to be used as a reference. (https://github.com/tinyladi) - Tweak: Add `OBJDIR` to `arduino-mk-vars.md` (https://github.com/tinyladi) - Tweak: *Beautify* `arduino-mk-vars.md` with code blocks. (https://github.com/tinyladi) +- Fix: AVR tools paths for chipKIT in Linux. (https://github.com/peplin) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/chipKIT.mk b/chipKIT.mk index 1adfda2..19a4a4a 100644 --- a/chipKIT.mk +++ b/chipKIT.mk @@ -57,8 +57,13 @@ ifndef MPIDE_PREFERENCES_PATH endif endif +# The same as in Arduino, the Linux distribution contains avrdude and # +# avrdude.conf in a different location, but for chipKIT it's even slightly +# different than the Linux paths for Arduino, so we have to "double override". ifeq ($(CURRENT_OS),LINUX) - BUNDLED_AVR_TOOLS_DIR = $(call dir_if_exists,$(MPIDE_DIR)/hardware/tools) + AVRDUDE_DIR = $(ARDUINO_DIR)/hardware/tools + AVRDUDE = $(AVRDUDE_DIR)/avrdude + AVRDUDE_CONF = $(AVRDUDE_DIR)/avrdude.conf endif PIC32_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools From ce89531226ea89bf5750bf5236eec2304119ebdf Mon Sep 17 00:00:00 2001 From: Geoff Holden Date: Fri, 14 Mar 2014 16:10:18 -0230 Subject: [PATCH 05/15] Fix: Consider usb... to be a valid ISP_PORT AVRDUDE requires -P usb to be passed as an argument for some ISP devices, and it is also required in the case where you have multiple usbtiny or usbasp devices connected at once to select a specific one. Fix #167 --- Arduino.mk | 10 +++++++--- HISTORY.md | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Arduino.mk b/Arduino.mk index 767f493..508c7ab 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -836,7 +836,7 @@ endif get_monitor_port = $(if $(wildcard $(DEVICE_PATH)),$(firstword $(wildcard $(DEVICE_PATH))),$(error Arduino port $(DEVICE_PATH) not found!)) # Returns the ISP port (first wildcard expansion) if it exists, otherwise it errors. -get_isp_port = $(if $(wildcard $(ISP_PORT)),$(firstword $(wildcard $(ISP_PORT))),$(error ISP port $(ISP_PORT) not found!)) +get_isp_port = $(if $(wildcard $(ISP_PORT)),$(firstword $(wildcard $(ISP_PORT))),$(if $(findstring Xusb,X$(ISP_PORT)),$(ISP_PORT),$(error ISP port $(ISP_PORT) not found!))) # Command for avr_size: do $(call avr_size,elffile,hexfile) ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) @@ -1075,8 +1075,12 @@ endif AVRDUDE_ISP_OPTS = -c $(ISP_PROG) -b $(AVRDUDE_ISP_BAUDRATE) -ifneq ($(strip $(ISP_PROG)),$(filter $(ISP_PROG), usbasp usbtiny gpio)) - AVRDUDE_ISP_OPTS += -P $(call get_isp_port) +ifndef $(ISP_PORT) + ifneq ($(strip $(ISP_PROG)),$(filter $(ISP_PROG), usbasp usbtiny gpio)) + AVRDUDE_ISP_OPTS += -P $(call get_isp_port) + endif +else + AVRDUDE_ISP_OPTS += -P $(call get_isp_port) endif ifndef ISP_EEPROM diff --git a/HISTORY.md b/HISTORY.md index 469a835..a70ac82 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -13,6 +13,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Tweak: Add `OBJDIR` to `arduino-mk-vars.md` (https://github.com/tinyladi) - Tweak: *Beautify* `arduino-mk-vars.md` with code blocks. (https://github.com/tinyladi) - Fix: AVR tools paths for chipKIT in Linux. (https://github.com/peplin) +- Fix: Consider usb or usb:... to be a valid ISP_PORT (https://github.com/geoffholden) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) From ffde764adaa56cf00296857c8fd4a821b6b2e506 Mon Sep 17 00:00:00 2001 From: Julien Ridoux Date: Fri, 14 Mar 2014 10:42:35 +1100 Subject: [PATCH 06/15] Add phony target to run pre-build hook script Fix #176 --- Arduino.mk | 15 +++++++++++++-- Common.mk | 8 ++++++++ HISTORY.md | 1 + arduino-mk-vars.md | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Arduino.mk b/Arduino.mk index 508c7ab..84d8af5 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -465,6 +465,13 @@ else $(call show_config_variable,USER_LIB_PATH,[USER]) endif +ifndef PRE_BUILD_HOOK + PRE_BUILD_HOOK = pre-build-hook.sh + $(call show_config_variable,PRE_BUILD_HOOK,[DEFAULT]) +else + $(call show_config_variable,PRE_BUILD_HOOK,[USER]) +endif + ######################################################################## # boards.txt parsing @@ -1106,9 +1113,12 @@ all: $(TARGET_EEP) $(TARGET_HEX) # prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prerequisite # list) to prevent remaking the target when any file in the directory # changes. -$(OBJDIR): +$(OBJDIR): pre-build $(MKDIR) $(OBJDIR) +pre-build: + $(call runscript_if_exists,$(PRE_BUILD_HOOK)) + $(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm @@ -1118,6 +1128,7 @@ $(CORE_LIB): $(CORE_OBJS) $(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 @@ -1244,7 +1255,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 + generate_assembly verify_size burn_bootloader help pre-build # added - in the beginning, so that we don't get an error if the file is not present -include $(DEPS) diff --git a/Common.mk b/Common.mk index a94c37f..9aa36b8 100644 --- a/Common.mk +++ b/Common.mk @@ -4,6 +4,14 @@ # (directory and optional filename) exists dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) +# Run a shell script if it exists. Stops make on error. +runscript_if_exists = \ + $(if $(wildcard $(1)), \ + $(if $(findstring 0, \ + $(lastword $(shell $(abspath $(wildcard $(1))); echo $$?))), \ + $(info Info: $(1) success), \ + $(error ERROR: $(1) failed))) + # 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)) diff --git a/HISTORY.md b/HISTORY.md index a70ac82..a911d65 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -14,6 +14,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Tweak: *Beautify* `arduino-mk-vars.md` with code blocks. (https://github.com/tinyladi) - Fix: AVR tools paths for chipKIT in Linux. (https://github.com/peplin) - Fix: Consider usb or usb:... to be a valid ISP_PORT (https://github.com/geoffholden) +- Add: Add phony target to run pre-build hook script (https://github.com/jrid) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index f8eb9a8..51e32ae 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -776,6 +776,25 @@ MONITOR_CMD = minicom ---- +### PRE_BUILD_HOOK + +**Description:** + +Path to shell script to be executed before build. Could be used to automatically +bump revision number for example. + +Defaults to `pre-build-hook.sh` + +**Example:** + +```Makefile +PRE_BUILD_HOOK = ~/bin/bump-revision.sh +``` + +**Requirement:** *Optional* + +---- + ## Avrdude setting variables ### AVRDUDE From 5599d2ab1e23d66640b53e3951f92102f933fbdc Mon Sep 17 00:00:00 2001 From: Simon John Date: Mon, 24 Mar 2014 00:53:30 +0000 Subject: [PATCH 07/15] Add `BOOTLOADER_PARENT` which has to be set if the user sets either of the other two BOOTLOADER variables Fix #178 --- HISTORY.md | 1 + arduino-mk-vars.md | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index a911d65..92b3d02 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -15,6 +15,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: AVR tools paths for chipKIT in Linux. (https://github.com/peplin) - Fix: Consider usb or usb:... to be a valid ISP_PORT (https://github.com/geoffholden) - Add: Add phony target to run pre-build hook script (https://github.com/jrid) +- Fix: Add BOOTLOADER_PARENT to `arduino-mk-vars.md` and fixed BOOTLOADER_PATH example. (https://github.com/sej7278) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 51e32ae..b18aa2b 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -1026,7 +1026,7 @@ BOOTLOADER_FILE = optiboot_atmega328.hex **Description:** -Path to bootloader file. +Relative path to bootloader directory. Usually can be auto-detected as a relative `bootloader.path` from `boards.txt` @@ -1036,14 +1036,34 @@ Usually can be auto-detected as a relative `bootloader.path` from `boards.txt` BOOTLOADER_PATH = optiboot # or BOOTLOADER_PATH = arduino:atmega -# or -BOOTLOADER_PATH = /usr/share/arduino/hardware/arduino/bootloaders/caterina/Caterina-Esplora.hex ``` **Requirement:** *Optional* ---- +### BOOTLOADER_PARENT + +**Description:** + +Absolute path to bootloader file's parent directory. + +Defaults to `/usr/share/arduino/hardware/arduino/bootloaders` (Linux) + +**Example:** + +```Makefile +BOOTLOADER_PARENT = ~/sketchbook/hardware/promicro/bootloaders +BOOTLOADER_PATH = caterina +BOOTLOADER_FILE = Caterina-promicro16.hex +``` + +Would result in an absolute path to the bootloader hex file of `~/sketchbook/hardware/promicro/bootloaders/caterina/Caterina-promicro16.hex` + +**Requirement:** *Optional, unless BOOTLOADER_FILE and/or BOOTLOADER_PATH are user-defined* + +---- + ## ChipKIT variables ### MPIDE_DIR From 392a6b9db1ce64099c15daa61c2e2ca964f95453 Mon Sep 17 00:00:00 2001 From: Simon John Date: Mon, 24 Mar 2014 13:27:36 +0000 Subject: [PATCH 08/15] replace perl reset script with python one Fix #180 Fix #127 --- HISTORY.md | 1 + README.md | 22 ++-- bin/ard-reset-arduino | 174 ++++++------------------------- packaging/debian/README.md | 2 +- packaging/fedora/README.md | 2 +- packaging/fedora/arduino-mk.spec | 9 +- 6 files changed, 53 insertions(+), 157 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 92b3d02..731591b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -16,6 +16,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: Consider usb or usb:... to be a valid ISP_PORT (https://github.com/geoffholden) - Add: Add phony target to run pre-build hook script (https://github.com/jrid) - Fix: Add BOOTLOADER_PARENT to `arduino-mk-vars.md` and fixed BOOTLOADER_PATH example. (https://github.com/sej7278) +- Tweak: Replace perl reset script with Python script. (https://github.com/sej7278) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/README.md b/README.md index d658789..5441f66 100644 --- a/README.md +++ b/README.md @@ -34,30 +34,36 @@ package and can be installed using `apt-get` or `aptitude`. You need to have the Arduino IDE. You can either install it through the installer or download the distribution zip file and extract it. -The Makefile also delegates resetting the board to a short Perl program. -You'll need to install `Device::SerialPort` to use it though. +The Makefile also delegates resetting the board to a short Python program. +You'll need to install `pySerial` to use it though. On Debian or Ubuntu: - apt-get install libdevice-serialport-perl + apt-get install python-serial On Fedora: - yum install perl-Device-SerialPort + yum install pyserial On openSUSE: - zypper install perl-Device-SerialPort + zypper install python-serial On Mac using MacPorts: - sudo port install p5-device-serialport + sudo port install py27-serial - and use /opt/local/bin/perl5 instead of /usr/bin/perl +On Windows: + + pySerial can be downloaded from PyPi On other systems: - cpan Device::SerialPort + pip install pyserial + + or + + easy_install -U pyserial ## Usage diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index bb52736..ec23023 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,147 +1,37 @@ -#!/usr/bin/env perl +#!/usr/bin/python -use strict; -use warnings; +import serial +import os.path +import argparse +from time import sleep -use Device::SerialPort; -use Getopt::Long; -use Pod::Usage; +parser = argparse.ArgumentParser(description='Reset an Arduino') +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() -my %Opt = - ( - period => 0.1, - ); - -GetOptions(\%Opt, - "period=f", # width of reset pulse in seconds - "verbose!", - "help!", - "info!", - "caterina!", - ); - -if ($Opt{help} || $Opt{info}) - { - usage(); - } - -die "No Arduinos found!\n" - unless @ARGV; - -foreach my $dev (@ARGV) - { - my $p = Device::SerialPort->new($dev) - or die "Unable to open $dev: $!\n"; - - if ($Opt{caterina}) - { - $p->baudrate(1200); - $p->write_settings; - $p->close; - - print STDERR "Forcing reset using 1200bps open/close on port $dev\n" - if $Opt{verbose}; - - # wait for it to come back - sleep 1; - while( ! -e $dev ) { - print STDERR "Waiting for $dev to come back\n" - if $Opt{verbose}; - sleep 1; - } - - print STDERR "$dev has come back after reset\n" - if $Opt{verbose}; - } - else - { - my $dt = $Opt{period}; - - print STDERR "Setting DTR high for ${dt}s on $dev\n" - if $Opt{verbose}; - - die "Invalid pulse width ($dt), " - unless $dt > 0.0; - - $p->pulse_dtr_on($dt * 1000.0); - } - } - -## here endeth the main - -sub usage - { - pod2usage(-verbose => 2); - } - -__END__ - -=head1 NAME - -ard-reset-arduino - Reset an Arduino - -=head1 USAGE - - $ ard-reset-arduino /dev/cu.usb* - - $ ard-reset-arduino --verbose --period=0.1 /dev/cu.usb* - - $ ard-reset-arduino --verbose --caterina /dev/ttyUSB0 - -=head1 DESCRIPTION - -To reset (most) Arduinos, it's enough to just pulse the DTR line. - -You can do that from the shell with stty, but there's an interesting -diversity of command flags. This little program gives a uniform interface -at the cost of requiring C. - -=head1 OPTIONS - -=over - -=item --verbose - -Watch what's going on on STDERR. - -=item --period=0.25 - -Specify the DTR pulse width in seconds. - -=item --caterina - -Reset a Leonardo, Micro, Robot or LilyPadUSB. - -=back - -=head1 BUGS AND LIMITATIONS - -There are no known bugs in this application. - -Please report problems to the author. - -Patches are welcome. - -=head1 AUTHOR - -Martin Oldfield, ex-atelier@mjo.tc - -Support for Leonardo/Micro added by sej7278, https://github.com/sej7278 - -Thanks to Daniele Vergini who suggested this to me, and supplied -a command line version. - -=head1 LICENCE AND COPYRIGHT - -Copyright (c) 2012, Martin Oldfield. All rights reserved. - -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. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +if 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() + ser.open() + ser.close() + ser.setBaudrate(1200) + ser.open() + ser.close() + sleep(1) + while not os.path.exists(args.port[0]): + if args.verbose: print 'Waiting for %s to come back' % args.port[0] + sleep(1) + if args.verbose: print '%s has come back after reset' % args.port[0] +else: + if args.verbose: print 'Setting DTR high on %s for %ss' % (args.port[0],args.period) + ser = serial.Serial(args.port[0], 115200) + ser.setDTR(False) + sleep(args.period) + ser.setDTR(True) + ser.close() diff --git a/packaging/debian/README.md b/packaging/debian/README.md index 26efa5a..c89bb43 100644 --- a/packaging/debian/README.md +++ b/packaging/debian/README.md @@ -7,7 +7,7 @@ or [Ubuntu](https://launchpad.net/ubuntu/+source/arduino-mk) or use apt. First install the dependencies for building/running the package, as root: apt-get build-dep arduino-mk - apt-get install arduino-core libdevice-serialport-perl help2man build-essential dpkg-dev fakeroot perl-doc devscripts + apt-get install arduino-core build-essential dpkg-dev fakeroot devscripts python-serial Fetch the Debian source: diff --git a/packaging/fedora/README.md b/packaging/fedora/README.md index 18c5955..37219cb 100644 --- a/packaging/fedora/README.md +++ b/packaging/fedora/README.md @@ -2,7 +2,7 @@ First install the dependencies as root: - yum install arduino-core perl-Device-SerialPort help2man rpm-build + yum install arduino-core rpm-build pyserial From the top-level Arduino-Makefile directory you've checked out of github, run the following (as unprivileged user) to create a compressed tarball using the naming conventions required by rpmbuild: diff --git a/packaging/fedora/arduino-mk.spec b/packaging/fedora/arduino-mk.spec index f8d6a07..88f4083 100644 --- a/packaging/fedora/arduino-mk.spec +++ b/packaging/fedora/arduino-mk.spec @@ -9,8 +9,8 @@ Group: Development/Tools License: LGPLv2+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch -Requires: arduino-core, perl-Device-SerialPort -BuildRequires: arduino-core, perl-Device-SerialPort, help2man +Requires: arduino-core pyserial +BuildRequires: arduino-core pyserial %description Arduino is an open-source electronics prototyping platform based on @@ -27,7 +27,6 @@ Arduino platform. %install mkdir -p %{buildroot}/%{_datadir}/arduino mkdir -p %{buildroot}/%{_bindir} -mkdir -p %{buildroot}/%{_mandir}/man1 mkdir -p %{buildroot}/%{_docdir}/%{name}/examples install -m 755 -d %{buildroot}/%{_docdir}/%{name} install -m 755 -d %{buildroot}/%{_docdir}/%{name}/examples @@ -36,7 +35,6 @@ for file in `find examples -type f ! -name .gitignore` ; do install -m 644 $file install -m 644 *.mk arduino-mk-vars.md %{buildroot}/%{_datadir}/arduino install -m 644 licence.txt %{buildroot}/%{_docdir}/%{name} install -m 755 bin/ard-reset-arduino %{buildroot}/%{_bindir}/ard-reset-arduino -help2man %{buildroot}/%{_bindir}/ard-reset-arduino -n "Reset Arduino board" -s 1 -m "Arduino CLI Reset" --version-string=%{version} -N -o %{buildroot}/%{_mandir}/man1/ard-reset-arduino.1 %clean rm -rf %{buildroot} @@ -44,7 +42,6 @@ rm -rf %{buildroot} %files %defattr(-,root,root,-) %{_bindir}/ard-reset-arduino -%{_mandir}/man1/ard-reset-arduino.1* %{_datadir}/arduino/*.mk %{_datadir}/arduino/arduino-mk-vars.md %doc %{_docdir}/%{name}/licence.txt @@ -52,6 +49,8 @@ rm -rf %{buildroot} %{_docdir}/%{name}/examples %changelog +* Mon Mar 24 2014 Simon John +- Replaced perl/help2man with pyserial for reset script. * Tue Feb 04 2014 Simon John - Added arduino-mk-vars.md to the files to be installed/packaged. * Sat Feb 01 2014 Simon John From c080fb29b769576b4b92f58b4c32b69a82f6e13f Mon Sep 17 00:00:00 2001 From: Simon John Date: Wed, 2 Apr 2014 17:57:58 +0100 Subject: [PATCH 09/15] python3 compatibility --- HISTORY.md | 1 + bin/ard-reset-arduino | 11 ++++++----- packaging/debian/README.md | 2 +- packaging/fedora/README.md | 2 +- packaging/fedora/arduino-mk.spec | 4 +++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 731591b..261d1e1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -17,6 +17,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Add: Add phony target to run pre-build hook script (https://github.com/jrid) - Fix: Add BOOTLOADER_PARENT to `arduino-mk-vars.md` and fixed BOOTLOADER_PATH example. (https://github.com/sej7278) - Tweak: Replace perl reset script with Python script. (https://github.com/sej7278) +- Tweak: Made choice of Python2/3 interpreter up to the OS. (https://github.com/peplin) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index ec23023..ed22a63 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,5 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python +from __future__ import print_function import serial import os.path import argparse @@ -13,7 +14,7 @@ parser.add_argument('port', nargs=1, help='Serial device e.g. /dev/ttyACM0') args = parser.parse_args() if args.caterina: - if args.verbose: print 'Forcing reset using 1200bps open/close on port %s' % args.port[0] + 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() ser.open() @@ -24,12 +25,12 @@ if args.caterina: sleep(1) while not os.path.exists(args.port[0]): - if args.verbose: print 'Waiting for %s to come back' % args.port[0] + if args.verbose: print('Waiting for %s to come back' % args.port[0]) sleep(1) - if args.verbose: print '%s has come back after reset' % args.port[0] + if args.verbose: print('%s has come back after reset' % args.port[0]) else: - if args.verbose: print 'Setting DTR high on %s for %ss' % (args.port[0],args.period) + if args.verbose: print('Setting DTR high on %s for %ss' % (args.port[0],args.period)) ser = serial.Serial(args.port[0], 115200) ser.setDTR(False) sleep(args.period) diff --git a/packaging/debian/README.md b/packaging/debian/README.md index c89bb43..6385780 100644 --- a/packaging/debian/README.md +++ b/packaging/debian/README.md @@ -7,7 +7,7 @@ or [Ubuntu](https://launchpad.net/ubuntu/+source/arduino-mk) or use apt. First install the dependencies for building/running the package, as root: apt-get build-dep arduino-mk - apt-get install arduino-core build-essential dpkg-dev fakeroot devscripts python-serial + apt-get install arduino-core build-essential dpkg-dev fakeroot devscripts python-serial python3-serial Fetch the Debian source: diff --git a/packaging/fedora/README.md b/packaging/fedora/README.md index 37219cb..63117f9 100644 --- a/packaging/fedora/README.md +++ b/packaging/fedora/README.md @@ -2,7 +2,7 @@ First install the dependencies as root: - yum install arduino-core rpm-build pyserial + yum install arduino-core rpm-build pyserial python3-pyserial From the top-level Arduino-Makefile directory you've checked out of github, run the following (as unprivileged user) to create a compressed tarball using the naming conventions required by rpmbuild: diff --git a/packaging/fedora/arduino-mk.spec b/packaging/fedora/arduino-mk.spec index 88f4083..4958515 100644 --- a/packaging/fedora/arduino-mk.spec +++ b/packaging/fedora/arduino-mk.spec @@ -10,7 +10,7 @@ License: LGPLv2+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires: arduino-core pyserial -BuildRequires: arduino-core pyserial +BuildRequires: arduino-core pyserial python3-pyserial %description Arduino is an open-source electronics prototyping platform based on @@ -49,6 +49,8 @@ rm -rf %{buildroot} %{_docdir}/%{name}/examples %changelog +* Wed Apr 02 2014 Simon John +- Added BuildRequires of python3-pyserial. Need to look into Requires. * Mon Mar 24 2014 Simon John - Replaced perl/help2man with pyserial for reset script. * Tue Feb 04 2014 Simon John From 7b5a163e9a5cabf1b30ab5bac51f2a51195c4514 Mon Sep 17 00:00:00 2001 From: Simon John Date: Fri, 4 Apr 2014 21:54:26 +0100 Subject: [PATCH 10/15] simplified packaging by removing dependencies on python3/pyserial --- HISTORY.md | 1 + packaging/debian/README.md | 4 ++-- packaging/fedora/README.md | 2 +- packaging/fedora/arduino-mk.spec | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 261d1e1..7c126da 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -18,6 +18,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: Add BOOTLOADER_PARENT to `arduino-mk-vars.md` and fixed BOOTLOADER_PATH example. (https://github.com/sej7278) - Tweak: Replace perl reset script with Python script. (https://github.com/sej7278) - Tweak: Made choice of Python2/3 interpreter up to the OS. (https://github.com/peplin) +- Tweak: Simplified packaging dependencies. (https://github.com/sej7278) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/packaging/debian/README.md b/packaging/debian/README.md index 6385780..44dcaa6 100644 --- a/packaging/debian/README.md +++ b/packaging/debian/README.md @@ -4,10 +4,10 @@ Use these instructions to build your own Deb package from your local sources. For the latest official packages go to [Debian](http://packages.debian.org/arduino-mk) or [Ubuntu](https://launchpad.net/ubuntu/+source/arduino-mk) or use apt. -First install the dependencies for building/running the package, as root: +First install the dependencies as root: apt-get build-dep arduino-mk - apt-get install arduino-core build-essential dpkg-dev fakeroot devscripts python-serial python3-serial + apt-get install arduino-core build-essential dpkg-dev fakeroot devscripts Fetch the Debian source: diff --git a/packaging/fedora/README.md b/packaging/fedora/README.md index 63117f9..86ec456 100644 --- a/packaging/fedora/README.md +++ b/packaging/fedora/README.md @@ -2,7 +2,7 @@ First install the dependencies as root: - yum install arduino-core rpm-build pyserial python3-pyserial + yum install arduino-core rpm-build From the top-level Arduino-Makefile directory you've checked out of github, run the following (as unprivileged user) to create a compressed tarball using the naming conventions required by rpmbuild: diff --git a/packaging/fedora/arduino-mk.spec b/packaging/fedora/arduino-mk.spec index 4958515..5fdbed7 100644 --- a/packaging/fedora/arduino-mk.spec +++ b/packaging/fedora/arduino-mk.spec @@ -10,7 +10,7 @@ License: LGPLv2+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires: arduino-core pyserial -BuildRequires: arduino-core pyserial python3-pyserial +BuildRequires: arduino-core %description Arduino is an open-source electronics prototyping platform based on @@ -49,6 +49,8 @@ rm -rf %{buildroot} %{_docdir}/%{name}/examples %changelog +* Fri Apr 04 2014 Simon John +- Removed BuildRequires of python3/pyserial. * Wed Apr 02 2014 Simon John - Added BuildRequires of python3-pyserial. Need to look into Requires. * Mon Mar 24 2014 Simon John From 32d35da2a0162b1b06ea7926e01a496dfacedc98 Mon Sep 17 00:00:00 2001 From: EAGMnor Date: Fri, 11 Apr 2014 15:13:42 +0200 Subject: [PATCH 11/15] Tweak AVRdude conf file detection in windows On windows the AVRdude configuration file is now detected properly. The comments and `README` are updated as well. Fix #187 --- Arduino.mk | 27 +++++++++++++++++++++++++++ HISTORY.md | 1 + README.md | 24 +++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Arduino.mk b/Arduino.mk index 84d8af5..31ce76f 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -56,6 +56,24 @@ # ARDMK_DIR = /usr/share/arduino # 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. +# +# ARDUINO_DIR =../../../../../Arduino +# AVR_TOOLS_DIR =../../../../../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 +# For this use the command mklink on the console. +# +# # You can either set these up in the Makefile, or put them in your # environment e.g. in your .bashrc # @@ -395,6 +413,15 @@ ifndef AVR_TOOLS_DIR else $(call show_config_variable,AVR_TOOLS_DIR,[USER]) + + # Check in Windows as Cygwin is being used, that the configuration file for the AVRDUDE is set + # Check if it works on MAC + ifeq ($(CURRENT_OS),WINDOWS) + ifndef AVRDUDE_CONF + AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf + endif + endif + endif #ndef AVR_TOOLS_DIR ifndef AVR_TOOLS_PATH diff --git a/HISTORY.md b/HISTORY.md index 7c126da..c093a99 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -19,6 +19,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Tweak: Replace perl reset script with Python script. (https://github.com/sej7278) - Tweak: Made choice of Python2/3 interpreter up to the OS. (https://github.com/peplin) - Tweak: Simplified packaging dependencies. (https://github.com/sej7278) +- Tweak: Tweak AVRDUDE conf detection in windows. (https://github.com/EAGMnor) ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) diff --git a/README.md b/README.md index 5441f66..5898daa 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ On Mac using MacPorts: On Windows: +You need to install Cygwin and its packages for Make, Perl and the next Serial library. + pySerial can be downloaded from PyPi On other systems: @@ -93,12 +95,32 @@ On Windows (using cygwin), you might want to set: MONITOR_PORT = com3 BOARD_TAG = mega2560 +It is recommended in Windows that you create a symbolic link directory for avoiding problem with folder naming conventions on Windows. Specially if your your Arduino folder is in: + +c:\Program Files (x86)\Arduino + +You will get problem for the special characters on the folder name. More details about this can be found on https://github.com/sudar/Arduino-Makefile/issues/94 + +For creating a symbolic link you have to use the command “mklink” on Windows, e.g. + +mklink /d c:\Arduino c:\Program Files (x86)\Arduino + +At the end the variables end up being. + +ARDUINO_DIR=../../../../../Arduino + +Instead of + +ARDUINO_DIR=../../../../../Program\ Files\ \(x86\)/Arduino + + + - `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. +- `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. The list of all variables that can be overridden is available at [arduino-mk-vars.md](arduino-mk-vars.md) file. From ba2b27db28e1029f07c30569185c8a2b7848f6db Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 11 Apr 2014 20:26:11 +0530 Subject: [PATCH 12/15] Bump up version to v1.3.2 for release --- HISTORY.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index c093a99..c0e7758 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,7 +4,7 @@ A Makefile for Arduino Sketches 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. -### 1.3.2 (in development) +### 1.3.2 (2014-04-11) - Fix: Add arduino-mk-vars.md file to RPM SPECfile. (https://github.com/sej7278) - Fix: Add avr-libc/malloc.c and realloc.c to included core files. Fixes issue #163 (https://github.com/sej7278) - Fix: Add "gpio" to the list of isp that don't have a port. (Issue #165, #166) (https://github.com/sej7278) diff --git a/README.md b/README.md index 5898daa..5c91764 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ It is possible to use [`colorgcc`](https://github.com/colorgcc/colorgcc) with th ## Versioning -The current version of the makefile is `1.3.1`. You can find the full history in the [HISTORY.md](HISTORY.md) file +The current version of the makefile is `1.3.2`. You can find the full history in the [HISTORY.md](HISTORY.md) file This project adheres to Semantic [Versioning 2.0](http://semver.org/). From fc54954d0f6da51ea05f83002dca47b4a276e16f Mon Sep 17 00:00:00 2001 From: Simon John Date: Sat, 12 Apr 2014 00:36:11 +0200 Subject: [PATCH 13/15] Add manpage back to specfile Includes following changes - change author info - add examples section Fix #188 --- ard-reset-arduino.1 | 48 ++++++++++++++++++++++++++++++++ packaging/fedora/arduino-mk.spec | 5 ++++ 2 files changed, 53 insertions(+) create mode 100644 ard-reset-arduino.1 diff --git a/ard-reset-arduino.1 b/ard-reset-arduino.1 new file mode 100644 index 0000000..fa05597 --- /dev/null +++ b/ard-reset-arduino.1 @@ -0,0 +1,48 @@ +.TH ARD-RESET-ARDUINO "1" "April 2014" "ard-reset-arduino 1.3.2" "Arduino CLI Reset" + +.SH NAME +ard-reset-arduino \- Reset Arduino board + +.SH SYNOPSIS +.B ard-reset-arduino +[OPTION]... [PORT] + +.SH DESCRIPTION +To reset Arduinos, we either pulse the DTR line or open the USB port +at 1200 baud and close it again. + +.SH OPTIONS +.B --verbose +Watch what's going on on STDERR. + +.B --period +Specify the DTR pulse width in seconds. + +.B --caterina +Reset a Leonardo, Micro, Robot, LilyPadUSB or similar 32u4-based device. + +.SH EXAMPLES +ard-reset-arduino /dev/ttyACM0 +.PP +ard-reset-arduino --verbose --period=0.1 /dev/cu.usb* +.PP +ard-reset-arduino --verbose --caterina /dev/ttyUSB0 + +.SH BUGS +There are no known bugs in this application. Please report problems +to the author. Patches are welcome. + +.SH AUTHOR +Simon John, git@the-jedi.co.uk + +.SH LICENSE +Copyright (c) 2014, Simon John. All rights reserved. +.PP +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. +.PP +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/packaging/fedora/arduino-mk.spec b/packaging/fedora/arduino-mk.spec index 5fdbed7..febd3b3 100644 --- a/packaging/fedora/arduino-mk.spec +++ b/packaging/fedora/arduino-mk.spec @@ -27,6 +27,7 @@ Arduino platform. %install mkdir -p %{buildroot}/%{_datadir}/arduino mkdir -p %{buildroot}/%{_bindir} +mkdir -p %{buildroot}/%{_mandir}/man1 mkdir -p %{buildroot}/%{_docdir}/%{name}/examples install -m 755 -d %{buildroot}/%{_docdir}/%{name} install -m 755 -d %{buildroot}/%{_docdir}/%{name}/examples @@ -35,6 +36,7 @@ for file in `find examples -type f ! -name .gitignore` ; do install -m 644 $file install -m 644 *.mk arduino-mk-vars.md %{buildroot}/%{_datadir}/arduino install -m 644 licence.txt %{buildroot}/%{_docdir}/%{name} install -m 755 bin/ard-reset-arduino %{buildroot}/%{_bindir}/ard-reset-arduino +install -m 644 ard-reset-arduino.1 %{buildroot}/%{_mandir}/man1 %clean rm -rf %{buildroot} @@ -42,6 +44,7 @@ rm -rf %{buildroot} %files %defattr(-,root,root,-) %{_bindir}/ard-reset-arduino +%{_mandir}/man1/ard-reset-arduino.1* %{_datadir}/arduino/*.mk %{_datadir}/arduino/arduino-mk-vars.md %doc %{_docdir}/%{name}/licence.txt @@ -49,6 +52,8 @@ rm -rf %{buildroot} %{_docdir}/%{name}/examples %changelog +* Sat Apr 12 2014 Simon John +- Put manpage back. * Fri Apr 04 2014 Simon John - Removed BuildRequires of python3/pyserial. * Wed Apr 02 2014 Simon John From b42d05d8b1bcd204336c889c9d83176e3dcea17d Mon Sep 17 00:00:00 2001 From: Simon John Date: Sat, 12 Apr 2014 17:12:42 +0200 Subject: [PATCH 14/15] Bump up version to v1.3.3 for release Fix #189 --- Arduino.mk | 2 +- HISTORY.md | 3 +++ README.md | 2 +- ard-reset-arduino.1 | 2 +- packaging/fedora/README.md | 4 ++-- packaging/fedora/arduino-mk.spec | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Arduino.mk b/Arduino.mk index 31ce76f..ff395d0 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -19,7 +19,7 @@ # # Original Arduino adaptation by mellis, eighthave, oli.keller # -# Current version: 1.3.2 +# Current version: 1.3.3 # # Refer to HISTORY.md file for complete history of changes # diff --git a/HISTORY.md b/HISTORY.md index c0e7758..3ecd0d5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,9 @@ A Makefile for Arduino Sketches 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. +### 1.3.3 (2014-04-12) +- Fix: Make a new manpage for ard-reset-arduino. Fixes issue #188 (https://github.com/sej7278) + ### 1.3.2 (2014-04-11) - Fix: Add arduino-mk-vars.md file to RPM SPECfile. (https://github.com/sej7278) - Fix: Add avr-libc/malloc.c and realloc.c to included core files. Fixes issue #163 (https://github.com/sej7278) diff --git a/README.md b/README.md index 5c91764..4044e69 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ It is possible to use [`colorgcc`](https://github.com/colorgcc/colorgcc) with th ## Versioning -The current version of the makefile is `1.3.2`. You can find the full history in the [HISTORY.md](HISTORY.md) file +The current version of the makefile is `1.3.3`. You can find the full history in the [HISTORY.md](HISTORY.md) file This project adheres to Semantic [Versioning 2.0](http://semver.org/). diff --git a/ard-reset-arduino.1 b/ard-reset-arduino.1 index fa05597..818b66c 100644 --- a/ard-reset-arduino.1 +++ b/ard-reset-arduino.1 @@ -1,4 +1,4 @@ -.TH ARD-RESET-ARDUINO "1" "April 2014" "ard-reset-arduino 1.3.2" "Arduino CLI Reset" +.TH ARD-RESET-ARDUINO "1" "April 2014" "ard-reset-arduino 1.3.3" "Arduino CLI Reset" .SH NAME ard-reset-arduino \- Reset Arduino board diff --git a/packaging/fedora/README.md b/packaging/fedora/README.md index 86ec456..726dc87 100644 --- a/packaging/fedora/README.md +++ b/packaging/fedora/README.md @@ -6,7 +6,7 @@ First install the dependencies as root: From the top-level Arduino-Makefile directory you've checked out of github, run the following (as unprivileged user) to create a compressed tarball using the naming conventions required by rpmbuild: - git archive HEAD --prefix=arduino-mk-1.3.2/ -o ../arduino-mk-1.3.2.tar.gz + git archive HEAD --prefix=arduino-mk-1.3.3/ -o ../arduino-mk-1.3.3.tar.gz If you don't already have a rpmbuild setup (e.g. you've not installed the SRPM) you will need to create the directories: @@ -14,7 +14,7 @@ If you don't already have a rpmbuild setup (e.g. you've not installed the SRPM) Then copy the tarball and specfile into those directories: - cp ../arduino-mk-1.3.2.tar.gz ~/rpmbuild/SOURCES/ + cp ../arduino-mk-1.3.3.tar.gz ~/rpmbuild/SOURCES/ cp packaging/fedora/arduino-mk.spec ~/rpmbuild/SPECS/ Then compile. This will create a binary and source RPM: diff --git a/packaging/fedora/arduino-mk.spec b/packaging/fedora/arduino-mk.spec index febd3b3..d320f15 100644 --- a/packaging/fedora/arduino-mk.spec +++ b/packaging/fedora/arduino-mk.spec @@ -1,5 +1,5 @@ Name: arduino-mk -Version: 1.3.2 +Version: 1.3.3 Release: 1%{dist} Summary: Program your Arduino from the command line Packager: Simon John From aa4c96ce50aca9a98abbe8b0acb334f74f500d57 Mon Sep 17 00:00:00 2001 From: Pierre DAVID Date: Mon, 14 Apr 2014 08:39:46 +0200 Subject: [PATCH 15/15] Allow spaces in "Serial.begin (....)" Fix #190 Fix #191 --- Arduino.mk | 2 +- HISTORY.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Arduino.mk b/Arduino.mk index ff395d0..2448c03 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -702,7 +702,7 @@ endif ifeq ($(strip $(NO_CORE)),) ifndef MONITOR_BAUDRATE ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) - SPEED = $(shell egrep -h 'Serial.begin\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1) + SPEED = $(shell egrep -h 'Serial.begin *\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1) MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) endif diff --git a/HISTORY.md b/HISTORY.md index 3ecd0d5..21ca01e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,9 @@ A Makefile for Arduino Sketches 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. +### 1.3.4 (In development) +- Tweak: Allow spaces in "Serial.begin (....)". (Issue #190) (https://github.com/pdav) + ### 1.3.3 (2014-04-12) - Fix: Make a new manpage for ard-reset-arduino. Fixes issue #188 (https://github.com/sej7278)