-
Notifications
You must be signed in to change notification settings - Fork 71
/
Makefile.isp
79 lines (66 loc) · 2.53 KB
/
Makefile.isp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Makefile.isp for Optiboot
# Bill Westfield (WestfW@yahoo.com) March, 2013
# $Id$
#
# Instructions:
#
# This is a "daughter" Makefile that burns the bootloader using a ISP
# device programmer. It is designed to inherit assorted variables from
# the parent optiboot "Makefile"... Using a daughter makefile makes
# certain variable manipulations more obvious.
#
# To burn bootloader .hex file, invoke the main Makefile using:
# make diecimila_isp
# make lilypad_isp
# make ng_isp
# etc...
#
# Note: inherit paths/etc from parent Makefile.
#
#---------------------------------------------------------------------------
# enter the parameters for the avrdude isp tool -b19200
#
# Inherit avrdude paths from top-level makefile
AVRDUDE_ROOT ?= $(GCCROOT)
AVRDUDE_CONF ?= -C$(TOOLROOT)/avr/etc/avrdude.conf
# These are the parameters for a usb-based STK500v2 programmer.
# Exact type unknown. (historical Makefile values.)
#ISPTOOL = stk500v2
#ISPPORT = usb
#ISPSPEED = -b 115200
#
#
# These are parameters for using an Arduino with the ArduinoISP sketch
# as the programmer. On a mac, for a particular Uno as programmer.
ISPTOOL ?= jtag2isp
ISPPORT ?= usb
ISPSPEED ?= -b19200
# Not all chips have EFUSE.
ifdef EFUSE
EFUSE_CMD= -U efuse:w:0x$(EFUSE):m
endif
# There are certain complicated caused by the fact that the default state
# of a fuse is a "1" rather than a "0", especially with respect to fuse bits
# that have not been implemented. Those would normally not be included, but
# unimplemented fuses still default to being "1"
#
# the efuse should really be 0xf8; since, however, only the lower
# three bits of that byte are used on the atmega168, avrdude gets
# confused if you specify 1's for the higher bits, see:
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
#
# similarly, the lock bits should be 0xff instead of 0x3f (to
# unlock the bootloader section) and 0xcf instead of 0x2f (to
# lock it), but since the high two bits of the lock byte are
# unused, avrdude would get confused.
# Set fuses and unlock memory
ISPFUSES = $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
-p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-e -u -U lock:w:0x3f:m $(EFUSE_CMD) \
-U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
# program flash and lock memory.
ISPFLASH = $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
-p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
-U flash:w:$(PROGRAM)_$(TARGET).hex
isp: $(PROGRAM)_$(TARGET).hex
$(ISPFLASH)