Mercurial > pihelp
annotate Makefile @ 33:a3de303afabf
Add compiled bootloader
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 27 Jun 2013 11:46:44 +0800 |
parents | bd9ce7e581ec |
children | b210df11f968 |
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 |
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 |
32 | 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 = |
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 |
39 # -U lock:w:0x28:m | |
40 # 0 unused bit7 | |
41 # 0 unused | |
42 # 1 blb12 no writing to bootloader | |
43 # 0 blb11 | |
44 # 1 blb02 no writing to app | |
45 # 0 blb01 | |
46 # 0 lb2 | |
47 # 0 lb1 bit0 | |
48 | |
0 | 49 # ATMega8 fuse bits used above (fuse bits for other devices are different!): |
50 # Example for 8 MHz internal oscillator | |
51 # Fuse high byte: | |
52 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) | |
53 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 | |
54 # | | | | | +-------- BOOTSZ1 | |
55 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) | |
56 # | | | +-------------- WDTON | |
57 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) | |
58 # | +------------------ DWEN | |
59 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) | |
60 # Fuse low byte: | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
61 # 0x77 0 1 1 1 0 1 1 1 (low rising, full swing, crystal) |
0 | 62 # 0x62 = 0 1 1 0 0 0 1 0 |
63 # ^ ^ \ / \--+--/ | |
64 # | | | +------- CKSEL 3..0 (8M internal RC) | |
65 # | | +--------------- SUT 1..0 (slowly rising power) | |
66 # | +------------------ CKOUT | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
67 # +-------------------- CLKDIV8 (initial) |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
68 |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
69 # Extended fuse: |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
70 # 0xfd = 2.7V BOD |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
71 # |
0 | 72 # |
73 # For computing fuse byte values for other devices and options see | |
74 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ | |
75 | |
76 | |
77 # Tune the lines below only if you know what you are doing: | |
78 | |
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
|
79 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
|
80 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
|
81 |
0 | 82 AVRDUDE = avrdude $(PROGRAMMER) |
32 | 83 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 | 84 |
85 # symbolic targets: | |
86 all: main.hex | |
87 | |
88 .c.o: | |
89 $(COMPILE) -c $< -o $@ | |
90 | |
91 .S.o: | |
92 $(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
93 # "-x assembler-with-cpp" should not be necessary since this is the default | |
94 # file type for the .S (with capital S) extension. However, upper case | |
95 # characters are not always preserved on Windows. To ensure WinAVR | |
96 # compatibility define the file type manually. | |
97 | |
98 .c.s: | |
99 $(COMPILE) -S $< -o $@ | |
100 | |
101 flash: all | |
29 | 102 $(AVRDUDE) -U flash:w:main.hex:i |
0 | 103 |
33 | 104 combined.hex: main.hex $(BOOTLOADER_HEX) |
105 srec_cat main.hex -I $(BOOTLOADER_HEX) -I -o $@ -I | |
106 | |
107 combo: combined.hex | |
108 $(AVRDUDE) -U flash:w:combined.hex:i | |
109 | |
0 | 110 checkprog: |
111 $(AVRDUDE) -v | |
112 | |
113 fuse: | |
114 $(AVRDUDE) $(FUSES) | |
115 | |
116 # Xcode uses the Makefile targets "", "clean" and "install" | |
117 install: flash | |
118 | |
119 # if you use a bootloader, change the command below appropriately: | |
120 load: all | |
121 bootloadHID main.hex | |
122 | |
123 clean: | |
124 rm -f main.hex main.elf $(OBJECTS) | |
125 | |
126 # file targets: | |
127 main.elf: $(SOURCE) | |
128 $(COMPILE) -o main.elf $(SOURCE) $(LIBS) | |
129 | |
130 main.hex: main.elf | |
131 rm -f main.hex | |
132 avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
133 avr-size --format=avr --mcu=$(DEVICE) main.elf | |
134 # If you have an EEPROM section, you must also create a hex file for the | |
135 # EEPROM and add it to the "flash" target. | |
136 | |
137 # Targets for code debugging and analysis: | |
138 disasm: main.elf | |
139 avr-objdump -d main.elf | |
140 | |
141 cpp: | |
142 $(COMPILE) -E main.c |