A TWI / I2C bootloader for AVR MCUs
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.

66 lines
1.5KB

  1. PRG = twiboot
  2. OBJ = main.o
  3. MCU_TARGET = atmega88
  4. OPTIMIZE = -Os
  5. ifeq ($(MCU_TARGET), atmega8)
  6. BOOTLOADER_START=0x1C00
  7. AVRDUDE_MCU=m8
  8. endif
  9. ifeq ($(MCU_TARGET), atmega88)
  10. BOOTLOADER_START=0x1C00
  11. AVRDUDE_MCU=m88
  12. endif
  13. ifeq ($(MCU_TARGET), atmega168)
  14. BOOTLOADER_START=0x3C00
  15. AVRDUDE_MCU=m168
  16. endif
  17. DEFS = -DAPP_END=$(BOOTLOADER_START)
  18. LIBS =
  19. # Override is only needed by avr-lib build system.
  20. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
  21. override LDFLAGS = -Wl,-Map,$(PRG).map,--section-start=.text=$(BOOTLOADER_START)
  22. CC = avr-gcc
  23. OBJCOPY = avr-objcopy
  24. OBJDUMP = avr-objdump
  25. SIZE = avr-size
  26. all: $(PRG).elf lst text
  27. $(SIZE) -x -A $(PRG).elf
  28. $(PRG).elf: $(OBJ)
  29. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  30. %.o: %.c $(MAKEFILE_LIST)
  31. $(CC) $(CFLAGS) -c $< -o $@
  32. clean:
  33. rm -rf *.o $(PRG).lst $(PRG).map $(PRG).elf $(PRG).hex $(PRG).bin
  34. lst: $(PRG).lst
  35. %.lst: %.elf
  36. $(OBJDUMP) -h -S $< > $@
  37. text: hex bin
  38. hex: $(PRG).hex
  39. bin: $(PRG).bin
  40. %.hex: %.elf
  41. $(OBJCOPY) -j .text -j .data -O ihex $< $@
  42. %.bin: %.elf
  43. $(OBJCOPY) -j .text -j .data -O binary $< $@
  44. install: text
  45. avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U flash:w:$(PRG).hex
  46. #fuses:
  47. # avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U lfuse:w:0xc2:m
  48. # avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U hfuse:w:0xdd:m
  49. # avrdude -c dragon_isp -P usb -p $(AVRDUDE_MCU) -U efuse:w:0xfa:m