| Line 1... |
Line 1... |
| 1 |
# |
1 |
# |
| 2 |
# Makefile for usbasp |
2 |
# Makefile for usbasp |
| 3 |
# 20061119 Thomas Fischl original |
3 |
# 20061119 Thomas Fischl original |
| 4 |
# 20061120 Hanns-Konrad Unger help: and TARGET=atmega48 added |
4 |
# 20061120 Hanns-Konrad Unger help: and TARGET=atmega48 added |
| - |
|
5 |
# 20140209 Milan Horkel added automatic built for more targets |
| - |
|
6 |
|
| - |
|
7 |
ALL_TARGETS=atmega8 atmega88 |
| 5 |
# |
8 |
|
| - |
|
9 |
# Default target |
| - |
|
10 |
# -------------- |
| - |
|
11 |
|
| - |
|
12 |
ifndef $(TARGET) |
| - |
|
13 |
TARGET=atmega88 |
| - |
|
14 |
endif |
| - |
|
15 |
|
| - |
|
16 |
|
| - |
|
17 |
# Define target dependent constants |
| - |
|
18 |
# --------------------------------- |
| - |
|
19 |
|
| - |
|
20 |
ifeq ($(TARGET), atmega88) |
| - |
|
21 |
HFUSE=0xc9 |
| - |
|
22 |
LFUSE=0xef |
| - |
|
23 |
endif |
| - |
|
24 |
|
| - |
|
25 |
ifeq ($(TARGET), atmega8) |
| - |
|
26 |
HFUSE=0xc9 |
| - |
|
27 |
LFUSE=0xef |
| - |
|
28 |
endif |
| - |
|
29 |
|
| - |
|
30 |
ifeq ($(TARGET), atmega8) |
| - |
|
31 |
HFUSE=0xdd |
| - |
|
32 |
LFUSE=0xff |
| - |
|
33 |
endif |
| 6 |
|
34 |
|
| 7 |
# TARGET=atmega8 HFUSE=0xc9 LFUSE=0xef |
- |
|
| 8 |
# TARGET=atmega48 HFUSE=0xdd LFUSE=0xff |
- |
|
| 9 |
# TARGET=at90s2313 |
- |
|
| 10 |
TARGET=atmega8 |
- |
|
| 11 |
HFUSE=0xc9 |
- |
|
| 12 |
LFUSE=0xef |
- |
|
| 13 |
|
35 |
|
| 14 |
|
36 |
|
| 15 |
# ISP=bsd PORT=/dev/parport0 |
37 |
# ISP=bsd PORT=/dev/parport0 |
| 16 |
# ISP=ponyser PORT=/dev/ttyS1 |
38 |
# ISP=ponyser PORT=/dev/ttyS1 |
| 17 |
# ISP=stk500 PORT=/dev/ttyS1 |
39 |
# ISP=stk500 PORT=/dev/ttyS1 |
| Line 21... |
Line 43... |
| 21 |
PORT=/dev/usb/ttyUSB0 |
43 |
PORT=/dev/usb/ttyUSB0 |
| 22 |
|
44 |
|
| 23 |
help: |
45 |
help: |
| 24 |
@echo "Usage: make same as make help" |
46 |
@echo "Usage: make same as make help" |
| 25 |
@echo " make help same as make" |
47 |
@echo " make help same as make" |
| - |
|
48 |
@echo " make all build HEX for all target CPUs" |
| 26 |
@echo " make main.hex create main.hex" |
49 |
@echo " make hex create HEX for default target CPU" |
| 27 |
@echo " make clean remove redundant data" |
50 |
@echo " make clean remove redundant data" |
| 28 |
@echo " make disasm disasm main" |
51 |
@echo " make disasm create listing" |
| 29 |
@echo " make flash upload main.hex into flash" |
52 |
@echo " make flash upload HEX into flash (for default target CPU)" |
| 30 |
@echo " make fuses program fuses" |
53 |
@echo " make fuses program fuses (for default target CPU)" |
| 31 |
@echo " make avrdude test avrdude" |
54 |
@echo " make avrdude test avrdude" |
| 32 |
@echo "Current values:" |
55 |
@echo "Current values:" |
| 33 |
@echo " TARGET=${TARGET}" |
56 |
@echo " TARGET=${TARGET}" |
| 34 |
@echo " LFUSE=${LFUSE}" |
57 |
@echo " LFUSE=${LFUSE}" |
| 35 |
@echo " HFUSE=${HFUSE}" |
58 |
@echo " HFUSE=${HFUSE}" |
| Line 53... |
Line 76... |
| 53 |
# compatibility define the file type manually. |
76 |
# compatibility define the file type manually. |
| 54 |
|
77 |
|
| 55 |
.c.s: |
78 |
.c.s: |
| 56 |
$(COMPILE) -S $< -o $@ |
79 |
$(COMPILE) -S $< -o $@ |
| 57 |
|
80 |
|
| 58 |
clean: |
81 |
cleantmp: |
| 59 |
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o main.s usbdrv/*.o |
82 |
rm -f usbasp.lst usbasp.obj usbasp.cof usbasp.list usbasp.map usbasp.bin *.o main.s usbdrv/*.o |
| - |
|
83 |
|
| - |
|
84 |
clean: cleantmp |
| - |
|
85 |
rm -f usbasp_$(TARGET).hex usbasp_$(TARGET).eep.hex |
| 60 |
|
86 |
|
| 61 |
# file targets: |
87 |
# file targets: |
| 62 |
main.bin: $(OBJECTS) |
88 |
usbasp.bin: $(OBJECTS) |
| 63 |
$(COMPILE) -o main.bin $(OBJECTS) -Wl,-Map,main.map |
89 |
$(COMPILE) -o usbasp.bin $(OBJECTS) -Wl,-Map,usbasp.map |
| - |
|
90 |
|
| - |
|
91 |
usbasp.hex: usbasp_$(TARGET).hex |
| 64 |
|
92 |
|
| 65 |
main.hex: main.bin |
93 |
usbasp_$(TARGET).hex: usbasp.bin |
| 66 |
rm -f main.hex main.eep.hex |
94 |
rm -f usbasp_$(TARGET).hex usbasp_$(TARGET).eep.hex |
| 67 |
avr-objcopy -j .text -j .data -O ihex main.bin main.hex |
95 |
avr-objcopy -j .text -j .data -O ihex usbasp.bin $@ |
| 68 |
# ./checksize main.bin |
96 |
# ./checksize usbasp.bin |
| 69 |
# do the checksize script as our last action to allow successful compilation |
97 |
# do the checksize script as our last action to allow successful compilation |
| 70 |
# on Windows with WinAVR where the Unix commands will fail. |
98 |
# on Windows with WinAVR where the Unix commands will fail. |
| 71 |
|
99 |
|
| 72 |
disasm: main.bin |
100 |
disasm: usbasp.bin |
| 73 |
avr-objdump -d main.bin |
101 |
avr-objdump -d usbasp.bin |
| 74 |
|
102 |
|
| 75 |
cpp: |
103 |
cpp: |
| 76 |
$(COMPILE) -E main.c |
104 |
$(COMPILE) -E main.c |
| 77 |
|
105 |
|
| 78 |
flash: |
106 |
flash: |
| 79 |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -U flash:w:main.hex |
107 |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -U flash:w:usbasp.hex |
| 80 |
|
108 |
|
| 81 |
fuses: |
109 |
fuses: |
| 82 |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -u -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m |
110 |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -u -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m |
| 83 |
|
111 |
|
| 84 |
avrdude: |
112 |
avrdude: |
| Line 129... |
Line 157... |
| 129 |
# to a Keyspan USB to serial converter to a Mac running Mac OS X. |
157 |
# to a Keyspan USB to serial converter to a Mac running Mac OS X. |
| 130 |
# Choose your favorite programmer and interface. |
158 |
# Choose your favorite programmer and interface. |
| 131 |
|
159 |
|
| 132 |
uisp: all |
160 |
uisp: all |
| 133 |
$(UISP) --erase |
161 |
$(UISP) --erase |
| 134 |
$(UISP) --upload --verify if=main.hex |
162 |
$(UISP) --upload --verify if=usbasp_$(TARGET).hex |
| 135 |
|
163 |
|
| - |
|
164 |
# Execute these steps for each target CPU |
| - |
|
165 |
# Do not remove empty line in this definition! |
| - |
|
166 |
define EXEC |
| - |
|
167 |
rm -f usbasp_$(1).hex |
| - |
|
168 |
make TARGET=$(1) cleantmp |
| - |
|
169 |
make TARGET=$(1) usbasp_$(1).hex |
| - |
|
170 |
|
| - |
|
171 |
endef |
| - |
|
172 |
|
| - |
|
173 |
ALL: |
| - |
|
174 |
@$(foreach III,$(ALL_TARGETS),$(call EXEC,$(III))) |
| - |
|
175 |
@make cleantmp |