From 06bc8d6aa388b1f24789c5f29e312eb199e74619 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 23 Aug 2012 12:39:31 -0500 Subject: [PATCH 01/28] Allow passing extra flags --- arduino-mk/Arduino.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index d50ff22..dc2ee0f 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -575,10 +575,10 @@ CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ -ffunction-sections -fdata-sections -CFLAGS = -std=gnu99 -CXXFLAGS = -fno-exceptions +CFLAGS = -std=gnu99 $(EXTRA_FLAGS) $(EXTRA_CFLAGS) +CXXFLAGS = -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp -LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os +LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) # Expand and pick the first port ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) From aaed1fc6faefb93fb810a5f28491c764ffb032e2 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 23 Aug 2012 12:39:42 -0500 Subject: [PATCH 02/28] Make listing files more useful --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index dc2ee0f..5dad154 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -705,7 +705,7 @@ $(OBJDIR)/%.eep: $(OBJDIR)/%.elf --change-section-lma .eeprom=0 -O ihex $< $@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf - $(OBJDUMP) -h -S $< > $@ + $(OBJDUMP) -h --source --demangle --wide $< > $@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(NM) -n $< > $@ From c6fef7c499a21ec1443f540957ae2f4ae3544841 Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 16:05:21 +0100 Subject: [PATCH 03/28] Added installation notes for Fedora as per Rickard Lindberg's patch; tweaked notes for other OSs --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f086c92..8dfd6f8 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,23 @@ On Linux, you might prefer: AVR_TOOLS_DIR = /usr The Makefile also delegates resetting the board to a short Perl program. -You'll need to install Device::SerialPort to use it though. On Debian or -Ubuntu do +You'll need to install Device::SerialPort to use it though. You'll also +need the YAML library to run ard-parse-boards. + +On Debian or Ubuntu: apt-get install libdevice-serial-perl + apt-get install libyaml-perl -On other systems +On Fedora: + + yum install perl-Device-SerialPort + yum install perl-YAML + +On other systems: cpanm Device::SerialPort + cpanm YAML ## User Libraries From b15aa4e88f25c48badfe2545835a148bb8f67243 Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 16:14:40 +0100 Subject: [PATCH 04/28] Made the size target look at the ELF file, not the hex, as per Jared Szechy's patch. Craig Leres made a similar comment --- arduino-mk/Arduino.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5261afa..38d8217 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -679,8 +679,8 @@ clean: depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) -size: $(OBJDIR) $(TARGET_HEX) - $(SIZE) $(TARGET_HEX) +size: $(OBJDIR) $(TARGET_ELF) + $(SIZE) -C --mcu=$(MCU) $(TARGET_ELF) show_boards: $(PARSE_BOARD_CMD) --boards From 22b4a0834ab7c5123df908fd546198688c96023c Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 16:25:21 +0100 Subject: [PATCH 05/28] Fixed ARDUNIO/ARDUINO typo in README.md as per Kalin Kozhuharov's comment --- README.md | 2 +- arduino-mk/Arduino.mk | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8dfd6f8..a55efbf 100644 --- a/README.md +++ b/README.md @@ -60,5 +60,5 @@ On other systems: In order to use Arduino libraries installed in the user's sketchbook folder (the standard location for custom libraries when using the Arduino IDE), you need to -set the `ARDUNIO_SKETCHBOOK` variable to point to this directory. By default it +set the `ARDUINO_SKETCHBOOK` variable to point to this directory. By default it is set to `$HOME/sketchbook`. diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 38d8217..315eddc 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -418,7 +418,9 @@ ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended endif # Everything gets built in here -OBJDIR = build-cli +ifndef OBJDIR +OBJDIR = build-$(BOARD_TAG) +endif ######################################################################## # Local sources From 03c80333a48c6c3b8706c6393c90bec8bc5f8aa1 Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 16:29:31 +0100 Subject: [PATCH 06/28] Only set OBJDIR if it is not already set; if we do set it make it $BOARD_TAG dependent. This follows comments from Matthias Urlichs and Scott Howard --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 315eddc..dc8aa6c 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -417,7 +417,7 @@ ifndef ISP_EXT_FUSE ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses) endif -# Everything gets built in here +# Everything gets built in here (include BOARD_TAG now) ifndef OBJDIR OBJDIR = build-$(BOARD_TAG) endif From c02da764aca6b6553d7d9b5d9dbdb6f4148e5cb6 Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 16:34:12 +0100 Subject: [PATCH 07/28] Changed the name of the Debian/Ubuntu package to arduino-mk (just a documentation patch) as per Scott Howard's comment --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a55efbf..0d949ae 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html "Documentation") exists. If you're using Debian or Ubuntu, you can find this in the -arduino-core package. +arduino-mk package. # Important Changes, 2012-04-29 From 9395817c96766004fa01d062c2cdaca659852a17 Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 16:38:46 +0100 Subject: [PATCH 08/28] Only set AVRDUDE_CONF if it's not set, as per Tom Hall's patch --- arduino-mk/Arduino.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index dc8aa6c..f12637d 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -285,9 +285,11 @@ ifdef ARDUINO_DIR ifndef AVR_TOOLS_DIR AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/tools/avr -# The avrdude bundled with Arduino can't find it's config +# The avrdude bundled with Arduino can't find its config +ifndef AVRDUDE_CONF AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf endif +endif ifndef AVR_TOOLS_PATH AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin From 869b5d85161c3e59f4ff05419eb6d70dfdc1a6ed Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 17:06:48 +0100 Subject: [PATCH 09/28] Added support for the USB PID/VID needed for the Leonardo, as per patches from Dan Villiom Podlaski Christiansen and Marc Plano-Lesay --- arduino-mk/Arduino.mk | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index f12637d..6a6fcc7 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -389,6 +389,15 @@ ifndef F_CPU F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) endif +# USB IDs for the Leonardo +ifndef USB_VID +USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid) +endif + +ifndef USB_PID +USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid) +endif + # normal programming info ifndef AVRDUDE_ARD_PROGRAMMER AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol) @@ -501,7 +510,9 @@ USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(USER_LIB_ CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ + -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) \ -ffunction-sections -fdata-sections + CFLAGS = -std=gnu99 CXXFLAGS = -fno-exceptions ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp From 184230fcf2ac9075fee642be8948d406913cb7df Mon Sep 17 00:00:00 2001 From: Martin Oldfield Date: Mon, 17 Sep 2012 18:08:22 +0100 Subject: [PATCH 10/28] Added changelog --- arduino-mk/Arduino.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 6a6fcc7..09819ac 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -77,6 +77,18 @@ # - Moved the reset target to Perl for # clarity and better error handling (ex # Daniele Vergini) +# +# 0.10 17.ix.12 M J Oldfield +# - Added installation notes for Fedora (ex Rickard Lindberg). +# - Changed size target so that it looks at the ELF object, +# not the hexfile (ex Jared Szechy and Scott Howard). +# - Fixed ARDUNIO typo in README.md (ex Kalin Kozhuharov). +# - Tweaked OBJDIR handling (ex Matthias Urlichs and Scott Howard). +# - Changed the name of the Debian/Ubuntu package (ex +# Scott Howard). +# - Only set AVRDUDE_CONF if it's not set (ex Tom Hall). +# - Added support for USB_PID/VID used by the Leonardo (ex Dan +# Villiom Podlaski Christiansen and Marc Plano-Lesay). # ######################################################################## # From 87060fa5c2d1f55375f643ac98f7c7818a8615ce Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:28:42 -0500 Subject: [PATCH 11/28] Add knowledge of device-specific assembler --- arduino-mk/Arduino.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5dad154..a71def9 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -536,6 +536,7 @@ DEP_FILE = $(OBJDIR)/depends.mk # Names of executables CC = $(AVR_TOOLS_PATH)/avr-gcc CXX = $(AVR_TOOLS_PATH)/avr-g++ +AS = $(AVR_TOOLS_PATH)/avr-as OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump AR = $(AVR_TOOLS_PATH)/avr-ar From 24c2366f26d68f242353a8d5471320fe56adde47 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:29:15 -0500 Subject: [PATCH 12/28] Use variables instead of hardcoded commands --- arduino-mk/Arduino.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index a71def9..0fb384b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -697,8 +697,8 @@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp # various object conversions $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(OBJCOPY) -O ihex -R .eeprom $< $@ - @echo - @echo + @$(ECHO) + @$(ECHO) $(call avr_size,$<,$@) $(OBJDIR)/%.eep: $(OBJDIR)/%.elf @@ -787,7 +787,7 @@ clean: $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) depends: $(DEPS) - cat $(DEPS) > $(DEP_FILE) + $(CAT) $(DEPS) > $(DEP_FILE) size: $(OBJDIR) $(TARGET_HEX) $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) From 05a31db4817b57101d7a2a29fed099ed63e0a4c4 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:29:26 -0500 Subject: [PATCH 13/28] Make disasm more helpful --- arduino-mk/Arduino.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 0fb384b..5ed7206 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -798,7 +798,8 @@ show_boards: monitor: $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) -disasm: all $(OBJDIR)/$(TARGET).lss +disasm: $(OBJDIR)/$(TARGET).lss + @$(ECHO) The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss .PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor From 6041f6201da0cacedaec55504cf31365120dbe30 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:29:36 -0500 Subject: [PATCH 14/28] Change .sym output --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5ed7206..e564369 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -709,7 +709,7 @@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(OBJDUMP) -h --source --demangle --wide $< > $@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf - $(NM) -n $< > $@ + $(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@ ######################################################################## # From 84648978fbdcd569e12ac43579d452941b78a3e1 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:30:46 -0500 Subject: [PATCH 15/28] Provide symbol_sizes and generated_assembly targets. Also update existing auxiliary targets with help, and make the .PHONY list complete and in order. --- arduino-mk/Arduino.mk | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index e564369..5179f9d 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -687,6 +687,13 @@ $(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(OBJDIR)/%.d: $(OBJDIR)/%.cpp $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) +# generated assembly +$(OBJDIR)/%.s: $(OBJDIR)/%.cpp + $(CXX) -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +#$(OBJDIR)/%.lst: $(OBJDIR)/%.s +# $(AS) -mmcu=$(MCU) -alhnd $< > $@ + # core files $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ @@ -801,6 +808,12 @@ monitor: disasm: $(OBJDIR)/$(TARGET).lss @$(ECHO) The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss -.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor +symbol_sizes: $(OBJDIR)/$(TARGET).sym + @$(ECHO) A symbol listing sorted by their size have been dumped to $(OBJDIR)/$(TARGET).sym + +generated_assembly: $(OBJDIR)/$(TARGET).s + @$(ECHO) Compiler-generated assembly for the main input source has been dumped to $(OBJDIR)/$(TARGET).s + +.PHONY: all upload raw_upload reset reset_stty ispload clean depends size show_boards monitor disasm symbol_sizes generated_assembly include $(DEP_FILE) From 184b482a98a5047726250507baae5d16d81bb804 Mon Sep 17 00:00:00 2001 From: Alex Szczuczko Date: Tue, 25 Sep 2012 21:34:26 -0400 Subject: [PATCH 16/28] Update boards_txt path in bin/ard-parse-boards to include environment variable ARDUINO_DIR This corrects the behaviour of ard-parse-boards --boards , which would fail if the path to boards.txt on the system didn't match the value which was hardcoded. --- bin/ard-parse-boards | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index e2de71b..de046c0 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -9,7 +9,7 @@ use YAML; my %Opt = ( - boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt', + boards_txt => "$ENV{'ARDUINO_DIR'}/hardware/arduino/boards.txt", ); GetOptions(\%Opt, From adbd6532f9877b646d41f039cc1fd4cdd787d54b Mon Sep 17 00:00:00 2001 From: Andreas Lohr Date: Sun, 7 Oct 2012 10:28:10 +0200 Subject: [PATCH 17/28] set USB_VID and USB_PID only for leonardo boards --- arduino-mk/Arduino.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 09819ac..450e482 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -401,6 +401,7 @@ ifndef F_CPU F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) endif +ifeq ($(VARIANT),leonardo) # USB IDs for the Leonardo ifndef USB_VID USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid) @@ -409,6 +410,7 @@ endif ifndef USB_PID USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid) endif +endif # normal programming info ifndef AVRDUDE_ARD_PROGRAMMER From 77f8ee0d77b4029300e0fda877db8e091f25c5d0 Mon Sep 17 00:00:00 2001 From: Andreas Lohr Date: Sun, 7 Oct 2012 10:33:22 +0200 Subject: [PATCH 18/28] use perl from /opt/local --- bin/ard-parse-boards | 2 +- bin/ard-reset-arduino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index e2de71b..a18d5b7 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /opt/local/bin/perl5 use strict; use warnings; diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index 22c7109..17548d6 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /opt/local/bin/perl5 use strict; use warnings; From 4241eccacc6a64cff1638a393a96a8a34acda9d3 Mon Sep 17 00:00:00 2001 From: Andreas Lohr Date: Sun, 7 Oct 2012 11:54:14 +0200 Subject: [PATCH 19/28] added MacPorts --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 0d949ae..9351277 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,13 @@ On Fedora: yum install perl-Device-SerialPort yum install perl-YAML +On Mac using MacPorts: + + sudo port install p5-device-serialport + sudo port install p5-YAML + + and use /opt/local/bin/perl5 instead of /usr/bin/perl + On other systems: cpanm Device::SerialPort From 86b7b034dc241ca3469d199e67ad3b278ef80114 Mon Sep 17 00:00:00 2001 From: Alistair MacLeod Date: Sun, 21 Oct 2012 21:05:56 +0100 Subject: [PATCH 20/28] Changed shebang to use /usr/bin/env --- bin/ard-parse-boards | 2 +- bin/ard-reset-arduino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index e2de71b..9f690e2 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /usr/bin/env perl use strict; use warnings; diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index 22c7109..085e442 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /usr/bin/env perl use strict; use warnings; From bc8caf8358dfb1c87bcbdef107fe5a7d74b37c4a Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Thu, 1 Nov 2012 12:01:54 +0100 Subject: [PATCH 21/28] Fixing problem of hanging upload. --- arduino-mk/Arduino.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 8fc8e5c..84d6573 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -848,6 +848,8 @@ raw_upload: $(TARGET_HEX) reset: $(RESET_CMD) $(ARD_PORT) + sleep 1 # If avrdude is called to early after the reset, the upload may + # hang. # stty on MacOS likes -F, but on Debian it likes -f redirecting # stdin/out appears to work but generates a spurious error on MacOS at From a814a9c276bd6586f50e366f8df32c2c93ee7651 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 1 Nov 2012 10:33:46 -0500 Subject: [PATCH 22/28] Be able to silence configuration output --- arduino-mk/Arduino.mk | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5179f9d..b90f81b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -124,6 +124,8 @@ # instead copy them to e.g. /home/mjo/arduino.mk/bin then set # ARDML_DIR = /home/mjo/arduino.mk # +# If you'd rather not see the configuration output, define ARDUINO_QUIET. +# ######################################################################## # # DEPENDENCIES @@ -254,19 +256,25 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # the number of bytes indicated by the second argument. space_pad_to = $(shell echo $(1) " " | head --bytes=$(2)) +ifndef ARDUINO_QUIET + arduino_output = $(info $(1)) +else + arduino_output = +endif + # Call with some text, and a prefix tag if desired (like [AUTODETECTED]), -show_config_info = $(info - $(call space_pad_to,$(2),20) $(1)) +show_config_info = $(call arduino_output,- $(call space_pad_to,$(2),20) $(1)) # Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]), # and an explanation if desired (like (found in $$PATH) show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2)) # Just a nice simple visual separator -show_separator = $(info -------------------------) +show_separator = $(call arduino_output,-------------------------) $(call show_separator) -$(info Arduino.mk Configuration:) +$(call arduino_output,Arduino.mk Configuration:) ifndef ARDUINO_DIR AUTO_ARDUINO_DIR := $(firstword \ @@ -598,7 +606,7 @@ endif ifneq (,$(strip $(ARDUINO_LIBS))) - $(info -) + $(call arduino_output,-) $(call show_config_info,ARDUINO_LIBS =) endif ifneq (,$(strip $(USER_LIB_NAMES))) From ee98d0c89b66adb5c54c0867d14d6c72261ef9a9 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 1 Nov 2012 10:34:09 -0500 Subject: [PATCH 23/28] Make everybody depend on the makefile, in case cflags are changed, etc. --- arduino-mk/Arduino.mk | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index b90f81b..a12c5d2 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -649,81 +649,82 @@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c # normal local sources # .o rules are for objects, .d for dependency tracking # there seems to be an awful lot of duplication here!!! -$(OBJDIR)/%.o: %.c +COMMON_DEPS := Makefile +$(OBJDIR)/%.o: %.c $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.cc +$(OBJDIR)/%.o: %.cc $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.cpp +$(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.S +$(OBJDIR)/%.o: %.S $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.s +$(OBJDIR)/%.o: %.s $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ -$(OBJDIR)/%.d: %.c +$(OBJDIR)/%.d: %.c $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.cc +$(OBJDIR)/%.d: %.cc $(COMMON_DEPS) $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.cpp +$(OBJDIR)/%.d: %.cpp $(COMMON_DEPS) $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.S +$(OBJDIR)/%.d: %.S $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.s +$(OBJDIR)/%.d: %.s $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) # the pde -> cpp -> o file -$(OBJDIR)/%.cpp: %.pde +$(OBJDIR)/%.cpp: %.pde $(COMMON_DEPS) $(ECHO) '#include "WProgram.h"' > $@ $(CAT) $< >> $@ # the ino -> cpp -> o file -$(OBJDIR)/%.cpp: %.ino +$(OBJDIR)/%.cpp: %.ino $(COMMON_DEPS) $(ECHO) '#include ' > $@ $(CAT) $< >> $@ -$(OBJDIR)/%.o: $(OBJDIR)/%.cpp +$(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.d: $(OBJDIR)/%.cpp +$(OBJDIR)/%.d: $(OBJDIR)/%.cpp $(COMMON_DEPS) $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) # generated assembly -$(OBJDIR)/%.s: $(OBJDIR)/%.cpp +$(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) $(CXX) -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ #$(OBJDIR)/%.lst: $(OBJDIR)/%.s # $(AS) -mmcu=$(MCU) -alhnd $< > $@ # core files -$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # various object conversions -$(OBJDIR)/%.hex: $(OBJDIR)/%.elf +$(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS) $(OBJCOPY) -O ihex -R .eeprom $< $@ @$(ECHO) @$(ECHO) $(call avr_size,$<,$@) -$(OBJDIR)/%.eep: $(OBJDIR)/%.elf +$(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS) -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O ihex $< $@ -$(OBJDIR)/%.lss: $(OBJDIR)/%.elf +$(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(COMMON_DEPS) $(OBJDUMP) -h --source --demangle --wide $< > $@ -$(OBJDIR)/%.sym: $(OBJDIR)/%.elf +$(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS) $(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@ ######################################################################## From edd514d65cc70b140e2882900e461ce87294bdd8 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 1 Nov 2012 10:57:11 -0500 Subject: [PATCH 24/28] Make the makefile error if the arduino port is not present. --- arduino-mk/Arduino.mk | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index a12c5d2..84c451b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -589,8 +589,8 @@ CXXFLAGS = -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) -# Expand and pick the first port -ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) +# Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors. +get_arduino_port = $(if $(wildcard $(ARDUINO_PORT)),$(firstword $(wildcard $(ARDUINO_PORT))),$(error Arduino port $(ARDUINO_PORT) not found!)) # Command for avr_size: do $(call avr_size,elffile,hexfile) ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) @@ -740,7 +740,7 @@ ifdef AVRDUDE_CONF AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) endif -AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT) +AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(call get_arduino_port) ifndef ISP_PROG ISP_PROG = -c stk500v2 @@ -775,7 +775,7 @@ raw_upload: $(TARGET_HEX) -U flash:w:$(TARGET_HEX):i reset: - $(RESET_CMD) $(ARD_PORT) + $(RESET_CMD) $(call get_arduino_port) # stty on MacOS likes -F, but on Debian it likes -f redirecting # stdin/out appears to work but generates a spurious error on MacOS at @@ -784,9 +784,9 @@ reset_stty: for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \ do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \ done ;\ - $$STTYF $(ARD_PORT) hupcl ;\ + $$STTYF $(call get_arduino_port) hupcl ;\ (sleep 0.1 || sleep 1) ;\ - $$STTYF $(ARD_PORT) -hupcl + $$STTYF $(call get_arduino_port) -hupcl ispload: $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ @@ -812,7 +812,7 @@ show_boards: $(PARSE_BOARD_CMD) --boards monitor: - $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) + $(MONITOR_CMD) $(call get_arduino_port) $(MONITOR_BAUDRATE) disasm: $(OBJDIR)/$(TARGET).lss @$(ECHO) The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss From 90e3c9ad0bb75d87e19d9eb017024aed55b544d1 Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Fri, 2 Nov 2012 12:51:53 +0100 Subject: [PATCH 25/28] Fix upload in case of parallelized make. --- arduino-mk/Arduino.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 84d6573..b47a025 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -840,16 +840,14 @@ $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) $(DEP_FILE): $(OBJDIR) $(DEPS) cat $(DEPS) > $(DEP_FILE) -upload: reset raw_upload +upload: raw_upload -raw_upload: $(TARGET_HEX) +raw_upload: reset $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ -U flash:w:$(TARGET_HEX):i reset: $(RESET_CMD) $(ARD_PORT) - sleep 1 # If avrdude is called to early after the reset, the upload may - # hang. # stty on MacOS likes -F, but on Debian it likes -f redirecting # stdin/out appears to work but generates a spurious error on MacOS at From b5448a64dc20f996a753c2cd3332e30be8df3ab8 Mon Sep 17 00:00:00 2001 From: Fabio Pugliese Ornellas Date: Mon, 12 Nov 2012 21:34:51 -0200 Subject: [PATCH 26/28] Added sketch size verification. --- arduino-mk/Arduino.mk | 15 +++++++++++---- bin/ard-verify-size | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100755 bin/ard-verify-size diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 09819ac..56204f9 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -445,6 +445,10 @@ ifndef OBJDIR OBJDIR = build-$(BOARD_TAG) endif +ifndef HEX_MAXIMUM_SIZE +HEX_MAXIMUM_SIZE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.maximum_size) +endif + ######################################################################## # Local sources # @@ -655,7 +659,7 @@ AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) # Explicit targets start here # -all: $(OBJDIR) $(TARGET_HEX) +all: $(OBJDIR) $(TARGET_HEX) verify_size $(OBJDIR): mkdir $(OBJDIR) @@ -671,7 +675,7 @@ $(DEP_FILE): $(OBJDIR) $(DEPS) upload: reset raw_upload -raw_upload: $(TARGET_HEX) +raw_upload: $(TARGET_HEX) verify_size $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ -U flash:w:$(TARGET_HEX):i @@ -689,7 +693,7 @@ reset_stty: (sleep 0.1 || sleep 1) ;\ $$STTYF $(ARD_PORT) -hupcl -ispload: $(TARGET_HEX) +ispload: $(TARGET_HEX) verify_size $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ -U lock:w:$(ISP_LOCK_FUSE_PRE):m \ -U hfuse:w:$(ISP_HIGH_FUSE):m \ @@ -715,6 +719,9 @@ show_boards: monitor: $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) -.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor +verify_size: $(TARGET_HEX) + $(ARDMK_PATH)/ard-verify-size $(TARGET_HEX) $(HEX_MAXIMUM_SIZE) + +.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor verify_size include $(DEP_FILE) diff --git a/bin/ard-verify-size b/bin/ard-verify-size new file mode 100755 index 0000000..2a7fa28 --- /dev/null +++ b/bin/ard-verify-size @@ -0,0 +1,9 @@ +#!/bin/bash +TARGET_HEX="$1" +MAX_SIZE="$2" +HEX_SIZE="$(cut -c12- < $TARGET_HEX | tr -d \\n | tr -d \\r | wc -c | awk '{print $1/2}')" +if [ $HEX_SIZE -gt $MAX_SIZE ] +then + echo "Sketch size is ${HEX_SIZE} bytes and maximum allowed is ${MAX_SIZE} bytes; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it." 1>&2 + exit 1 +fi From bfd9dac2167043b4e8b24324119bf89fd90c75bf Mon Sep 17 00:00:00 2001 From: Fabio Pugliese Ornellas Date: Mon, 12 Nov 2012 22:13:03 -0200 Subject: [PATCH 27/28] Added dummy file to verify_size to avoid always being run. --- arduino-mk/Arduino.mk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 56204f9..6cbf133 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -719,9 +719,12 @@ show_boards: monitor: $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) -verify_size: $(TARGET_HEX) +$(TARGET_HEX).sizeok: $(TARGET_HEX) $(ARDMK_PATH)/ard-verify-size $(TARGET_HEX) $(HEX_MAXIMUM_SIZE) + touch $@ -.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor verify_size +verify_size: $(TARGET_HEX) $(TARGET_HEX).sizeok + +.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitorx verify_size include $(DEP_FILE) From 9ebae306d0604273112f19e1311b9923c6a4af18 Mon Sep 17 00:00:00 2001 From: Adam Dunlap Date: Fri, 17 Aug 2012 11:50:05 -0700 Subject: [PATCH 28/28] Show original line number for error messages --- README.md | 1 + arduino-mk/Arduino.mk | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44a8d9f..593369c 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ The following are the list of changes that I have made or merged in this fork. H ### 0.10.2 15.xii.2012 Sudar - Added sketch size verification. (https://github.com/fornellas) +- Show original line number for error messages (https://github.com/WizenedEE) ## Know Issues - Because of the way the makefile is structured, the configuration parameters gets printed twice. diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 57680b5..605cbc1 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -143,6 +143,7 @@ # # 0.10.2 15.xii.2012 Sudar # - Added sketch size verification. (https://github.com/fornellas) +# - Show original line number for error messages (https://github.com/WizenedEE) # ######################################################################## # @@ -812,12 +813,12 @@ $(OBJDIR)/%.d: %.s $(COMMON_DEPS) # We should check for Arduino version, if the file is .pde because a .pde file might be used in Arduino 1.0 # the pde -> cpp -> o file $(OBJDIR)/%.cpp: %.pde $(COMMON_DEPS) - $(ECHO) '#if ARDUINO >= 100\n #include "Arduino.h"\n#else\n #include "WProgram.h"\n#endif' > $@ + $(ECHO) '#if ARDUINO >= 100\n #include "Arduino.h"\n#else\n #include "WProgram.h"\n#endif\n#line 1' > $@ $(CAT) $< >> $@ # the ino -> cpp -> o file $(OBJDIR)/%.cpp: %.ino $(COMMON_DEPS) - $(ECHO) '#include ' > $@ + $(ECHO) '#include \n#line 1' > $@ $(CAT) $< >> $@ $(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(COMMON_DEPS)