Mercurial > ~darius > hgwebdir.cgi > avr-lib
comparison Makefile.avr @ 12:4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
they are specified.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Thu, 06 Jan 2011 23:37:15 +1030 |
parents | 5f21a1c8ca06 |
children | bbe75f183cf9 |
comparison
equal
deleted
inserted
replaced
11:b46f0c742316 | 12:4e10d1eef9a5 |
---|---|
1 # | 1 # |
2 # Helper makefile to build AVR sources | 2 # Helper makefile to build AVR sources |
3 # | 3 # |
4 | 4 |
5 .SUFFIXES: .hex .out .c .o .elf .dmp .s | 5 .SUFFIXES: .hex .out .c .o .elf .dmp .s .fuse |
6 | 6 |
7 # Otherwise we get -march=foo | 7 # Otherwise we get -march=foo |
8 NO_CPU_CFLAGS= | 8 NO_CPU_CFLAGS= |
9 _CPUCFLAGS= | 9 _CPUCFLAGS= |
10 | 10 |
11 # Programs | 11 # Programs |
12 AS=avr-as | 12 AS=avr-as |
13 CC=avr-gcc | 13 CC=avr-gcc |
14 OBJCOPY=avr-objcopy | 14 OBJCOPY=avr-objcopy |
15 OBJDUMP=avr-objdump | 15 OBJDUMP=avr-objdump |
16 SED=sed | |
17 TAIL=tail | |
16 | 18 |
17 # Tell as to generate listings | 19 # Tell as to generate listings |
18 CPPFLAGS+=-Wa,-adhlmsn=${<:T:S/.c/.lst/} | 20 CPPFLAGS+=-Wa,-adhlmsn=${<:T:S/.c/.lst/} |
19 | 21 |
20 MCU?=notset | 22 MCU?=notset |
25 | 27 |
26 RM=rm -f | 28 RM=rm -f |
27 | 29 |
28 PROGRAMMER=avrdude | 30 PROGRAMMER=avrdude |
29 PROGTYPE?=alf | 31 PROGTYPE?=alf |
32 | |
30 # Need the -B 1 or it is very slow. For slow clocks (eg factory fused) -B 10 works | 33 # Need the -B 1 or it is very slow. For slow clocks (eg factory fused) -B 10 works |
31 PROGEXTRA?=-B 1 | 34 PROGOPTS+=-B 10 |
35 | |
36 .if defined(WITH_FUSES) | |
37 FUSEFILE=${PROG}.fuse | |
38 PROGOPTS+=`cat ${PROG}.fuse` | |
39 .elf.fuse: | |
40 ${OBJDUMP} -s -j .fuse ${.IMPSRC} | ${TAIL} -1 | ${SED} -nEe 's, [^ ]+ (..)(..)(..).*,-Ulfuse:w:0x\1:m -Uhfuse:w:0x\2:m -Uefuse:w:0x\3:m,p' >${.TARGET} | |
41 .else | |
42 FUSEFILE= | |
43 .endif | |
32 | 44 |
33 .if ${PROGTYPE} != "dragon_isp" && ${PROGTYPE} != "dragon_jtag" | 45 .if ${PROGTYPE} != "dragon_isp" && ${PROGTYPE} != "dragon_jtag" |
34 PROGEXITS?=vcc,noreset | 46 PROGEXITS?=vcc,noreset |
35 .endif | 47 .endif |
36 | 48 |
39 .endif | 51 .endif |
40 .if defined(PROGPORT) && ${PROGPORT} != "" | 52 .if defined(PROGPORT) && ${PROGPORT} != "" |
41 _PROGPORT=-P ${PROGPORT} | 53 _PROGPORT=-P ${PROGPORT} |
42 .endif | 54 .endif |
43 | 55 |
44 PROGOPTS?=-p ${PART} -c ${PROGTYPE} ${_PROGPORT} ${_PROGEXITS} -q ${PROGEXTRA} | 56 PROGOPTS+=-p ${PART} -c ${PROGTYPE} ${_PROGPORT} ${_PROGEXITS} -q -U flash:w:${PROG}.hex ${PROGEXTRA} |
45 | 57 |
46 .if !defined(SRCS) | 58 .if !defined(SRCS) |
47 SRCS= ${PROG}.c | 59 SRCS= ${PROG}.c |
48 .endif | 60 .endif |
49 | 61 |
62 | 74 |
63 .elf.dmp: | 75 .elf.dmp: |
64 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp | 76 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp |
65 | 77 |
66 clean: | 78 clean: |
67 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp | 79 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp ${PROG}.fuse |
68 | 80 |
69 prog: all | 81 prog: ${PROG}.elf ${FUSEFILE} |
70 ${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS} | 82 ${PROGRAMMER} ${PROGOPTS} |
71 | 83 |
72 | 84 ######################### |
85 #;;; Local Variables: *** | |
86 #;;; mode:makefile *** | |
87 #;;; End: *** |