Mercurial > pihelp
annotate Makefile @ 49:12236bceb6b0 default tip
snapshot export of the schematic
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 25 Jun 2014 21:29:52 +0800 |
parents | a0f2fcc6d9dd |
children |
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 | |
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 |
30 | 22 CLOCK = 11059200L |
0 | 23 PROGRAMMER = #-c stk500v2 -P avrdoper |
35 | 24 PROGRAMMER = -c arduino -b 115200 -P /dev/ttyAMA0 -p $(PROGDEVICE) -B 2 |
0 | 25 SOURCE_1WIRE = onewire.c simple_ds18b20.c crc8.c |
5 | 26 SOURCE_CRYPTO = hmac-sha1.c sha1-asm.S aes.c |
32 | 27 SOURCE_SD = byteordering.c fat.c partition.c sd_raw.c |
45 | 28 SOURCE = main.c buildid.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 = |
33 | 31 BOOTLOADER_HEX = ATmegaBOOT_168_pihelp.hex |
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
|
32 |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
33 OBJECTS := $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCE))) |
0 | 34 |
35 # default but 2mhz | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
36 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x77:m -U efuse:w:0xfd:m |
0 | 37 |
22 | 38 #LOCKBIT |
35 | 39 # prevent bootloader write protect: |
40 # -U lock:w:0x2f:m | |
41 | 41 # X unused bit7 |
42 # X unused | |
22 | 43 # 1 blb12 no writing to bootloader |
44 # 0 blb11 | |
35 | 45 # 1 blb02 bootloader can write to app |
46 # 1 blb01 | |
47 # 1 lb2 external serial prog unrestricted | |
48 # 1 lb1 bit0 | |
49 | |
50 # stop everything: | |
51 # -U lock:w:0x20:m | |
52 # 0 unused bit7 | |
53 # 0 unused | |
54 # 1 blb12 no writing to bootloader | |
55 # 0 blb11 | |
56 # 0 blb02 | |
22 | 57 # 0 blb01 |
35 | 58 # 0 lb2 |
22 | 59 # 0 lb1 bit0 |
60 | |
0 | 61 # ATMega8 fuse bits used above (fuse bits for other devices are different!): |
62 # Example for 8 MHz internal oscillator | |
63 # Fuse high byte: | |
41 | 64 # 0xdb = 1 1 0 1 1 0 1 1 <-- BOOTRST (boot reset vector at 0x0000) |
65 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 (2048 bytes bootloader) | |
0 | 66 # | | | | | +-------- BOOTSZ1 |
67 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) | |
68 # | | | +-------------- WDTON | |
69 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) | |
70 # | +------------------ DWEN | |
71 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) | |
72 # Fuse low byte: | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
73 # 0x77 0 1 1 1 0 1 1 1 (low rising, full swing, crystal) |
0 | 74 # 0x62 = 0 1 1 0 0 0 1 0 |
75 # ^ ^ \ / \--+--/ | |
76 # | | | +------- CKSEL 3..0 (8M internal RC) | |
77 # | | +--------------- SUT 1..0 (slowly rising power) | |
78 # | +------------------ CKOUT | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
79 # +-------------------- CLKDIV8 (initial) |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
80 |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
81 # Extended fuse: |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
82 # 0xfd = 2.7V BOD |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
83 # |
0 | 84 # |
85 # For computing fuse byte values for other devices and options see | |
86 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ | |
87 | |
88 | |
89 # Tune the lines below only if you know what you are doing: | |
90 | |
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
|
91 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
|
92 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
|
93 |
0 | 94 AVRDUDE = avrdude $(PROGRAMMER) |
32 | 95 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 -flto |
0 | 96 |
97 # symbolic targets: | |
98 all: main.hex | |
99 | |
45 | 100 .PHONY: buildid.c |
101 | |
102 buildid.c: | |
103 echo "#include \"buildid.h\"" > $@ | |
104 echo "uint8_t buildid[20] = { `dd if=/dev/urandom bs=20 count=1 2> /dev/null | hexdump -e '20/1 "0x%02x, "' ` };" >> $@ | |
105 | |
0 | 106 .c.o: |
107 $(COMPILE) -c $< -o $@ | |
108 | |
109 .S.o: | |
110 $(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
111 # "-x assembler-with-cpp" should not be necessary since this is the default | |
112 # file type for the .S (with capital S) extension. However, upper case | |
113 # characters are not always preserved on Windows. To ensure WinAVR | |
114 # compatibility define the file type manually. | |
115 | |
116 .c.s: | |
117 $(COMPILE) -S $< -o $@ | |
118 | |
119 flash: all | |
29 | 120 $(AVRDUDE) -U flash:w:main.hex:i |
0 | 121 |
33 | 122 combined.hex: main.hex $(BOOTLOADER_HEX) |
123 srec_cat main.hex -I $(BOOTLOADER_HEX) -I -o $@ -I | |
34 | 124 avr-objdump -h $@ |
33 | 125 |
126 combo: combined.hex | |
127 $(AVRDUDE) -U flash:w:combined.hex:i | |
128 | |
0 | 129 checkprog: |
130 $(AVRDUDE) -v | |
131 | |
132 fuse: | |
133 $(AVRDUDE) $(FUSES) | |
134 | |
135 # Xcode uses the Makefile targets "", "clean" and "install" | |
136 install: flash | |
137 | |
138 # if you use a bootloader, change the command below appropriately: | |
139 load: all | |
140 bootloadHID main.hex | |
141 | |
142 clean: | |
143 rm -f main.hex main.elf $(OBJECTS) | |
144 | |
145 # file targets: | |
146 main.elf: $(SOURCE) | |
147 $(COMPILE) -o main.elf $(SOURCE) $(LIBS) | |
148 | |
149 main.hex: main.elf | |
150 rm -f main.hex | |
151 avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
152 avr-size --format=avr --mcu=$(DEVICE) main.elf | |
153 # If you have an EEPROM section, you must also create a hex file for the | |
154 # EEPROM and add it to the "flash" target. | |
155 | |
156 # Targets for code debugging and analysis: | |
157 disasm: main.elf | |
158 avr-objdump -d main.elf | |
159 | |
160 cpp: | |
161 $(COMPILE) -E main.c |