Mercurial > ~darius > hgwebdir.cgi > avr-lib
diff 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 |
line wrap: on
line diff
--- a/Makefile.avr Sat Jan 01 19:44:02 2011 +1030 +++ b/Makefile.avr Thu Jan 06 23:37:15 2011 +1030 @@ -2,7 +2,7 @@ # Helper makefile to build AVR sources # -.SUFFIXES: .hex .out .c .o .elf .dmp .s +.SUFFIXES: .hex .out .c .o .elf .dmp .s .fuse # Otherwise we get -march=foo NO_CPU_CFLAGS= @@ -13,6 +13,8 @@ CC=avr-gcc OBJCOPY=avr-objcopy OBJDUMP=avr-objdump +SED=sed +TAIL=tail # Tell as to generate listings CPPFLAGS+=-Wa,-adhlmsn=${<:T:S/.c/.lst/} @@ -27,8 +29,18 @@ PROGRAMMER=avrdude PROGTYPE?=alf + # Need the -B 1 or it is very slow. For slow clocks (eg factory fused) -B 10 works -PROGEXTRA?=-B 1 +PROGOPTS+=-B 10 + +.if defined(WITH_FUSES) +FUSEFILE=${PROG}.fuse +PROGOPTS+=`cat ${PROG}.fuse` +.elf.fuse: + ${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} +.else +FUSEFILE= +.endif .if ${PROGTYPE} != "dragon_isp" && ${PROGTYPE} != "dragon_jtag" PROGEXITS?=vcc,noreset @@ -41,7 +53,7 @@ _PROGPORT=-P ${PROGPORT} .endif -PROGOPTS?=-p ${PART} -c ${PROGTYPE} ${_PROGPORT} ${_PROGEXITS} -q ${PROGEXTRA} +PROGOPTS+=-p ${PART} -c ${PROGTYPE} ${_PROGPORT} ${_PROGEXITS} -q -U flash:w:${PROG}.hex ${PROGEXTRA} .if !defined(SRCS) SRCS= ${PROG}.c @@ -64,9 +76,12 @@ ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp clean: - ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp + ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp ${PROG}.fuse + +prog: ${PROG}.elf ${FUSEFILE} + ${PROGRAMMER} ${PROGOPTS} -prog: all - ${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS} - - +######################### +#;;; Local Variables: *** +#;;; mode:makefile *** +#;;; End: ***