Merge pull request #10 from gaftech/master

EEPROM upload support
This commit is contained in:
Sudar 2012-12-17 04:45:56 -08:00
commit 5045345467

View file

@ -148,6 +148,12 @@
# - Changed shebang to use /usr/bin/env (https://github.com/anm)
# - set USB_VID and USB_PID only for leonardo boards(https://github.com/alohr)
#
# 0.10.3 16.xii 2012 gaftech
# - Enabling creation of EEPROM file (.eep)
# - EEPROM upload: eeprom and raw_eeprom targets
# - Auto EEPROM upload with isp mode: ISP_EEPROM option.
# - Allow custom OBJDIR
#
########################################################################
#
# PATHS YOU NEED TO SET UP
@ -270,6 +276,8 @@
# with your original source code.
# make verify_size - Verify that the size of the final file is less than
# the capacity of the micro controller.
# make eeprom - upload the eep file
# make raw_eeprom - upload the eep file without first resetting
#
########################################################################
#
@ -309,6 +317,9 @@
# ISP_LOW_FUSE = 0xff
# ISP_EXT_FUSE = 0x01
#
# You can specify to also upload the EEPROM file:
# ISP_EEPROM = 1
#
# I think the fuses here are fine for uploading to the ATmega168
# without bootloader.
#
@ -663,6 +674,7 @@ endif
# The name of the main targets
TARGET_HEX = $(OBJDIR)/$(TARGET).hex
TARGET_ELF = $(OBJDIR)/$(TARGET).elf
TARGET_EEP = $(OBJDIR)/$(TARGET).eep
TARGETS = $(OBJDIR)/$(TARGET).*
CORE_LIB = $(OBJDIR)/libcore.a
@ -890,15 +902,30 @@ ifndef ISP_PROG
ISP_PROG = -c stk500v2
endif
# usb seems to be a reasonable default, at least on linux
ifndef ISP_PORT
ISP_PORT = usb
endif
AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG)
ifndef ISP_EEPROM
ISP_EEPROM = 0
endif
AVRDUDE_UPLOAD_HEX = -U flash:w:$(TARGET_HEX):i
AVRDUDE_UPLOAD_EEP = -U eeprom:w:$(TARGET_EEP):i
AVRDUDE_ISPLOAD_OPTS = $(AVRDUDE_UPLOAD_HEX)
ifneq ($(ISP_EEPROM), 0)
AVRDUDE_ISPLOAD_OPTS += $(AVRDUDE_UPLOAD_EEP)
endif
########################################################################
#
# Explicit targets start here
#
all: $(OBJDIR) $(TARGET_HEX) verify_size
all: $(OBJDIR) $(TARGET_EEP) $(TARGET_HEX) verify_size
$(OBJDIR):
mkdir $(OBJDIR)
@ -916,7 +943,13 @@ upload: raw_upload
raw_upload: reset $(TARGET_HEX) verify_size
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
-U flash:w:$(TARGET_HEX):i
$(AVRDUDE_UPLOAD_HEX)
eeprom: reset raw_eeprom
raw_eeprom: $(TARGET_EEP) $(TARGET_HEX)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
$(AVRDUDE_UPLOAD_EEP)
reset:
$(RESET_CMD) $(call get_arduino_port)
@ -932,14 +965,14 @@ reset_stty:
(sleep 0.1 || sleep 1) ;\
$$STTYF $(call get_arduino_port) -hupcl
ispload: $(TARGET_HEX) verify_size
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 \
-U flash:w:$(TARGET_HEX):i
$(AVRDUDE_ISPLOAD_OPTS)
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \
-U lock:w:$(ISP_LOCK_FUSE_POST):m