Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Makefile for ATmegaBOOT
  2. # E.Lins, 18.7.2005
  3. #
  4. # Instructions
  5. #
  6. # To make bootloader .hex file:
  7. # make diecimila
  8. # make lilypad
  9. # make ng
  10. # etc...
  11. #
  12. # To burn bootloader .hex file:
  13. # make diecimila_isp
  14. # make lilypad_isp
  15. # make ng_isp
  16. # etc...
  17. # program name should not be changed...
  18. PROGRAM = ATmegaBOOT_168
  19. # enter the parameters for the avrdude isp tool
  20. ISPTOOL = stk500v2
  21. ISPPORT = usb
  22. ISPSPEED = -b 115200
  23. MCU_TARGET = atmega168
  24. LDSECTION = --section-start=.text=0x3800
  25. # the efuse should really be 0xf8; since, however, only the lower
  26. # three bits of that byte are used on the atmega168, avrdude gets
  27. # confused if you specify 1's for the higher bits, see:
  28. # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
  29. #
  30. # similarly, the lock bits should be 0xff instead of 0x3f (to
  31. # unlock the bootloader section) and 0xcf instead of 0x0f (to
  32. # lock it), but since the high two bits of the lock byte are
  33. # unused, avrdude would get confused.
  34. ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  35. -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
  36. ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  37. -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
  38. STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
  39. STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
  40. -lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
  41. STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
  42. OBJ = $(PROGRAM).o
  43. OPTIMIZE = -O2
  44. DEFS =
  45. LIBS =
  46. CC = avr-gcc
  47. # Override is only needed by avr-lib build system.
  48. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
  49. override LDFLAGS = -Wl,$(LDSECTION)
  50. #override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
  51. OBJCOPY = avr-objcopy
  52. OBJDUMP = avr-objdump
  53. all:
  54. atmega328_bt: TARGET = atmega328_bt
  55. atmega328_bt: MCU_TARGET = atmega328p
  56. atmega328_bt: AVR_FREQ = 16000000L
  57. atmega328_bt: LDSECTION = --section-start=.text=0x7000
  58. atmega328_bt: $(PROGRAM)_atmega328_bt.hex
  59. atmega328_bt_isp: atmega328_bt
  60. atmega328_bt_isp: TARGET = atmega328_bt
  61. atmega328_bt_isp: MCU_TARGET = atmega328p
  62. atmega328_bt_isp: HFUSE = D8
  63. atmega328_bt_isp: LFUSE = FF
  64. atmega328_bt_isp: EFUSE = 05
  65. atmega328_bt_isp: isp
  66. isp: $(TARGET)
  67. $(ISPFUSES)
  68. $(ISPFLASH)
  69. isp-stk500: $(PROGRAM)_$(TARGET).hex
  70. $(STK500-1)
  71. $(STK500-2)
  72. %.elf: $(OBJ)
  73. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  74. clean:
  75. rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
  76. %.lst: %.elf
  77. $(OBJDUMP) -h -S $< > $@
  78. %.hex: %.elf
  79. $(OBJCOPY) -j .text -j .data -O ihex $< $@
  80. %.srec: %.elf
  81. $(OBJCOPY) -j .text -j .data -O srec $< $@
  82. %.bin: %.elf
  83. $(OBJCOPY) -j .text -j .data -O binary $< $@