Makefile 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. # Makefile for ATmegaBOOT
  2. # E.Lins, 18.7.2005
  3. # $Id$
  4. #
  5. # Instructions
  6. #
  7. # To make bootloader .hex file:
  8. # make diecimila
  9. # make lilypad
  10. # make ng
  11. # etc...
  12. #
  13. # To burn bootloader .hex file:
  14. # make diecimila_isp
  15. # make lilypad_isp
  16. # make ng_isp
  17. # etc...
  18. # program name should not be changed...
  19. PROGRAM = ATmegaBOOT_168
  20. # enter the parameters for the avrdude isp tool
  21. ISPTOOL = stk500v2
  22. ISPPORT = usb
  23. ISPSPEED = -b 115200
  24. MCU_TARGET = atmega168
  25. LDSECTION = --section-start=.text=0x3800
  26. # the efuse should really be 0xf8; since, however, only the lower
  27. # three bits of that byte are used on the atmega168, avrdude gets
  28. # confused if you specify 1's for the higher bits, see:
  29. # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
  30. #
  31. # similarly, the lock bits should be 0xff instead of 0x3f (to
  32. # unlock the bootloader section) and 0xcf instead of 0x0f (to
  33. # lock it), but since the high two bits of the lock byte are
  34. # unused, avrdude would get confused.
  35. ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  36. -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
  37. ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  38. -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
  39. STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
  40. STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
  41. -lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
  42. STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
  43. OBJ = $(PROGRAM).o
  44. OPTIMIZE = -O2
  45. DEFS =
  46. LIBS =
  47. CC = avr-gcc
  48. # Override is only needed by avr-lib build system.
  49. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
  50. override LDFLAGS = -Wl,$(LDSECTION)
  51. #override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
  52. OBJCOPY = avr-objcopy
  53. OBJDUMP = avr-objdump
  54. all:
  55. lilypad: TARGET = lilypad
  56. lilypad: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
  57. lilypad: AVR_FREQ = 8000000L
  58. lilypad: $(PROGRAM)_lilypad.hex
  59. lilypad_isp: lilypad
  60. lilypad_isp: TARGET = lilypad
  61. lilypad_isp: HFUSE = DD
  62. lilypad_isp: LFUSE = E2
  63. lilypad_isp: EFUSE = 00
  64. lilypad_isp: isp
  65. lilypad_resonator: TARGET = lilypad_resonator
  66. lilypad_resonator: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=3'
  67. lilypad_resonator: AVR_FREQ = 8000000L
  68. lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
  69. lilypad_resonator_isp: lilypad_resonator
  70. lilypad_resonator_isp: TARGET = lilypad_resonator
  71. lilypad_resonator_isp: HFUSE = DD
  72. lilypad_resonator_isp: LFUSE = C6
  73. lilypad_resonator_isp: EFUSE = 00
  74. lilypad_resonator_isp: isp
  75. pro8: TARGET = pro_8MHz
  76. pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
  77. pro8: AVR_FREQ = 8000000L
  78. pro8: $(PROGRAM)_pro_8MHz.hex
  79. pro8_isp: pro8
  80. pro8_isp: TARGET = pro_8MHz
  81. pro8_isp: HFUSE = DD
  82. pro8_isp: LFUSE = C6
  83. pro8_isp: EFUSE = 00
  84. pro8_isp: isp
  85. pro16: TARGET = pro_16MHz
  86. pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
  87. pro16: AVR_FREQ = 16000000L
  88. pro16: $(PROGRAM)_pro_16MHz.hex
  89. pro16_isp: pro16
  90. pro16_isp: TARGET = pro_16MHz
  91. pro16_isp: HFUSE = DD
  92. pro16_isp: LFUSE = C6
  93. pro16_isp: EFUSE = 00
  94. pro16_isp: isp
  95. pro20: TARGET = pro_20mhz
  96. pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
  97. pro20: AVR_FREQ = 20000000L
  98. pro20: $(PROGRAM)_pro_20mhz.hex
  99. pro20_isp: pro20
  100. pro20_isp: TARGET = pro_20mhz
  101. pro20_isp: HFUSE = DD
  102. pro20_isp: LFUSE = C6
  103. pro20_isp: EFUSE = 00
  104. pro20_isp: isp
  105. diecimila: TARGET = diecimila
  106. diecimila: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1'
  107. diecimila: AVR_FREQ = 16000000L
  108. diecimila: $(PROGRAM)_diecimila.hex
  109. diecimila_isp: diecimila
  110. diecimila_isp: TARGET = diecimila
  111. diecimila_isp: HFUSE = DD
  112. diecimila_isp: LFUSE = FF
  113. diecimila_isp: EFUSE = 00
  114. diecimila_isp: isp
  115. ng: TARGET = ng
  116. ng: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
  117. ng: AVR_FREQ = 16000000L
  118. ng: $(PROGRAM)_ng.hex
  119. ng_isp: ng
  120. ng_isp: TARGET = ng
  121. ng_isp: HFUSE = DD
  122. ng_isp: LFUSE = FF
  123. ng_isp: EFUSE = 00
  124. ng_isp: isp
  125. atmega328: TARGET = atmega328
  126. atmega328: MCU_TARGET = atmega328p
  127. atmega328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600
  128. atmega328: AVR_FREQ = 16000000L
  129. atmega328: LDSECTION = --section-start=.text=0x7800
  130. atmega328: $(PROGRAM)_atmega328.hex
  131. atmega328_isp: atmega328
  132. atmega328_isp: TARGET = atmega328
  133. atmega328_isp: MCU_TARGET = atmega328p
  134. atmega328_isp: HFUSE = DA
  135. atmega328_isp: LFUSE = FF
  136. atmega328_isp: EFUSE = 05
  137. atmega328_isp: isp
  138. atmega328_pro8: TARGET = atmega328_pro_8MHz
  139. atmega328_pro8: MCU_TARGET = atmega328p
  140. atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
  141. atmega328_pro8: AVR_FREQ = 8000000L
  142. atmega328_pro8: LDSECTION = --section-start=.text=0x7800
  143. atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
  144. atmega328_pro8_isp: atmega328_pro8
  145. atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
  146. atmega328_pro8_isp: MCU_TARGET = atmega328p
  147. atmega328_pro8_isp: HFUSE = DA
  148. atmega328_pro8_isp: LFUSE = FF
  149. atmega328_pro8_isp: EFUSE = 05
  150. atmega328_pro8_isp: isp
  151. mega: TARGET = atmega1280
  152. mega: MCU_TARGET = atmega1280
  153. mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600
  154. mega: AVR_FREQ = 16000000L
  155. mega: LDSECTION = --section-start=.text=0x1F000
  156. mega: $(PROGRAM)_atmega1280.hex
  157. mega_isp: mega
  158. mega_isp: TARGET = atmega1280
  159. mega_isp: MCU_TARGET = atmega1280
  160. mega_isp: HFUSE = DA
  161. mega_isp: LFUSE = FF
  162. mega_isp: EFUSE = F5
  163. mega_isp: isp
  164. atmega1284p: TARGET = atmega1284p
  165. atmega1284p: MCU_TARGET = atmega1284p
  166. atmega1284p: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=57600'
  167. atmega1284p: AVR_FREQ = 16000000L
  168. atmega1284p: LDSECTION = --section-start=.text=0x1F000
  169. atmega1284p: $(PROGRAM)_atmega1284p.hex
  170. atmega1284p_8m: TARGET = atmega1284p
  171. atmega1284p_8m: MCU_TARGET = atmega1284p
  172. atmega1284p_8m: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=19200'
  173. atmega1284p_8m: AVR_FREQ = 8000000L
  174. atmega1284p_8m: LDSECTION = --section-start=.text=0x1F000
  175. atmega1284p_8m: $(PROGRAM)_atmega1284p_8m.hex
  176. atmega644p: TARGET = atmega644p
  177. atmega644p: MCU_TARGET = atmega644p
  178. atmega644p: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=57600'
  179. atmega644p: AVR_FREQ = 16000000L
  180. atmega644p: LDSECTION = --section-start=.text=0xF800
  181. atmega644p: $(PROGRAM)_atmega644p.hex
  182. atmega1284p_isp: atmega1284p
  183. atmega1284p_isp: TARGET = atmega1284p
  184. atmega1284p_isp: MCU_TARGET = atmega1284p
  185. atmega1284p_isp: HFUSE = DC
  186. atmega1284p_isp: LFUSE = FF
  187. atmega1284p_isp: EFUSE = FD
  188. atmega1284p_isp: isp
  189. isp: $(TARGET)
  190. $(ISPFUSES)
  191. $(ISPFLASH)
  192. isp-stk500: $(PROGRAM)_$(TARGET).hex
  193. $(STK500-1)
  194. $(STK500-2)
  195. %.elf: $(OBJ)
  196. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  197. clean:
  198. rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
  199. %.lst: %.elf
  200. $(OBJDUMP) -h -S $< > $@
  201. %.hex: %.elf
  202. $(OBJCOPY) -j .text -j .data -O ihex $< $@
  203. %.srec: %.elf
  204. $(OBJCOPY) -j .text -j .data -O srec $< $@
  205. %.bin: %.elf
  206. $(OBJCOPY) -j .text -j .data -O binary $< $@