2010-03-30 20:09:55 +02:00
# Makefile for ATmegaBOOT
# E.Lins, 18.7.2005
# $Id$
2011-02-23 21:47:18 +01:00
#
2010-03-30 20:09:55 +02:00
# Instructions
#
2011-02-23 21:47:18 +01:00
# To make bootloader .hex file:
# make diecimila
# make lilypad
# make ng
# etc...
#
# To burn bootloader .hex file:
# make diecimila_isp
# make lilypad_isp
# make ng_isp
# etc...
2010-03-30 20:09:55 +02:00
# program name should not be changed...
PROGRAM = ATmegaBOOT_168
# enter the parameters for the avrdude isp tool
ISPTOOL = stk500v2
ISPPORT = usb
ISPSPEED = -b 115200
MCU_TARGET = atmega168
LDSECTION = --section-start= .text= 0x3800
# the efuse should really be 0xf8; since, however, only the lower
# three bits of that byte are used on the atmega168, avrdude gets
# confused if you specify 1's for the higher bits, see:
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
#
# similarly, the lock bits should be 0xff instead of 0x3f (to
# unlock the bootloader section) and 0xcf instead of 0x0f (to
# lock it), but since the high two bits of the lock byte are
# unused, avrdude would get confused.
2011-02-23 21:47:18 +01:00
ISPFUSES = avrdude -c $( ISPTOOL) -p $( MCU_TARGET) -P $( ISPPORT) $( ISPSPEED) \
-e -u -U lock : w :0x 3f :m -U efuse :w :0x $( EFUSE ) :m -U hfuse :w :0x $( HFUSE ) :m -U lfuse :w :0x $( LFUSE ) :m
ISPFLASH = avrdude -c $( ISPTOOL) -p $( MCU_TARGET) -P $( ISPPORT) $( ISPSPEED) \
-U flash : w :$( PROGRAM ) _ $( TARGET ) .hex -U lock :w :0x 0f :m
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
STK500-1 = $( STK500) -e -d$( MCU_TARGET) -pf -vf -if$( PROGRAM) _$( TARGET) .hex \
- l F F - L F F - f $( HFUSE ) $( LFUSE ) - E F 8 - m s - q - c U S B - I 2 0 0 k H z - s - w t
STK500-2 = $( STK500) -d$( MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
2010-03-30 20:09:55 +02:00
OBJ = $( PROGRAM) .o
OPTIMIZE = -O2
DEFS =
LIBS =
CC = avr-gcc
# Override is only needed by avr-lib build system.
o v e r r i d e CFLAGS = -g -Wall $( OPTIMIZE) -mmcu= $( MCU_TARGET) -DF_CPU= $( AVR_FREQ) $( DEFS)
o v e r r i d e LDFLAGS = -Wl,$( LDSECTION)
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all :
2011-02-23 21:47:18 +01:00
atmega328_bt : TARGET = atmega 328_bt
atmega328_bt : MCU_TARGET = atmega 328p
atmega328_bt : AVR_FREQ = 16000000L
atmega328_bt : LDSECTION = --section -start =.text =0x 7000
atmega328_bt : $( PROGRAM ) _atmega 328_bt .hex
atmega328_bt_isp : atmega 328_bt
atmega328_bt_isp : TARGET = atmega 328_bt
atmega328_bt_isp : MCU_TARGET = atmega 328p
atmega328_bt_isp : HFUSE = D 8
atmega328_bt_isp : LFUSE = FF
atmega328_bt_isp : EFUSE = 05
atmega328_bt_isp : isp
isp : $( TARGET )
$( ISPFUSES)
$( ISPFLASH)
isp-stk500 : $( PROGRAM ) _ $( TARGET ) .hex
$( STK500-1)
$( STK500-2)
%.elf : $( OBJ )
2010-03-30 20:09:55 +02:00
$( CC) $( CFLAGS) $( LDFLAGS) -o $@ $^ $( LIBS)
2011-02-23 21:47:18 +01:00
clean :
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
2010-03-30 20:09:55 +02:00
%.lst : %.elf
$( OBJDUMP) -h -S $< > $@
2011-02-23 21:47:18 +01:00
%.hex : %.elf
$( OBJCOPY) -j .text -j .data -O ihex $< $@
2010-03-30 20:09:55 +02:00
%.srec : %.elf
$( OBJCOPY) -j .text -j .data -O srec $< $@
%.bin : %.elf
$( OBJCOPY) -j .text -j .data -O binary $< $@