From 78f2363dd5c8e2e60bc82a3dd7ac68edc3ec0408 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 15 Jun 2013 19:23:26 +0530 Subject: [PATCH] Handle cases where certain fuse bits are not present Introduce two new variables AVRDUDE_ISP_FUSES_PRE and AVRDUDE_ISP_FUSES_POST which are set based on whether the fuse bits are present or not. avrdude is invoked to set fuse bits only if these new variables are not empty. Fix #61 --- HISTORY.md | 1 + arduino-mk/Arduino.mk | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index ea7a1e3..46e8e61 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,6 +8,7 @@ The following is the rough list of changes that went into different versions. I - Fix whitespace issues - Add a warning when HEX_MAXIMUM_SIZE is not specified - Add the ability to configure avrdude options. Fix issue #53 +- Handle cases where certain fuse bits are not present. Fix issue #61 ### 0.10.6 (2013-06-14) - Fix whitespace and add /dev/null redirection (https://github.com/sej7278) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 825aa95..bb95bf3 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -818,6 +818,34 @@ ifndef AVRDUDE_ISP_BAUDRATE AVRDUDE_ISP_BAUDRATE = 19200 endif +# Pre fuse settings +ifndef AVRDUDE_ISP_FUSES_PRE + + ifneq ($(strip $(ISP_LOCK_FUSE_PRE)),) + AVRDUDE_ISP_FUSES_PRE += -U lock:w:$(ISP_LOCK_FUSE_PRE):m + endif + + ifneq ($(strip $(ISP_HIGH_FUSE)),) + AVRDUDE_ISP_FUSES_PRE += -U hfuse:w:$(ISP_HIGH_FUSE):m + endif + + ifneq ($(strip $(ISP_LOW_FUSE)),) + AVRDUDE_ISP_FUSES_PRE += -U lfuse:w:$(ISP_LOW_FUSE):m + endif + + ifneq ($(strip $(ISP_EXT_FUSE)),) + AVRDUDE_ISP_FUSES_PRE += -U efuse:w:$(ISP_EXT_FUSE):m + endif + +endif + +# Post fuse settings +ifndef AVRDUDE_ISP_FUSES_POST + ifneq ($(strip $(ISP_LOCK_FUSE_POST)),) + AVRDUDE_ISP_FUSES_POST += -U lock:w:$(ISP_LOCK_FUSE_POST):m + endif +endif + AVRDUDE_ISP_OPTS = -c $(ISP_PROG) -b $(AVRDUDE_ISP_BAUDRATE) -P $(call get_isp_port) ifndef ISP_EEPROM @@ -902,15 +930,14 @@ reset_stty: $$STTYF $(call get_arduino_port) -hupcl ispload: $(TARGET_EEP) $(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 \ - -U lfuse:w:$(ISP_LOW_FUSE):m \ - -U efuse:w:$(ISP_EXT_FUSE):m - $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -D \ - $(AVRDUDE_ISPLOAD_OPTS) +ifdef AVRDUDE_ISP_FUSES_PRE + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE) +endif $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \ - -U lock:w:$(ISP_LOCK_FUSE_POST):m + $(AVRDUDE_ISPLOAD_OPTS) +ifdef AVRDUDE_ISP_FUSES_POST + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST) +endif clean: $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR}