]> git.cryptolib.org Git - labortage2013badge.git/blob - firmware/Makefile
many new features, but a bit to big
[labortage2013badge.git] / firmware / Makefile
1 # Name: Makefile
2 # Project: hid-custom-rq example
3 # Author: Christian Starkjohann
4 # Creation Date: 2008-04-07
5 # Tabsize: 4
6 # Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
7 # License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
8 # This Revision: $Id: Makefile 692 2008-11-07 15:07:40Z cs $
9
10 DEVICE  = attiny85 #attiny45
11 F_CPU   = 16500000
12 FUSE_L  = 0xe1# 1110.0001
13 FUSE_H  = 0x9d# 1001.1101
14 #AVRDUDE = avrdude -c avr910 -P /dev/ttyUSB0 -p $(DEVICE) # edit this line for your programmer
15 AVRDUDE_ISP = avrdude -c jtag2isp -P usb -p $(DEVICE) # edit this line for your programmer
16 AVRDUDE_DW  = avrdude -c jtag2dw  -P usb -p $(DEVICE) # edit this line for your programmer
17
18 CFLAGS  = -Iusbdrv -I. -DDEBUG_LEVEL=0
19 OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o \
20           percnt2.o sha1-asm.o hmac-sha1.o hotp.o special_functions.o
21
22 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
23 COMPILEPP = avr-g++ -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
24
25 # symbolic targets:
26 help:
27         @echo "This Makefile has no default rule. Use one of the following:"
28         @echo "make hex ....... to build main.hex"
29         @echo "make program ... to flash fuses and firmware"
30         @echo "make fuse ...... to flash the fuses"
31         @echo "make flash ..... to flash the firmware (use this on metaboard)"
32         @echo "make clean ..... to delete objects and hex file"
33
34 hex: main.hex
35
36 program: flash
37
38 xprog_i: flash_isp fuse
39 xprog_d: fuse flash_dw
40
41 # rule for programming fuse bits:
42 fuse:
43         @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
44                 { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
45         $(AVRDUDE_ISP) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
46
47 # rule for uploading firmware:
48 flash_isp: main.hex
49         $(AVRDUDE_ISP) -U flash:w:main.hex:i
50
51 flash_dw: main.hex
52         $(AVRDUDE_DW) -U flash:w:main.hex:i
53
54
55 # rule for deleting dependent files (those which can be built by Make):
56 clean:
57         rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
58
59 .cpp.o:
60         $(COMPILEPP) -c $< -o $@
61
62
63 # Generic rule for compiling C files:
64 .c.o:
65         $(COMPILE) -c $< -o $@
66
67 # Generic rule for assembling Assembler source files:
68 .S.o:
69         $(COMPILE) -x assembler-with-cpp -c $< -o $@
70 # "-x assembler-with-cpp" should not be necessary since this is the default
71 # file type for the .S (with capital S) extension. However, upper case
72 # characters are not always preserved on Windows. To ensure WinAVR
73 # compatibility define the file type manually.
74
75 # Generic rule for compiling C to assembler, used for debugging only.
76 .c.s:
77         $(COMPILE) -S $< -o $@
78
79 # file targets:
80
81 # Since we don't want to ship the driver multipe times, we copy it into this project:
82 usbdrv:
83         cp -r ../../../usbdrv .
84
85 main.elf: usbdrv $(OBJECTS)     # usbdrv dependency only needed because we copy it
86         $(COMPILE) -o main.elf $(OBJECTS)
87
88 main.hex: main.elf
89         rm -f main.hex main.eep.hex
90         avr-objcopy -j .text -j .data -O ihex main.elf main.hex
91         avr-size main.hex
92
93 # debugging targets:
94
95 disasm: main.elf
96         avr-objdump -d main.elf
97
98 cpp:
99         $(COMPILE) -E main.cpp