2007-10-05 01:45:15 +02:00
|
|
|
PRG = fc_boot
|
|
|
|
OBJ = main.o
|
2010-12-26 19:32:28 +01:00
|
|
|
MCU_TARGET = atmega644p
|
2007-10-05 01:45:15 +02:00
|
|
|
OPTIMIZE = -Os
|
|
|
|
|
|
|
|
DEFS =
|
|
|
|
LIBS =
|
|
|
|
|
2011-06-05 14:39:59 +02:00
|
|
|
LDSCRIPT_SRC := /usr/lib/ldscripts/avr5.x
|
|
|
|
LDSCRIPT_DST := ldscript-no-vectors.x
|
|
|
|
|
2007-10-05 01:45:15 +02:00
|
|
|
# Override is only needed by avr-lib build system.
|
|
|
|
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
|
2011-06-05 14:39:59 +02:00
|
|
|
override LDFLAGS = -Wl,-Map,$(PRG).map,--section-start=.text=0xF800,-T$(LDSCRIPT_DST)
|
2007-10-05 01:45:15 +02:00
|
|
|
|
|
|
|
CC = avr-gcc
|
|
|
|
OBJCOPY = avr-objcopy
|
|
|
|
OBJDUMP = avr-objdump
|
|
|
|
SIZE = avr-size
|
|
|
|
|
2011-06-05 14:39:59 +02:00
|
|
|
#LDSCRIPT_SRC := $(shell LANG=C $(CC) $(CFLAGS) -Wl,--verbose 2> /dev/null | awk '/^opened script file (.*)$$/{ print $$4 }')
|
|
|
|
|
2007-10-05 01:45:15 +02:00
|
|
|
all: $(PRG).elf lst text
|
|
|
|
$(SIZE) -x -A $(PRG).elf
|
|
|
|
|
2011-06-05 14:39:59 +02:00
|
|
|
$(PRG).elf: $(OBJ) | $(LDSCRIPT_DST)
|
2007-10-05 01:45:15 +02:00
|
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
|
|
|
2011-06-05 14:39:59 +02:00
|
|
|
$(LDSCRIPT_DST): $(LDSCRIPT_SRC)
|
|
|
|
# remove all lines with *vectors* and insert DISCARD line above .text declaration
|
|
|
|
sed -e '/.*vectors.*/d' -e 's/\(^[ \t]*\)\(.text[ \t]*\:\)$$/\1\/DISCARD\/ : { *(.vectors) }\n\1\2/g' $^ > $@
|
|
|
|
# -diff -uNr $^ $@ > $@.diff
|
|
|
|
|
2007-10-05 01:45:15 +02:00
|
|
|
clean:
|
2011-06-05 14:39:59 +02:00
|
|
|
rm -rf *.o $(PRG).lst $(PRG).map $(PRG).elf $(PRG).hex $(PRG).bin $(LDSCRIPT_DST)
|
2007-10-05 01:45:15 +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
|
2011-06-05 14:39:59 +02:00
|
|
|
avrdude -c dragon_isp -P usb -p m644p -V -U flash:w:$(PRG).hex
|