update Makefile
This commit is contained in:
parent
1b9c5ba1ed
commit
6afa5ccbd7
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,4 +3,5 @@
|
|||||||
*.bin
|
*.bin
|
||||||
*.hex
|
*.hex
|
||||||
*.lst
|
*.lst
|
||||||
|
*.lss
|
||||||
*.map
|
*.map
|
||||||
|
80
Makefile
80
Makefile
@ -1,51 +1,53 @@
|
|||||||
PRG = ispprog
|
CC := avr-gcc
|
||||||
OBJ = ispprog.o
|
LD := avr-ld
|
||||||
MCU_TARGET = atmega16
|
OBJCOPY := avr-objcopy
|
||||||
OPTIMIZE = -Os
|
OBJDUMP := avr-objdump
|
||||||
|
SIZE := avr-size
|
||||||
|
|
||||||
DEFS =
|
TARGET = ispprog
|
||||||
LIBS =
|
SOURCE = $(wildcard *.c)
|
||||||
|
|
||||||
# You should not have to change anything below here.
|
# select MCU
|
||||||
|
MCU = atmega16
|
||||||
|
|
||||||
CC = avr-gcc
|
AVRDUDE_PROG := -c butterfly -b 19200 -P /dev/ttyUSB0
|
||||||
|
#AVRDUDE_PROG := -c dragon_isp -P usb
|
||||||
|
|
||||||
# Override is only needed by avr-lib build system.
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
|
ifeq ($(MCU), atmega16)
|
||||||
override LDFLAGS = -Wl,-Map,$(PRG).map
|
# (ext. crystal)
|
||||||
|
AVRDUDE_MCU=m16
|
||||||
|
AVRDUDE_FUSES=lfuse:w:0xff:m hfuse:w:0xda:m
|
||||||
|
endif
|
||||||
|
|
||||||
OBJCOPY = avr-objcopy
|
# ---------------------------------------------------------------------------
|
||||||
OBJDUMP = avr-objdump
|
|
||||||
SIZE = avr-size
|
|
||||||
|
|
||||||
all: $(PRG).elf lst text
|
CFLAGS = -pipe -g -Os -mmcu=$(MCU) -Wall -fdata-sections -ffunction-sections
|
||||||
$(SIZE) -x -A $(PRG).elf
|
CFLAGS += -Wa,-adhlns=$(*F).lst
|
||||||
|
LDFLAGS = -Wl,-Map,$(@:.elf=.map),--cref,--relax,--gc-sections
|
||||||
|
|
||||||
$(PRG).elf: $(OBJ)
|
# ---------------------------------------------------------------------------
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
||||||
|
$(TARGET): $(TARGET).elf
|
||||||
|
@$(SIZE) -B -x --mcu=$(MCU) $<
|
||||||
|
|
||||||
|
$(TARGET).elf: $(SOURCE:.c=.o)
|
||||||
|
@echo " Linking file: $@"
|
||||||
|
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
||||||
|
@$(OBJDUMP) -h -S $@ > $(@:.elf=.lss)
|
||||||
|
@$(OBJCOPY) -j .text -j .data -O ihex $@ $(@:.elf=.hex)
|
||||||
|
@$(OBJCOPY) -j .text -j .data -O binary $@ $(@:.elf=.bin)
|
||||||
|
|
||||||
|
%.o: %.c $(MAKEFILE_LIST)
|
||||||
|
@echo " Building file: $<"
|
||||||
|
@$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o $(PRG).lst $(PRG).map $(PRG).elf $(PRG).hex $(PRG).bin
|
rm -rf $(SOURCE:.c=.o) $(SOURCE:.c=.lst) $(addprefix $(TARGET), .elf .map .lss .hex .bin)
|
||||||
|
|
||||||
lst: $(PRG).lst
|
install: $(TARGET).elf
|
||||||
|
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U flash:w:$(<:.elf=.hex)
|
||||||
|
|
||||||
%.lst: %.elf
|
fuses:
|
||||||
$(OBJDUMP) -h -S $< > $@
|
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) $(patsubst %,-U %, $(AVRDUDE_FUSES))
|
||||||
|
|
||||||
# Rules for building the .text rom images
|
|
||||||
|
|
||||||
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
|
|
||||||
# uisp -dprog=stk200 --erase --upload if=$(PRG).hex --verify
|
|
||||||
avrdude -p m16 -c butterfly -b 19200 -P /dev/ttyUSB0 -U flash:w:$(PRG).hex
|
|
||||||
|
Loading…
Reference in New Issue
Block a user