Mercurial > pihelp
annotate Makefile @ 28:735c406b4c57
add more tests
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 17 Jun 2013 00:09:52 +0800 |
parents | a55d7c2440fd |
children | 292cd17de2a4 22badb6239e0 |
rev | line source |
---|---|
0 | 1 # Name: Makefile |
2 # Author: <insert your name here> | |
3 # Copyright: <insert your copyright message here> | |
4 # License: <insert your license reference here> | |
5 | |
6 # This is a prototype Makefile. Modify it according to your needs. | |
7 # You should at least check the settings for | |
8 # DEVICE ....... The AVR device you compile for | |
20 | 9 # CLOCK ........ Target AVR CLOCK rate in Hertz |
0 | 10 # OBJECTS ...... The object files created from your source files. This list is |
11 # usually the same as the list of source files with suffix ".o". | |
12 # PROGRAMMER ... Options to avrdude which define the hardware you use for | |
13 # uploading to the AVR and the interface where this hardware | |
14 # is connected. We recommend that you leave it undefined and | |
15 # add settings like this to your ~/.avrduderc file: | |
16 # default_programmer = "stk500v2" | |
17 # default_serial = "avrdoper" | |
18 # FUSES ........ Parameters for avrdude to flash the fuses appropriately. | |
19 | |
20 DEVICE = atmega328 | |
21 PROGDEVICE = atmega328p | |
20 | 22 CLOCK = 4915200L |
0 | 23 PROGRAMMER = #-c stk500v2 -P avrdoper |
24 PROGRAMMER = -c stk500 -P ~/dev/stk500 -p $(PROGDEVICE) -B 2 | |
25 SOURCE_1WIRE = onewire.c simple_ds18b20.c crc8.c | |
5 | 26 SOURCE_CRYPTO = hmac-sha1.c sha1-asm.S aes.c |
0 | 27 SOURCE = main.c |
2 | 28 SOURCE += $(SOURCE_CRYPTO) |
0 | 29 LIBS = -lm |
30 | |
31 # default but 2mhz | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
32 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x77:m -U efuse:w:0xfd:m |
0 | 33 |
22 | 34 #LOCKBIT |
35 # -U lock:w:0x28:m | |
36 # 0 unused bit7 | |
37 # 0 unused | |
38 # 1 blb12 no writing to bootloader | |
39 # 0 blb11 | |
40 # 1 blb02 no writing to app | |
41 # 0 blb01 | |
42 # 0 lb2 | |
43 # 0 lb1 bit0 | |
44 | |
0 | 45 # ATMega8 fuse bits used above (fuse bits for other devices are different!): |
46 # Example for 8 MHz internal oscillator | |
47 # Fuse high byte: | |
48 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) | |
49 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 | |
50 # | | | | | +-------- BOOTSZ1 | |
51 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) | |
52 # | | | +-------------- WDTON | |
53 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) | |
54 # | +------------------ DWEN | |
55 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) | |
56 # Fuse low byte: | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
57 # 0x77 0 1 1 1 0 1 1 1 (low rising, full swing, crystal) |
0 | 58 # 0x62 = 0 1 1 0 0 0 1 0 |
59 # ^ ^ \ / \--+--/ | |
60 # | | | +------- CKSEL 3..0 (8M internal RC) | |
61 # | | +--------------- SUT 1..0 (slowly rising power) | |
62 # | +------------------ CKOUT | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
63 # +-------------------- CLKDIV8 (initial) |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
64 |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
65 # Extended fuse: |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
66 # 0xfd = 2.7V BOD |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
67 # |
0 | 68 # |
69 # For computing fuse byte values for other devices and options see | |
70 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ | |
71 | |
72 | |
73 # Tune the lines below only if you know what you are doing: | |
74 | |
75 AVRDUDE = avrdude $(PROGRAMMER) | |
76 #COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--relax -fwhole-program -Wl,-u,vfprintf -lprintf_flt -lm | |
2 | 77 COMPILE = /usr/local/CrossPack-AVR/bin/avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -Wl,-u,vfprintf -lprintf_flt -lm |
0 | 78 |
79 # symbolic targets: | |
80 all: main.hex | |
81 | |
82 .c.o: | |
83 $(COMPILE) -c $< -o $@ | |
84 | |
85 .S.o: | |
86 $(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
87 # "-x assembler-with-cpp" should not be necessary since this is the default | |
88 # file type for the .S (with capital S) extension. However, upper case | |
89 # characters are not always preserved on Windows. To ensure WinAVR | |
90 # compatibility define the file type manually. | |
91 | |
92 .c.s: | |
93 $(COMPILE) -S $< -o $@ | |
94 | |
95 flash: all | |
20 | 96 $(AVRDUDE) -D -U flash:w:main.hex:i |
0 | 97 |
98 checkprog: | |
99 $(AVRDUDE) -v | |
100 | |
101 fuse: | |
102 $(AVRDUDE) $(FUSES) | |
103 | |
104 # Xcode uses the Makefile targets "", "clean" and "install" | |
105 install: flash | |
106 | |
107 # if you use a bootloader, change the command below appropriately: | |
108 load: all | |
109 bootloadHID main.hex | |
110 | |
111 clean: | |
112 rm -f main.hex main.elf $(OBJECTS) | |
113 | |
114 # file targets: | |
115 main.elf: $(SOURCE) | |
116 $(COMPILE) -o main.elf $(SOURCE) $(LIBS) | |
117 | |
118 main.hex: main.elf | |
119 rm -f main.hex | |
120 avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
121 avr-size --format=avr --mcu=$(DEVICE) main.elf | |
122 # If you have an EEPROM section, you must also create a hex file for the | |
123 # EEPROM and add it to the "flash" target. | |
124 | |
125 # Targets for code debugging and analysis: | |
126 disasm: main.elf | |
127 avr-objdump -d main.elf | |
128 | |
129 cpp: | |
130 $(COMPILE) -E main.c |