From 349d254013ad83dbfc570a36ba1a549b39f75623 Mon Sep 17 00:00:00 2001 From: Masataro Asai Date: Fri, 5 Apr 2013 17:44:10 +0900 Subject: [PATCH] arduino leonardo support. Reset leonardo and wait for the connection to be established. --- .gitignore | 1 + arduino-mk/Arduino.mk | 27 +++++++++++++++++++-------- bin/ard-reset-leonardo | 8 ++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100755 bin/ard-reset-leonardo diff --git a/.gitignore b/.gitignore index 7294495..5abd7ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o build-cli +*~ \ No newline at end of file diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 09819ac..be9bdcb 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -297,10 +297,10 @@ ifdef ARDUINO_DIR ifndef AVR_TOOLS_DIR AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/tools/avr +endif # The avrdude bundled with Arduino can't find its config ifndef AVRDUDE_CONF -AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf -endif +AVRDUDE_CONF = $(ARDUINO_DIR)/hardware/tools/avrdude.conf endif ifndef AVR_TOOLS_PATH @@ -358,12 +358,6 @@ ifndef MONITOR_CMD MONITOR_CMD = screen endif -######################################################################## -# Reset -ifndef RESET_CMD -RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) -endif - ######################################################################## # boards.txt parsing # @@ -445,6 +439,17 @@ ifndef OBJDIR OBJDIR = build-$(BOARD_TAG) endif + +######################################################################## +# Reset +ifndef RESET_CMD +ifeq ($(BOARD_TAG),leonardo) +RESET_CMD = $(ARDMK_PATH)/ard-reset-leonardo $(ARD_RESET_OPTS) +else +RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) +endif +endif + ######################################################################## # Local sources # @@ -672,10 +677,16 @@ $(DEP_FILE): $(OBJDIR) $(DEPS) upload: reset raw_upload raw_upload: $(TARGET_HEX) + while [ ! -e $(ARDUINO_PORT) ] ;\ + do \ + echo "Waiting for arduino at $(ARD_PORT)";\ + sleep 0.3 ;\ + done $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ -U flash:w:$(TARGET_HEX):i reset: + $(ECHO) "Resetting Arduino..." $(RESET_CMD) $(ARD_PORT) # stty on MacOS likes -F, but on Debian it likes -f redirecting diff --git a/bin/ard-reset-leonardo b/bin/ard-reset-leonardo new file mode 100755 index 0000000..7ad554e --- /dev/null +++ b/bin/ard-reset-leonardo @@ -0,0 +1,8 @@ +#! /usr/bin/python + +import sys +import serial + +ser = serial.Serial(sys.argv[1], 1200) +ser.open() +ser.close()