annotate old/Makefile @ 619:aecd0a15133c rust

update
author Matt Johnston <matt@ucc.asn.au>
date Tue, 21 Mar 2017 22:41:29 +0800
parents 11a1b59b0624
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 # Name: Makefile
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 # Author: <insert your name here>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 # Copyright: <insert your copyright message here>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 # License: <insert your license reference here>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 # This is a prototype Makefile. Modify it according to your needs.
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 # You should at least check the settings for
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 # DEVICE ....... The AVR device you compile for
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 # CLOCK ........ Target AVR clock rate in Hertz
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 # OBJECTS ...... The object files created from your source files. This list is
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 # usually the same as the list of source files with suffix ".o".
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 # PROGRAMMER ... Options to avrdude which define the hardware you use for
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 # uploading to the AVR and the interface where this hardware
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 # is connected. We recommend that you leave it undefined and
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 # add settings like this to your ~/.avrduderc file:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 # default_programmer = "stk500v2"
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 # default_serial = "avrdoper"
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 # FUSES ........ Parameters for avrdude to flash the fuses appropriately.
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19
7
52cb08a01171 serial prints something
Matt Johnston <matt@ucc.asn.au>
parents: 6
diff changeset
20 DEVICE = atmega328
52cb08a01171 serial prints something
Matt Johnston <matt@ucc.asn.au>
parents: 6
diff changeset
21 PROGDEVICE = atmega328p
9
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
22 CLOCK = 2000000
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 PROGRAMMER = #-c stk500v2 -P avrdoper
10
1bfe28c348dd reading DS18B20 works
Matt Johnston <matt@ucc.asn.au>
parents: 9
diff changeset
24 PROGRAMMER = -c stk500 -P ~/dev/stk500 -p $(PROGDEVICE) -B 2
12
3c27bfbd7f3a Add simple_ds18b20.c etc
Matt Johnston <matt@ucc.asn.au>
parents: 11
diff changeset
25 SOURCE_1WIRE = onewire.c simple_ds18b20.c crc8.c
11
06bedbe8540d all these optimisations make it 30% smaller
Matt Johnston <matt@ucc.asn.au>
parents: 10
diff changeset
26 SOURCE = main.c
06bedbe8540d all these optimisations make it 30% smaller
Matt Johnston <matt@ucc.asn.au>
parents: 10
diff changeset
27 SOURCE += $(SOURCE_1WIRE)
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
28 LIBS = -lm
9
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
29
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
30 # default but 2mhz
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
31 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x62:m
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 # ATMega8 fuse bits used above (fuse bits for other devices are different!):
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 # Example for 8 MHz internal oscillator
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 # Fuse high byte:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 # | | | | | +-------- BOOTSZ1
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase)
9
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
40 # | | | +-------------- WDTON
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 # | | +---------------- SPIEN (if set to 1, serial programming is disabled)
9
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
42 # | +------------------ DWEN
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 # Fuse low byte:
9
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
45 # 0x62 = 0 1 1 0 0 0 1 0
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 # ^ ^ \ / \--+--/
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 # | | | +------- CKSEL 3..0 (8M internal RC)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 # | | +--------------- SUT 1..0 (slowly rising power)
9
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
49 # | +------------------ CKOUT
7da9a3f23592 Import ds18x20 code
Matt Johnston <matt@ucc.asn.au>
parents: 7
diff changeset
50 # +-------------------- CLKDIV8
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 #
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 # For computing fuse byte values for other devices and options see
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 # the fuse bit calculator at http://www.engbedded.com/fusecalc/
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 # Tune the lines below only if you know what you are doing:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57
7
52cb08a01171 serial prints something
Matt Johnston <matt@ucc.asn.au>
parents: 6
diff changeset
58 AVRDUDE = avrdude $(PROGRAMMER)
118
bb0c946460f3 a bit more logging. make printf floats work
Matt Johnston <matt@ucc.asn.au>
parents: 105
diff changeset
59 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--relax --combine -fwhole-program -Wl,-u,vfprintf -lprintf_flt -lm
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 # symbolic targets:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 all: main.hex
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 .c.o:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
65 $(COMPILE) -c $< -o $@
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67 .S.o:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68 $(COMPILE) -x assembler-with-cpp -c $< -o $@
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69 # "-x assembler-with-cpp" should not be necessary since this is the default
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
70 # file type for the .S (with capital S) extension. However, upper case
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 # characters are not always preserved on Windows. To ensure WinAVR
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72 # compatibility define the file type manually.
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 .c.s:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 $(COMPILE) -S $< -o $@
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
76
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
77 flash: all
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
78 $(AVRDUDE) -U flash:w:main.hex:i
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79
13
4838bfcb3504 Add eeprom stuff
Matt Johnston <matt@ucc.asn.au>
parents: 12
diff changeset
80 checkprog:
4838bfcb3504 Add eeprom stuff
Matt Johnston <matt@ucc.asn.au>
parents: 12
diff changeset
81 $(AVRDUDE) -v
4838bfcb3504 Add eeprom stuff
Matt Johnston <matt@ucc.asn.au>
parents: 12
diff changeset
82
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
83 fuse:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
84 $(AVRDUDE) $(FUSES)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
85
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
86 # Xcode uses the Makefile targets "", "clean" and "install"
12
3c27bfbd7f3a Add simple_ds18b20.c etc
Matt Johnston <matt@ucc.asn.au>
parents: 11
diff changeset
87 install: flash
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
88
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
89 # if you use a bootloader, change the command below appropriately:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
90 load: all
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
91 bootloadHID main.hex
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93 clean:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
94 rm -f main.hex main.elf $(OBJECTS)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96 # file targets:
11
06bedbe8540d all these optimisations make it 30% smaller
Matt Johnston <matt@ucc.asn.au>
parents: 10
diff changeset
97 main.elf: $(SOURCE)
06bedbe8540d all these optimisations make it 30% smaller
Matt Johnston <matt@ucc.asn.au>
parents: 10
diff changeset
98 $(COMPILE) -o main.elf $(SOURCE) $(LIBS)
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
100 main.hex: main.elf
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101 rm -f main.hex
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102 avr-objcopy -j .text -j .data -O ihex main.elf main.hex
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103 avr-size --format=avr --mcu=$(DEVICE) main.elf
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
104 # If you have an EEPROM section, you must also create a hex file for the
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105 # EEPROM and add it to the "flash" target.
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107 # Targets for code debugging and analysis:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 disasm: main.elf
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 avr-objdump -d main.elf
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
111 cpp:
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
112 $(COMPILE) -E main.c