]> git.cryptolib.org Git - labortage2013badge.git/blob - firmware/Makefile
removing memory r/w/x features
[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 FUSE_E  = 0xfe# 1111.1110
15 #AVRDUDE = avrdude -c avr910 -P /dev/ttyUSB0 -p $(DEVICE) # edit this line for your programmer
16 AVRDUDE_ISP = avrdude -c jtag2isp -P usb -p $(DEVICE) # edit this line for your programmer
17 AVRDUDE_DW  = avrdude -c jtag2dw  -P usb -p $(DEVICE) # edit this line for your programmer
18
19 CFLAGS  = -Iusbdrv -I. -DDEBUG_LEVEL=0
20 OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o \
21           sha1-asm.o hmac-sha1.o hotp.o special_functions.o
22
23 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
24 COMPILEPP = avr-g++ -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
25
26 # symbolic targets:
27 help:
28         @echo "This Makefile has no default rule. Use one of the following:"
29         @echo "make hex ....... to build main.hex"
30         @echo "make program ... to flash fuses and firmware"
31         @echo "make fuse ...... to flash the fuses"
32         @echo "make flash ..... to flash the firmware (use this on metaboard)"
33         @echo "make clean ..... to delete objects and hex file"
34
35 hex: main.hex
36
37 program: flash
38
39 xprog_i: flash_isp fuse
40 xprog_d: fuse flash_dw
41
42 # rule for programming fuse bits:
43 fuse:
44         @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" -a "$(FUSE_E)" != "" ] || \
45                 { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
46         $(AVRDUDE_ISP) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m -U efuse:w:$(FUSE_E):m
47
48 # rule for uploading firmware:
49 flash_isp: main.hex
50         $(AVRDUDE_ISP) -U flash:w:main.hex:i
51
52 flash_dw: main.hex
53         $(AVRDUDE_DW) -U flash:w:main.hex:i
54
55
56 # rule for deleting dependent files (those which can be built by Make):
57 clean:
58         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
59
60 .cpp.o:
61         $(COMPILEPP) -c $< -o $@
62
63
64 # Generic rule for compiling C files:
65 .c.o:
66         $(COMPILE) -c $< -o $@
67
68 # Generic rule for assembling Assembler source files:
69 .S.o:
70         $(COMPILE) -x assembler-with-cpp -c $< -o $@
71 # "-x assembler-with-cpp" should not be necessary since this is the default
72 # file type for the .S (with capital S) extension. However, upper case
73 # characters are not always preserved on Windows. To ensure WinAVR
74 # compatibility define the file type manually.
75
76 # Generic rule for compiling C to assembler, used for debugging only.
77 .c.s:
78         $(COMPILE) -S $< -o $@
79
80 # file targets:
81
82 # Since we don't want to ship the driver multipe times, we copy it into this project:
83 usbdrv:
84         cp -r ../../../usbdrv .
85
86 main.elf: usbdrv $(OBJECTS)     # usbdrv dependency only needed because we copy it
87         $(COMPILE) -o main.elf $(OBJECTS)
88
89 main.hex: main.elf
90         rm -f main.hex main.eep.hex
91         avr-objcopy -j .text -j .data -O ihex main.elf main.hex
92         avr-size main.hex
93
94 # debugging targets:
95
96 disasm: main.elf
97         avr-objdump -d main.elf
98
99 cpp:
100         $(COMPILE) -E main.cpp