You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
1.3 KiB

  1. CC := avr-gcc
  2. LD := avr-ld
  3. OBJCOPY := avr-objcopy
  4. OBJDUMP := avr-objdump
  5. SIZE := avr-size
  6. TARGET = e2promprog
  7. SOURCE = $(wildcard *.c)
  8. MCU=attiny2313
  9. AVRDUDE_MCU=attiny2313
  10. AVRDUDE_FUSES=lfuse:w:0xe4:m hfuse:w:0xdf:m efuse:w:0xff:m
  11. AVRDUDE_PROG := -c avr910 -b 115200 -P /dev/ispprog
  12. #AVRDUDE_PROG := -c dragon_isp -P usb
  13. # ---------------------------------------------------------------------------
  14. CFLAGS = -pipe -g -Os -mmcu=$(MCU) -Wall
  15. CFLAGS += -fdata-sections -ffunction-sections
  16. CFLAGS += -Wa,-adhlns=$(*F).lst
  17. LDFLAGS = -Wl,-Map,$(@:.elf=.map),--cref
  18. LDFLAGS += -Wl,--relax,--gc-sections
  19. # ---------------------------------------------------------------------------
  20. $(TARGET): $(TARGET).elf
  21. @$(SIZE) -B -x --mcu=$(MCU) $<
  22. $(TARGET).elf: $(SOURCE:.c=.o)
  23. @echo " Linking file: $@"
  24. @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ 2> /dev/null
  25. @$(OBJDUMP) -h -S $@ > $(@:.elf=.lss)
  26. @$(OBJCOPY) -j .text -j .data -O ihex $@ $(@:.elf=.hex)
  27. @$(OBJCOPY) -j .text -j .data -O binary $@ $(@:.elf=.bin)
  28. %.o: %.c $(MAKEFILE_LIST)
  29. @echo " Building file: $<"
  30. @$(CC) $(CFLAGS) -o $@ -c $<
  31. clean:
  32. rm -rf $(SOURCE:.c=.o) $(SOURCE:.c=.lst) $(addprefix $(TARGET), .elf .map .lss .hex .bin)
  33. install: $(TARGET).elf
  34. avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U flash:w:$(<:.elf=.hex)
  35. fuses:
  36. avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) $(patsubst %,-U %, $(AVRDUDE_FUSES))