3471 |
miho |
1 |
# |
|
|
2 |
# Makefile for usbasp |
|
|
3 |
# 20061119 Thomas Fischl original |
|
|
4 |
# 20061120 Hanns-Konrad Unger help: and TARGET=atmega48 added |
|
|
5 |
# |
|
|
6 |
|
|
|
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 |
|
|
|
14 |
|
|
|
15 |
# ISP=bsd PORT=/dev/parport0 |
|
|
16 |
# ISP=ponyser PORT=/dev/ttyS1 |
|
|
17 |
# ISP=stk500 PORT=/dev/ttyS1 |
|
|
18 |
# ISP=usbasp PORT=/dev/usb/ttyUSB0 |
|
|
19 |
# ISP=stk500v2 PORT=/dev/ttyUSB0 |
|
|
20 |
ISP=usbasp |
|
|
21 |
PORT=/dev/usb/ttyUSB0 |
|
|
22 |
|
|
|
23 |
help: |
|
|
24 |
@echo "Usage: make same as make help" |
|
|
25 |
@echo " make help same as make" |
|
|
26 |
@echo " make main.hex create main.hex" |
|
|
27 |
@echo " make clean remove redundant data" |
|
|
28 |
@echo " make disasm disasm main" |
|
|
29 |
@echo " make flash upload main.hex into flash" |
|
|
30 |
@echo " make fuses program fuses" |
|
|
31 |
@echo " make avrdude test avrdude" |
|
|
32 |
@echo "Current values:" |
|
|
33 |
@echo " TARGET=${TARGET}" |
|
|
34 |
@echo " LFUSE=${LFUSE}" |
|
|
35 |
@echo " HFUSE=${HFUSE}" |
|
|
36 |
@echo " CLOCK=12000000" |
|
|
37 |
@echo " ISP=${ISP}" |
|
|
38 |
@echo " PORT=${PORT}" |
|
|
39 |
|
|
|
40 |
COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=$(TARGET) # -DDEBUG_LEVEL=2 |
|
|
41 |
|
|
|
42 |
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o isp.o clock.o tpi.o main.o |
|
|
43 |
|
|
|
44 |
.c.o: |
|
|
45 |
$(COMPILE) -c $< -o $@ |
|
|
46 |
#-Wa,-ahlms=$<.lst |
|
|
47 |
|
|
|
48 |
.S.o: |
|
|
49 |
$(COMPILE) -x assembler-with-cpp -c $< -o $@ |
|
|
50 |
# "-x assembler-with-cpp" should not be necessary since this is the default |
|
|
51 |
# file type for the .S (with capital S) extension. However, upper case |
|
|
52 |
# characters are not always preserved on Windows. To ensure WinAVR |
|
|
53 |
# compatibility define the file type manually. |
|
|
54 |
|
|
|
55 |
.c.s: |
|
|
56 |
$(COMPILE) -S $< -o $@ |
|
|
57 |
|
|
|
58 |
clean: |
|
|
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 |
|
|
60 |
|
|
|
61 |
# file targets: |
|
|
62 |
main.bin: $(OBJECTS) |
|
|
63 |
$(COMPILE) -o main.bin $(OBJECTS) -Wl,-Map,main.map |
|
|
64 |
|
|
|
65 |
main.hex: main.bin |
|
|
66 |
rm -f main.hex main.eep.hex |
|
|
67 |
avr-objcopy -j .text -j .data -O ihex main.bin main.hex |
|
|
68 |
# ./checksize main.bin |
|
|
69 |
# do the checksize script as our last action to allow successful compilation |
|
|
70 |
# on Windows with WinAVR where the Unix commands will fail. |
|
|
71 |
|
|
|
72 |
disasm: main.bin |
|
|
73 |
avr-objdump -d main.bin |
|
|
74 |
|
|
|
75 |
cpp: |
|
|
76 |
$(COMPILE) -E main.c |
|
|
77 |
|
|
|
78 |
flash: |
|
|
79 |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -U flash:w:main.hex |
|
|
80 |
|
|
|
81 |
fuses: |
|
|
82 |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -u -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m |
|
|
83 |
|
|
|
84 |
avrdude: |
|
|
85 |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -v |
|
|
86 |
|
|
|
87 |
# Fuse atmega8 high byte HFUSE: |
|
|
88 |
# 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) |
|
|
89 |
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 |
|
|
90 |
# | | | | | +-------- BOOTSZ1 |
|
|
91 |
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) |
|
|
92 |
# | | | +-------------- CKOPT (full output swing) |
|
|
93 |
# | | +---------------- SPIEN (allow serial programming) |
|
|
94 |
# | +------------------ WDTON (WDT not always on) |
|
|
95 |
# +-------------------- RSTDISBL (reset pin is enabled) |
|
|
96 |
# Fuse atmega8 low byte LFUSE: |
|
|
97 |
# 0x9f = 1 0 0 1 1 1 1 1 |
|
|
98 |
# ^ ^ \ / \--+--/ |
|
|
99 |
# | | | +------- CKSEL 3..0 (external >8M crystal) |
|
|
100 |
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) |
|
|
101 |
# | +------------------ BODEN (BrownOut Detector enabled) |
|
|
102 |
# +-------------------- BODLEVEL (2.7V) |
|
|
103 |
# |
|
|
104 |
# Fuse atmega48 high byte hfuse: |
|
|
105 |
# 0xdf = 1 1 0 1 1 1 1 1 factory setting |
|
|
106 |
# ^ ^ ^ ^ ^ \-+-/ |
|
|
107 |
# | | | | | +------ BODLEVEL (Brown out disabled) |
|
|
108 |
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) |
|
|
109 |
# | | | +-------------- WDTON (WDT not always on) |
|
|
110 |
# | | +---------------- SPIEN (allow serial programming) |
|
|
111 |
# | +------------------ DWEN (debug wire is disabled) |
|
|
112 |
# +-------------------- RSTDISBL (reset pin is enabled) |
|
|
113 |
# 0xdd = ext.reset, no DW, SPI, no watchdog, no save eeprom, BOD 2.7V |
|
|
114 |
# Fuse atmega48 low byte lfuse: |
|
|
115 |
# 0x62 = 0 1 1 0 0 0 1 0 factory setting |
|
|
116 |
# ^ ^ \ / \--+--/ |
|
|
117 |
# | | | +------- CKSEL 3..0 (internal 8Mhz Oszillator) |
|
|
118 |
# | | +--------------- SUT 1..0 (start-up time) |
|
|
119 |
# | +------------------ CKOUT (no clock output) |
|
|
120 |
# +-------------------- CKDIV8 (divide clock by 8) |
|
|
121 |
# 0xdc = divide/1,no clock output,fast raising power,low Pw Oszil. 3..8 Mhz |
|
|
122 |
# 0xe0 = divide/1,no clock output,fast raising power,external Oszil. |
|
|
123 |
# 0xff = divide/1,no clock output,slow raising power,low Pw Oszil 8.. Mhz |
|
|
124 |
|
|
|
125 |
|
|
|
126 |
SERIAL = `echo /dev/tty.USA19QI*` |
|
|
127 |
UISP = uisp -dprog=$S -dserial=$(SERIAL) -dpart=auto |
|
|
128 |
# The two lines above are for "uisp" and the AVR910 serial programmer connected |
|
|
129 |
# to a Keyspan USB to serial converter to a Mac running Mac OS X. |
|
|
130 |
# Choose your favorite programmer and interface. |
|
|
131 |
|
|
|
132 |
uisp: all |
|
|
133 |
$(UISP) --erase |
|
|
134 |
$(UISP) --upload --verify if=main.hex |
|
|
135 |
|