diff --git a/Arduino.mk b/Arduino.mk index b0bac01..a5b9bba 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -458,12 +458,6 @@ endif ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries $(call show_config_variable,ARDUINO_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) -ifndef ARDUINO_CORE_PATH - ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/$(VENDOR)/$(ARCHITECTURE)/cores/arduino - $(call show_config_variable,ARDUINO_CORE_PATH,[DEFAULT]) -else - $(call show_config_variable,ARDUINO_CORE_PATH,[USER]) -endif # 1.5.x platform dependent libs path ifndef ARDUINO_PLATFORM_LIB_PATH @@ -565,6 +559,16 @@ endif # But the user might have to define MCU, F_CPU etc ifeq ($(strip $(NO_CORE)),) + # Select a core from the 'cores' directory. Two main values: 'arduino' or + # 'robot', but can also hold 'tiny', for example, if using + # https://code.google.com/p/arduino-tiny alternate core. + ifndef CORE + CORE = $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.core) | cut -d : -f 2) + $(call show_config_variable,CORE,[COMPUTED],(from build.core)) + else + $(call show_config_variable,CORE,[USER]) + endif + # Which variant ? This affects the include path ifndef VARIANT VARIANT = $(call PARSE_BOARD,$(BOARD_TAG),build.variant) @@ -689,6 +693,25 @@ else $(call show_config_variable,OBJDIR,[USER]) endif +# Now that we have ARDUINO_DIR, VENDOR, ARCHITECTURE and CORE, +# we can set ARDUINO_CORE_PATH. +ifndef ARDUINO_CORE_PATH + ifeq ($(strip $(CORE)),) + ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/$(VENDOR)/$(ARCHITECTURE)/cores/arduino + $(call show_config_variable,ARDUINO_CORE_PATH,[DEFAULT]) + else + ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/$(CORE) + ifeq ($(wildcard $(ARDUINO_CORE_PATH)),) + ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/$(VENDOR)/$(ARCHITECTURE)/cores/$(CORE) + $(call show_config_variable,ARDUINO_CORE_PATH,[COMPUTED],(from ARDUINO_DIR, BOARD_TAG and boards.txt)) + else + $(call show_config_variable,ARDUINO_CORE_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH, BOARD_TAG and boards.txt)) + endif + endif +else + $(call show_config_variable,ARDUINO_CORE_PATH,[USER]) +endif + ######################################################################## # Reset @@ -1031,11 +1054,22 @@ else $(call show_config_variable,DEVICE_PATH,[AUTODETECTED]) endif -# Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors. -ifeq ($(CURRENT_OS), WINDOWS) - get_monitor_port = $(COM_STYLE_MONITOR_PORT) +ifndef FORCE_MONITOR_PORT + $(call show_config_variable,FORCE_MONITOR_PORT,[DEFAULT]) else - get_monitor_port = $(if $(wildcard $(DEVICE_PATH)),$(firstword $(wildcard $(DEVICE_PATH))),$(error Arduino port $(DEVICE_PATH) not found!)) + $(call show_config_variable,FORCE_MONITOR_PORT,[USER]) +endif + +ifdef FORCE_MONITOR_PORT + # Skips the DEVICE_PATH existance check. + get_monitor_port = $(DEVICE_PATH) +else + # Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors. + ifeq ($(CURRENT_OS), WINDOWS) + get_monitor_port = $(COM_STYLE_MONITOR_PORT) + else + get_monitor_port = $(if $(wildcard $(DEVICE_PATH)),$(firstword $(wildcard $(DEVICE_PATH))),$(error Arduino port $(DEVICE_PATH) not found!)) + endif endif # Returns the ISP port (first wildcard expansion) if it exists, otherwise it errors. diff --git a/HISTORY.md b/HISTORY.md index 9a8f8cd..b7ccdd3 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 - New: Support for Teensy 3.x (https://github.com/stepcut) - New: Support for PuTTY under Windows (https://github.com/PeterMosmans) - New: Add support for installation using homebrew(https://github.com/ladislas) +- New: Add support and example for flashing on a remote RPi. (https://github.com/Gaboose) - Tweak: Update Malefile-example.mk with STD flags (https://github.com/ladislas) - Tweak: Allow remove of any OBJDIR with `$(REMOVE) $(OBJDIR)`. (https://github.com/ladislas) @@ -24,6 +25,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Tweak: Updated package instructions for Arch/Fedora/Raspbian. (https://github.com/sej7278) - Tweak: Remove $(EXTRA_XXX) variables (Issue #234) (https://github.com/ladislas) - Tweak: Moved location of avrdude for 1.5.8 on Linux (Issue #301) (https://github.com/sej7278) +- Tweak: Allow 'build.core' param as found in [arduino-tiny](https://code.google.com/p/arduino-tiny/) Prospective Boards.txt. (https://github.com/Gaboose) - Fix: Improved Windows (Cygwin/MSYS) support (https://github.com/PeterMosmans) - Fix: Change "tinyladi" username to "ladislas" in HISTORY.md. (https://github.com/ladislas) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 73bed78..4003a6c 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -316,6 +316,25 @@ MONITOR_PORT = com3 ---- +### FORCE_MONITOR_PORT + +**Description:** + +Skip the MONITOR_PORT existance check. + +**Example:** + +```Makefile +# Enable +FORCE_MONITOR_PORT = true +# Disable (default) +undefine FORCE_MONITOR_PORT +``` + +**Requirement:** *Optional* + +---- + ### USER_LIB_PATH **Description:** @@ -392,6 +411,29 @@ ARDUINO_VAR_PATH = ~/sketchbook/hardware/arduino-tiny/cores/tiny ---- +### CORE + +**Description:** + +Name of the core *inside* the ALTERNATE_CORE or the standard core. + +Usually can be auto-detected as `build.core` from `boards.txt`. + +**Example:** + +```Makefile +# standard Arduino core (undefine ALTERNATE_CORE) +CORE = arduino +# or +CORE = robot +# tiny core (ALTERNATE_CORE = arduino-tiny) +CORE = tiny +``` + +**Requirement:** *Optional* + +---- + ### VARIANT **Description:** diff --git a/examples/BlinkNetworkRPi/ATtinyBlink.ino b/examples/BlinkNetworkRPi/ATtinyBlink.ino new file mode 100644 index 0000000..1d1566d --- /dev/null +++ b/examples/BlinkNetworkRPi/ATtinyBlink.ino @@ -0,0 +1,23 @@ +/* + Blink + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + */ + +// Connect a LED to Pin 3. It might be different in different ATtiny micro controllers +int led = 3; + +// the setup routine runs once when you press reset: +void setup() { + // initialize the digital pin as an output. + pinMode(led, OUTPUT); +} + +// the loop routine runs over and over again forever: +void loop() { + digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) + delay(1000); // wait for a second + digitalWrite(led, LOW); // turn the LED off by making the voltage LOW + delay(1000); // wait for a second +} diff --git a/examples/BlinkNetworkRPi/Makefile b/examples/BlinkNetworkRPi/Makefile new file mode 100644 index 0000000..15e565e --- /dev/null +++ b/examples/BlinkNetworkRPi/Makefile @@ -0,0 +1,46 @@ +# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile + +# Tested and working with a linuxspi programmer on a remote Raspberry Pi +# Refer to https://github.com/kcuzner/avrdude for linuxspi. +# Should work with ISP as well if you replace $(AVRDUDE_ARD_OPTS) with +# $(AVRDUDE_ISP_OPTS) in the net_set_fuses rule. + +# Alternate core from https://code.google.com/p/arduino-tiny +ALTERNATE_CORE = tiny +BOARD_TAG = attiny85at8 + +# Avrdude config path on the remote Raspberry Pi +AVRDUDE_CONF=/usr/local/etc/avrdude.conf + +# Skip the monitor port existance check since it's not on our machine. +FORCE_MONITOR_PORT=true +MONITOR_PORT=/dev/spidev0.0 + +include ../../Arduino.mk + + +# Additional rules to use a remote Raspberry Pi programmer + +# Note that it's recommended not to use root for this task, +# but to setup spidev access on a normal user instead. +HOST = root@alarmpi +SSH_AVRDUDE = ssh $(HOST) /usr/local/bin/avrdude + +CAT_HEX = cat $(TARGET_HEX) +AVRDUDE_UPLOAD_PIPE = -U flash:w:-:i + +.PHONY: net_upload net_set_fuses + +net_upload: $(TARGET_HEX) verify_size + $(CAT_HEX) | $(SSH_AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ + $(AVRDUDE_UPLOAD_PIPE) + +net_set_fuses: +ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),) + $(SSH_AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) -e \ + $(AVRDUDE_ISP_FUSES_PRE) +endif +ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),) + $(SSH_AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ + $(AVRDUDE_ISP_FUSES_POST) +endif diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh index f45fa3f..1c54836 100755 --- a/tests/script/runtests.sh +++ b/tests/script/runtests.sh @@ -7,7 +7,7 @@ failures=() # 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 BlinkTeensy) +NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkTeensy BlinkNetworkRPi) for dir in $TESTS_DIR/*/ do