comparison Makefile @ 0:8705acff2494

lots of stuff
author Matt Johnston <matt@ucc.asn.au>
date Sat, 01 Jun 2013 01:38:42 +0800
parents
children e23c1b6f6080
comparison
equal deleted inserted replaced
-1:000000000000 0:8705acff2494
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
9 # CLOCK ........ Target AVR clock rate in Hertz
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
22 CLOCK = 2000000
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
26 SOURCE_CRYPTO = sha1.c hmac-sha1.c sha1-asm.S
27 SOURCE = main.c
28 SOURCE += $(SOURCE_1WIRE) $(SOURCE_CRYPTO)
29 LIBS = -lm
30
31 # default but 2mhz
32 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x62:m
33
34 # ATMega8 fuse bits used above (fuse bits for other devices are different!):
35 # Example for 8 MHz internal oscillator
36 # Fuse high byte:
37 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
38 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
39 # | | | | | +-------- BOOTSZ1
40 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase)
41 # | | | +-------------- WDTON
42 # | | +---------------- SPIEN (if set to 1, serial programming is disabled)
43 # | +------------------ DWEN
44 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled)
45 # Fuse low byte:
46 # 0x62 = 0 1 1 0 0 0 1 0
47 # ^ ^ \ / \--+--/
48 # | | | +------- CKSEL 3..0 (8M internal RC)
49 # | | +--------------- SUT 1..0 (slowly rising power)
50 # | +------------------ CKOUT
51 # +-------------------- CLKDIV8
52 #
53 # For computing fuse byte values for other devices and options see
54 # the fuse bit calculator at http://www.engbedded.com/fusecalc/
55
56
57 # Tune the lines below only if you know what you are doing:
58
59 AVRDUDE = avrdude $(PROGRAMMER)
60 #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
61 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -Wl,-u,vfprintf -lprintf_flt -lm
62
63 # symbolic targets:
64 all: main.hex
65
66 .c.o:
67 $(COMPILE) -c $< -o $@
68
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 .c.s:
77 $(COMPILE) -S $< -o $@
78
79 flash: all
80 $(AVRDUDE) -U flash:w:main.hex:i
81
82 checkprog:
83 $(AVRDUDE) -v
84
85 fuse:
86 $(AVRDUDE) $(FUSES)
87
88 # Xcode uses the Makefile targets "", "clean" and "install"
89 install: flash
90
91 # if you use a bootloader, change the command below appropriately:
92 load: all
93 bootloadHID main.hex
94
95 clean:
96 rm -f main.hex main.elf $(OBJECTS)
97
98 # file targets:
99 main.elf: $(SOURCE)
100 $(COMPILE) -o main.elf $(SOURCE) $(LIBS)
101
102 main.hex: main.elf
103 rm -f main.hex
104 avr-objcopy -j .text -j .data -O ihex main.elf main.hex
105 avr-size --format=avr --mcu=$(DEVICE) main.elf
106 # If you have an EEPROM section, you must also create a hex file for the
107 # EEPROM and add it to the "flash" target.
108
109 # Targets for code debugging and analysis:
110 disasm: main.elf
111 avr-objdump -d main.elf
112
113 cpp:
114 $(COMPILE) -E main.c