Mercurial > pihelp
annotate Makefile @ 19:5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Use smaller build options
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 25 Jun 2013 13:55:11 +0800 |
parents | 021e6e0006f4 |
children | 292cd17de2a4 |
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 | |
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 | |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
20 DEVICE = atmega328p |
0 | 21 PROGDEVICE = atmega328p |
17 | 22 CLOCK = 4915200 |
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 |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
27 SOURCE_SD = byteordering.c fat.c partition.c sd_raw.c |
0 | 28 SOURCE = main.c |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
29 SOURCE += $(SOURCE_CRYPTO) $(SOURCE_SD) |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
30 LIBS = |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
31 |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
32 OBJECTS := $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCE))) |
0 | 33 |
34 # default but 2mhz | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
35 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x77:m -U efuse:w:0xfd:m |
0 | 36 |
37 # ATMega8 fuse bits used above (fuse bits for other devices are different!): | |
38 # Example for 8 MHz internal oscillator | |
39 # Fuse high byte: | |
40 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) | |
41 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 | |
42 # | | | | | +-------- BOOTSZ1 | |
43 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) | |
44 # | | | +-------------- WDTON | |
45 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) | |
46 # | +------------------ DWEN | |
47 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) | |
48 # Fuse low byte: | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
49 # 0x77 0 1 1 1 0 1 1 1 (low rising, full swing, crystal) |
0 | 50 # 0x62 = 0 1 1 0 0 0 1 0 |
51 # ^ ^ \ / \--+--/ | |
52 # | | | +------- CKSEL 3..0 (8M internal RC) | |
53 # | | +--------------- SUT 1..0 (slowly rising power) | |
54 # | +------------------ CKOUT | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
55 # +-------------------- CLKDIV8 (initial) |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
56 |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
57 # Extended fuse: |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
58 # 0xfd = 2.7V BOD |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
59 # |
0 | 60 # |
61 # For computing fuse byte values for other devices and options see | |
62 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ | |
63 | |
64 | |
65 # Tune the lines below only if you know what you are doing: | |
66 | |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
67 SHELL := /bin/bash |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
68 export PATH := $(PATH):/usr/local/CrossPack-AVR/bin/ |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
69 |
0 | 70 AVRDUDE = avrdude $(PROGRAMMER) |
71 #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 | |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
72 COMPILE = /usr/local/CrossPack-AVR/bin/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 -flto |
0 | 73 |
74 # symbolic targets: | |
75 all: main.hex | |
76 | |
77 .c.o: | |
78 $(COMPILE) -c $< -o $@ | |
79 | |
80 .S.o: | |
81 $(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
82 # "-x assembler-with-cpp" should not be necessary since this is the default | |
83 # file type for the .S (with capital S) extension. However, upper case | |
84 # characters are not always preserved on Windows. To ensure WinAVR | |
85 # compatibility define the file type manually. | |
86 | |
87 .c.s: | |
88 $(COMPILE) -S $< -o $@ | |
89 | |
90 flash: all | |
91 $(AVRDUDE) -U flash:w:main.hex:i | |
92 | |
93 checkprog: | |
94 $(AVRDUDE) -v | |
95 | |
96 fuse: | |
97 $(AVRDUDE) $(FUSES) | |
98 | |
99 # Xcode uses the Makefile targets "", "clean" and "install" | |
100 install: flash | |
101 | |
102 # if you use a bootloader, change the command below appropriately: | |
103 load: all | |
104 bootloadHID main.hex | |
105 | |
106 clean: | |
107 rm -f main.hex main.elf $(OBJECTS) | |
108 | |
109 # file targets: | |
110 main.elf: $(SOURCE) | |
111 $(COMPILE) -o main.elf $(SOURCE) $(LIBS) | |
112 | |
113 main.hex: main.elf | |
114 rm -f main.hex | |
115 avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
116 avr-size --format=avr --mcu=$(DEVICE) main.elf | |
117 # If you have an EEPROM section, you must also create a hex file for the | |
118 # EEPROM and add it to the "flash" target. | |
119 | |
120 # Targets for code debugging and analysis: | |
121 disasm: main.elf | |
122 avr-objdump -d main.elf | |
123 | |
124 cpp: | |
125 $(COMPILE) -E main.c |