twiboot/Makefile

66 lines
1.5 KiB
Makefile
Raw Normal View History

2007-09-21 21:39:09 +02:00
PRG = twiboot
OBJ = main.o
2008-06-17 18:02:07 +02:00
MCU_TARGET = atmega88
2007-09-21 21:39:09 +02:00
OPTIMIZE = -Os
2010-08-15 16:44:54 +02:00
ifeq ($(MCU_TARGET), atmega8)
BOOTLOADER_START=0x1C00
AVRDUDE_MCU=m8
endif
ifeq ($(MCU_TARGET), atmega88)
BOOTLOADER_START=0x1C00
AVRDUDE_MCU=m88
endif
ifeq ($(MCU_TARGET), atmega168)
BOOTLOADER_START=0x3C00
AVRDUDE_MCU=m168
endif
DEFS = -DAPP_END=$(BOOTLOADER_START)
2007-09-21 21:39:09 +02:00
LIBS =
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
2010-08-15 16:44:54 +02:00
override LDFLAGS = -Wl,-Map,$(PRG).map,--section-start=.text=$(BOOTLOADER_START)
2007-09-21 21:39:09 +02:00
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
all: $(PRG).elf lst text
$(SIZE) -x -A $(PRG).elf
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
2010-08-15 16:44:54 +02:00
%.o: %.c $(MAKEFILE_LIST)
$(CC) $(CFLAGS) -c $< -o $@
2007-09-21 21:39:09 +02:00
clean:
2010-10-16 19:28:05 +02:00
rm -rf *.o $(PRG).lst $(PRG).map $(PRG).elf $(PRG).hex $(PRG).bin
2007-09-21 21:39:09 +02:00
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
text: hex bin
hex: $(PRG).hex
bin: $(PRG).bin
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
install: text
2010-08-15 16:44:54 +02:00
avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U flash:w:$(PRG).hex
2009-01-24 16:52:22 +01:00
2010-10-16 19:28:05 +02:00
#fuses:
# avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U lfuse:w:0xc2:m
# avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U hfuse:w:0xdd:m
# avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U efuse:w:0xfa:m