1 |
# Name: Makefile |
1 |
# Name: Makefile |
2 |
# Project: USB I2C |
2 |
# Project: USB I2C |
3 |
# Author: Christian Starkjohann, modified for I2C USB by Till Harbaum |
3 |
# Author: Christian Starkjohann, modified for I2C USB by Till Harbaum |
4 |
# Creation Date: 2005-03-20 |
4 |
# Creation Date: 2005-03-20 |
5 |
# Tabsize: 4 |
5 |
# Tabsize: 4 |
6 |
# Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH |
6 |
# Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH |
7 |
# License: Proprietary, free under certain conditions. See Documentation. |
7 |
# License: Proprietary, free under certain conditions. See Documentation. |
8 |
# This Revision: $Id: Makefile-avrusb.mega8,v 1.1 2006/12/03 21:28:59 harbaum Exp $ |
8 |
# This Revision: $Id: Makefile-avrusb.mega8,v 1.1 2006/12/03 21:28:59 harbaum Exp $ |
9 |
|
9 |
|
10 |
SERIAL = `echo /dev/tty.[Uu][Ss]*` |
10 |
SERIAL = `echo /dev/tty.[Uu][Ss]*` |
11 |
UISP = uisp -dprog=stk200 |
11 |
UISP = uisp -dprog=stk200 |
12 |
# UISP = uisp -dprog=avr910 -dserial=$(SERIAL) -dpart=auto |
12 |
# UISP = uisp -dprog=avr910 -dserial=$(SERIAL) -dpart=auto |
13 |
# The two lines above are for "uisp" and the AVR910 serial programmer connected |
13 |
# The two lines above are for "uisp" and the AVR910 serial programmer connected |
14 |
# to a Keyspan USB to serial converter to a Mac running Mac OS X. |
14 |
# to a Keyspan USB to serial converter to a Mac running Mac OS X. |
15 |
# Choose your favorite programmer and interface. |
15 |
# Choose your favorite programmer and interface. |
16 |
|
16 |
|
17 |
DEFINES += -DDEBUG |
17 |
DEFINES += -DDEBUG |
18 |
DEFINES += -DDEBUG_LEVEL=1 |
18 |
DEFINES += -DDEBUG_LEVEL=1 |
19 |
COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=atmega8 $(DEFINES) |
19 |
COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=atmega8 $(DEFINES) |
20 |
|
20 |
|
21 |
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o |
21 |
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o |
22 |
|
22 |
|
23 |
|
23 |
|
24 |
# symbolic targets: |
24 |
# symbolic targets: |
25 |
all: firmware.hex |
25 |
all: firmware.hex |
26 |
|
26 |
|
27 |
.c.o: |
27 |
.c.o: |
28 |
$(COMPILE) -c $< -o $@ |
28 |
$(COMPILE) -c $< -o $@ |
29 |
|
29 |
|
30 |
.S.o: |
30 |
.S.o: |
31 |
$(COMPILE) -x assembler-with-cpp -c $< -o $@ |
31 |
$(COMPILE) -x assembler-with-cpp -c $< -o $@ |
32 |
# "-x assembler-with-cpp" should not be necessary since this is the default |
32 |
# "-x assembler-with-cpp" should not be necessary since this is the default |
33 |
# file type for the .S (with capital S) extension. However, upper case |
33 |
# file type for the .S (with capital S) extension. However, upper case |
34 |
# characters are not always preserved on Windows. To ensure WinAVR |
34 |
# characters are not always preserved on Windows. To ensure WinAVR |
35 |
# compatibility define the file type manually. |
35 |
# compatibility define the file type manually. |
36 |
|
36 |
|
37 |
.c.s: |
37 |
.c.s: |
38 |
$(COMPILE) -S $< -o $@ |
38 |
$(COMPILE) -S $< -o $@ |
39 |
|
39 |
|
40 |
# Fuse high byte: |
40 |
# Fuse high byte: |
- |
|
41 |
# 0xD9 = 1 1 0 1 1 0 0 1 = Factory Default Value |
41 |
# 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) |
42 |
# 0xC9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) |
42 |
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 |
43 |
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 |
43 |
# | | | | | +-------- BOOTSZ1 |
44 |
# | | | | | +-------- BOOTSZ1 |
44 |
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) |
45 |
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) |
45 |
# | | | +-------------- CKOPT (full output swing) |
46 |
# | | | +-------------- CKOPT (full output swing) |
46 |
# | | +---------------- SPIEN (allow serial programming) |
47 |
# | | +---------------- SPIEN (allow serial programming) |
47 |
# | +------------------ WDTON (WDT not always on) |
48 |
# | +------------------ WDTON (WDT not always on) |
48 |
# +-------------------- RSTDISBL (reset pin is enabled) |
49 |
# +-------------------- RSTDISBL (reset pin is enabled) |
49 |
# Fuse low byte: |
50 |
# Fuse low byte: |
- |
|
51 |
# 0xE1 = 1 1 1 0 0 0 0 1 = Factory Default Value |
50 |
# 0x9f = 1 0 0 1 1 1 1 1 |
52 |
# 0x9F = 1 0 0 1 1 1 1 1 |
51 |
# ^ ^ \ / \--+--/ |
53 |
# ^ ^ \ / \--+--/ |
52 |
# | | | +------- CKSEL 3..0 (external >8M crystal) |
54 |
# | | | +------- CKSEL 3..0 (external >8M crystal) |
53 |
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) |
55 |
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) |
54 |
# | +------------------ BODEN (BrownOut Detector enabled) |
56 |
# | +------------------ BODEN (BrownOut Detector enabled) |
55 |
# +-------------------- BODLEVEL (2.7V) |
57 |
# +-------------------- BODLEVEL (2.7V) |
56 |
fuse: |
58 |
fuse: |
57 |
$(UISP) --wr_fuse_h=0xc9 --wr_fuse_l=0x9f |
59 |
$(UISP) --wr_fuse_h=0xc9 --wr_fuse_l=0x9f |
58 |
|
60 |
|
59 |
|
61 |
|
60 |
clean: |
62 |
clean: |
61 |
rm -f firmware.hex firmware.lst firmware.obj firmware.cof firmware.list firmware.map firmware.eep.hex firmware.bin *.o usbdrv/*.o firmware.s usbdrv/oddebug.s usbdrv/usbdrv.s |
63 |
rm -f firmware.hex firmware.lst firmware.obj firmware.cof firmware.list firmware.map firmware.eep.hex firmware.bin *.o usbdrv/*.o firmware.s usbdrv/oddebug.s usbdrv/usbdrv.s |
62 |
|
64 |
|
63 |
# file targets: |
65 |
# file targets: |
64 |
firmware.bin: $(OBJECTS) |
66 |
firmware.bin: $(OBJECTS) |
65 |
$(COMPILE) -o firmware.bin $(OBJECTS) |
67 |
$(COMPILE) -o firmware.bin $(OBJECTS) |
66 |
|
68 |
|
67 |
firmware.hex: firmware.bin |
69 |
firmware.hex: firmware.bin |
68 |
rm -f firmware.hex firmware.eep.hex |
70 |
rm -f firmware.hex firmware.eep.hex |
69 |
avr-objcopy -j .text -j .data -O ihex firmware.bin firmware.hex |
71 |
avr-objcopy -j .text -j .data -O ihex firmware.bin firmware.hex |
70 |
./checksize firmware.bin 8192 960 |
72 |
./checksize firmware.bin 8192 960 |
71 |
# do the checksize script as our last action to allow successful compilation |
73 |
# do the checksize script as our last action to allow successful compilation |
72 |
# on Windows with WinAVR where the Unix commands will fail. |
74 |
# on Windows with WinAVR where the Unix commands will fail. |
73 |
|
75 |
|
74 |
program: firmware.hex |
76 |
program: firmware.hex |
75 |
avrdude -c usbasp -p atmega8 -U lfuse:w:0x9f:m -U hfuse:w:0xc9:m -U flash:w:firmware.hex |
77 |
avrdude -c usbasp -p atmega8 -U lfuse:w:0x9f:m -U hfuse:w:0xc9:m -U flash:w:firmware.hex |
76 |
|
78 |
|
77 |
program-nodep: |
79 |
program-nodep: |
78 |
avrdude -c usbasp -p atmega8 -U lfuse:w:0x9f:m -U hfuse:w:0xc9:m -U flash:w:firmware.hex |
80 |
avrdude -c usbasp -p atmega8 -U lfuse:w:0x9f:m -U hfuse:w:0xc9:m -U flash:w:firmware.hex |
79 |
|
81 |
|
80 |
disasm: firmware.bin |
82 |
disasm: firmware.bin |
81 |
avr-objdump -d firmware.bin |
83 |
avr-objdump -d firmware.bin |
82 |
|
84 |
|
83 |
cpp: |
85 |
cpp: |
84 |
$(COMPILE) -E main.c |
86 |
$(COMPILE) -E main.c |