My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

Makefile 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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 = optiboot
  20. # The default behavior is to build using tools that are in the users
  21. # current path variables, but we can also build using an installed
  22. # Arduino user IDE setup, or the Arduino source tree.
  23. # Uncomment this next lines to build within the arduino environment,
  24. # using the arduino-included avrgcc toolset (mac and pc)
  25. # ENV ?= arduino
  26. # ENV ?= arduinodev
  27. # OS ?= macosx
  28. # OS ?= windows
  29. # enter the parameters for the avrdude isp tool
  30. ISPTOOL = stk500v2
  31. ISPPORT = usb
  32. ISPSPEED = -b 115200
  33. MCU_TARGET = atmega168
  34. LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
  35. # Build environments
  36. # Start of some ugly makefile-isms to allow optiboot to be built
  37. # in several different environments. See the README.TXT file for
  38. # details.
  39. # default
  40. fixpath = $(1)
  41. ifeq ($(ENV), arduino)
  42. # For Arduino, we assume that we're connected to the optiboot directory
  43. # included with the arduino distribution, which means that the full set
  44. # of avr-tools are "right up there" in standard places.
  45. TOOLROOT = ../../../tools
  46. GCCROOT = $(TOOLROOT)/avr/bin/
  47. AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
  48. ifeq ($(OS), windows)
  49. # On windows, SOME of the tool paths will need to have backslashes instead
  50. # of forward slashes (because they use windows cmd.exe for execution instead
  51. # of a unix/mingw shell?) We also have to ensure that a consistent shell
  52. # is used even if a unix shell is installed (ie as part of WINAVR)
  53. fixpath = $(subst /,\,$1)
  54. SHELL = cmd.exe
  55. endif
  56. else ifeq ($(ENV), arduinodev)
  57. # Arduino IDE source code environment. Use the unpacked compilers created
  58. # by the build (you'll need to do "ant build" first.)
  59. ifeq ($(OS), macosx)
  60. TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
  61. endif
  62. ifeq ($(OS), windows)
  63. TOOLROOT = ../../../../build/windows/work/hardware/tools
  64. endif
  65. GCCROOT = $(TOOLROOT)/avr/bin/
  66. AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
  67. else
  68. GCCROOT =
  69. AVRDUDE_CONF =
  70. endif
  71. #
  72. # End of build environment code.
  73. # the efuse should really be 0xf8; since, however, only the lower
  74. # three bits of that byte are used on the atmega168, avrdude gets
  75. # confused if you specify 1's for the higher bits, see:
  76. # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
  77. #
  78. # similarly, the lock bits should be 0xff instead of 0x3f (to
  79. # unlock the bootloader section) and 0xcf instead of 0x2f (to
  80. # lock it), but since the high two bits of the lock byte are
  81. # unused, avrdude would get confused.
  82. ISPFUSES = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
  83. -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  84. -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
  85. -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
  86. ISPFLASH = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
  87. -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  88. -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
  89. STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
  90. STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
  91. -lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
  92. STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
  93. OBJ = $(PROGRAM).o
  94. OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls
  95. DEFS =
  96. LIBS =
  97. CC = $(GCCROOT)avr-gcc
  98. # Override is only needed by avr-lib build system.
  99. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
  100. override LDFLAGS = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib
  101. OBJCOPY = $(GCCROOT)avr-objcopy
  102. OBJDUMP = $(call fixpath,$(GCCROOT)avr-objdump)
  103. SIZE = $(GCCROOT)avr-size
  104. # Test platforms
  105. # Virtual boot block test
  106. virboot328: TARGET = atmega328
  107. virboot328: MCU_TARGET = atmega328p
  108. virboot328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DVIRTUAL_BOOT'
  109. virboot328: AVR_FREQ = 16000000L
  110. virboot328: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
  111. virboot328: $(PROGRAM)_atmega328.hex
  112. virboot328: $(PROGRAM)_atmega328.lst
  113. # 20MHz clocked platforms
  114. #
  115. # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
  116. #
  117. pro20: TARGET = pro_20mhz
  118. pro20: MCU_TARGET = atmega168
  119. pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  120. pro20: AVR_FREQ = 20000000L
  121. pro20: $(PROGRAM)_pro_20mhz.hex
  122. pro20: $(PROGRAM)_pro_20mhz.lst
  123. pro20_isp: pro20
  124. pro20_isp: TARGET = pro_20mhz
  125. # 2.7V brownout
  126. pro20_isp: HFUSE = DD
  127. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  128. pro20_isp: LFUSE = C6
  129. # 512 byte boot
  130. pro20_isp: EFUSE = 04
  131. pro20_isp: isp
  132. # 16MHz clocked platforms
  133. #
  134. # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
  135. #
  136. pro16: TARGET = pro_16MHz
  137. pro16: MCU_TARGET = atmega168
  138. pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  139. pro16: AVR_FREQ = 16000000L
  140. pro16: $(PROGRAM)_pro_16MHz.hex
  141. pro16: $(PROGRAM)_pro_16MHz.lst
  142. pro16_isp: pro16
  143. pro16_isp: TARGET = pro_16MHz
  144. # 2.7V brownout
  145. pro16_isp: HFUSE = DD
  146. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  147. pro16_isp: LFUSE = C6
  148. # 512 byte boot
  149. pro16_isp: EFUSE = 04
  150. pro16_isp: isp
  151. # Diecimila, Duemilanove with m168, and NG use identical bootloaders
  152. # Call it "atmega168" for generality and clarity, keep "diecimila" for
  153. # backward compatibility of makefile
  154. #
  155. atmega168: TARGET = atmega168
  156. atmega168: MCU_TARGET = atmega168
  157. atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  158. atmega168: AVR_FREQ = 16000000L
  159. atmega168: $(PROGRAM)_atmega168.hex
  160. atmega168: $(PROGRAM)_atmega168.lst
  161. atmega168_isp: atmega168
  162. atmega168_isp: TARGET = atmega168
  163. # 2.7V brownout
  164. atmega168_isp: HFUSE = DD
  165. # Low power xtal (16MHz) 16KCK/14CK+65ms
  166. atmega168_isp: LFUSE = FF
  167. # 512 byte boot
  168. atmega168_isp: EFUSE = 04
  169. atmega168_isp: isp
  170. diecimila: TARGET = diecimila
  171. diecimila: MCU_TARGET = atmega168
  172. diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  173. diecimila: AVR_FREQ = 16000000L
  174. diecimila: $(PROGRAM)_diecimila.hex
  175. diecimila: $(PROGRAM)_diecimila.lst
  176. diecimila_isp: diecimila
  177. diecimila_isp: TARGET = diecimila
  178. # 2.7V brownout
  179. diecimila_isp: HFUSE = DD
  180. # Low power xtal (16MHz) 16KCK/14CK+65ms
  181. diecimila_isp: LFUSE = FF
  182. # 512 byte boot
  183. diecimila_isp: EFUSE = 04
  184. diecimila_isp: isp
  185. atmega328: TARGET = atmega328
  186. atmega328: MCU_TARGET = atmega328p
  187. atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  188. atmega328: AVR_FREQ = 16000000L
  189. atmega328: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
  190. atmega328: $(PROGRAM)_atmega328.hex
  191. atmega328: $(PROGRAM)_atmega328.lst
  192. atmega328_isp: atmega328
  193. atmega328_isp: TARGET = atmega328
  194. atmega328_isp: MCU_TARGET = atmega328p
  195. # 512 byte boot, SPIEN
  196. atmega328_isp: HFUSE = DE
  197. # Low power xtal (16MHz) 16KCK/14CK+65ms
  198. atmega328_isp: LFUSE = FF
  199. # 2.7V brownout
  200. atmega328_isp: EFUSE = 05
  201. atmega328_isp: isp
  202. atmega1284: TARGET = atmega1284p
  203. atmega1284: MCU_TARGET = atmega1284p
  204. atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
  205. atmega1284: AVR_FREQ = 16000000L
  206. atmega1284: LDSECTIONS = -Wl,--section-start=.text=0x1fc00
  207. atmega1284: $(PROGRAM)_atmega1284p.hex
  208. atmega1284: $(PROGRAM)_atmega1284p.lst
  209. atmega1284_isp: atmega1284
  210. atmega1284_isp: TARGET = atmega1284p
  211. atmega1284_isp: MCU_TARGET = atmega1284p
  212. # 1024 byte boot
  213. atmega1284_isp: HFUSE = DE
  214. # Low power xtal (16MHz) 16KCK/14CK+65ms
  215. atmega1284_isp: LFUSE = FF
  216. # 2.7V brownout
  217. atmega1284_isp: EFUSE = FD
  218. atmega1284_isp: isp
  219. # Sanguino has a minimum boot size of 1024 bytes, so enable extra functions
  220. #
  221. sanguino: TARGET = atmega644p
  222. sanguino: MCU_TARGET = atmega644p
  223. sanguino: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
  224. sanguino: AVR_FREQ = 16000000L
  225. sanguino: LDSECTIONS = -Wl,--section-start=.text=0xfc00
  226. sanguino: $(PROGRAM)_atmega644p.hex
  227. sanguino: $(PROGRAM)_atmega644p.lst
  228. sanguino_isp: sanguino
  229. sanguino_isp: TARGET = atmega644p
  230. sanguino_isp: MCU_TARGET = atmega644p
  231. # 1024 byte boot
  232. sanguino_isp: HFUSE = DE
  233. # Low power xtal (16MHz) 16KCK/14CK+65ms
  234. sanguino_isp: LFUSE = FF
  235. # 2.7V brownout
  236. sanguino_isp: EFUSE = 05
  237. sanguino_isp: isp
  238. # Mega has a minimum boot size of 1024 bytes, so enable extra functions
  239. #mega: TARGET = atmega1280
  240. mega: MCU_TARGET = atmega1280
  241. mega: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
  242. mega: AVR_FREQ = 16000000L
  243. mega: LDSECTIONS = -Wl,--section-start=.text=0x1fc00
  244. mega: $(PROGRAM)_atmega1280.hex
  245. mega: $(PROGRAM)_atmega1280.lst
  246. mega_isp: mega
  247. mega_isp: TARGET = atmega1280
  248. mega_isp: MCU_TARGET = atmega1280
  249. # 1024 byte boot
  250. mega_isp: HFUSE = DE
  251. # Low power xtal (16MHz) 16KCK/14CK+65ms
  252. mega_isp: LFUSE = FF
  253. # 2.7V brownout
  254. mega_isp: EFUSE = 05
  255. mega_isp: isp
  256. # ATmega8
  257. #
  258. atmega8: TARGET = atmega8
  259. atmega8: MCU_TARGET = atmega8
  260. atmega8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  261. atmega8: AVR_FREQ = 16000000L
  262. atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
  263. atmega8: $(PROGRAM)_atmega8.hex
  264. atmega8: $(PROGRAM)_atmega8.lst
  265. atmega8_isp: atmega8
  266. atmega8_isp: TARGET = atmega8
  267. atmega8_isp: MCU_TARGET = atmega8
  268. # SPIEN, CKOPT, Bootsize=512B
  269. atmega8_isp: HFUSE = CC
  270. # 2.7V brownout, Low power xtal (16MHz) 16KCK/14CK+65ms
  271. atmega8_isp: LFUSE = BF
  272. atmega8_isp: isp
  273. # ATmega88
  274. #
  275. atmega88: TARGET = atmega88
  276. atmega88: MCU_TARGET = atmega88
  277. atmega88: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  278. atmega88: AVR_FREQ = 16000000L
  279. atmega88: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
  280. atmega88: $(PROGRAM)_atmega88.hex
  281. atmega88: $(PROGRAM)_atmega88.lst
  282. atmega88_isp: atmega88
  283. atmega88_isp: TARGET = atmega88
  284. atmega88_isp: MCU_TARGET = atmega88
  285. # 2.7V brownout
  286. atmega88_isp: HFUSE = DD
  287. # Low power xtal (16MHz) 16KCK/14CK+65ms
  288. atemga88_isp: LFUSE = FF
  289. # 512 byte boot
  290. atmega88_isp: EFUSE = 04
  291. atmega88_isp: isp
  292. # 8MHz clocked platforms
  293. #
  294. # These are capable of 115200 baud
  295. #
  296. lilypad: TARGET = lilypad
  297. lilypad: MCU_TARGET = atmega168
  298. lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  299. lilypad: AVR_FREQ = 8000000L
  300. lilypad: $(PROGRAM)_lilypad.hex
  301. lilypad: $(PROGRAM)_lilypad.lst
  302. lilypad_isp: lilypad
  303. lilypad_isp: TARGET = lilypad
  304. # 2.7V brownout
  305. lilypad_isp: HFUSE = DD
  306. # Internal 8MHz osc (8MHz) Slow rising power
  307. lilypad_isp: LFUSE = E2
  308. # 512 byte boot
  309. lilypad_isp: EFUSE = 04
  310. lilypad_isp: isp
  311. lilypad_resonator: TARGET = lilypad_resonator
  312. lilypad_resonator: MCU_TARGET = atmega168
  313. lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  314. lilypad_resonator: AVR_FREQ = 8000000L
  315. lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
  316. lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst
  317. lilypad_resonator_isp: lilypad_resonator
  318. lilypad_resonator_isp: TARGET = lilypad_resonator
  319. # 2.7V brownout
  320. lilypad_resonator_isp: HFUSE = DD
  321. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  322. lilypad_resonator_isp: LFUSE = C6
  323. # 512 byte boot
  324. lilypad_resonator_isp: EFUSE = 04
  325. lilypad_resonator_isp: isp
  326. pro8: TARGET = pro_8MHz
  327. pro8: MCU_TARGET = atmega168
  328. pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  329. pro8: AVR_FREQ = 8000000L
  330. pro8: $(PROGRAM)_pro_8MHz.hex
  331. pro8: $(PROGRAM)_pro_8MHz.lst
  332. pro8_isp: pro8
  333. pro8_isp: TARGET = pro_8MHz
  334. # 2.7V brownout
  335. pro8_isp: HFUSE = DD
  336. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  337. pro8_isp: LFUSE = C6
  338. # 512 byte boot
  339. pro8_isp: EFUSE = 04
  340. pro8_isp: isp
  341. atmega328_pro8: TARGET = atmega328_pro_8MHz
  342. atmega328_pro8: MCU_TARGET = atmega328p
  343. atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
  344. atmega328_pro8: AVR_FREQ = 8000000L
  345. atmega328_pro8: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
  346. atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
  347. atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst
  348. atmega328_pro8_isp: atmega328_pro8
  349. atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
  350. atmega328_pro8_isp: MCU_TARGET = atmega328p
  351. # 512 byte boot, SPIEN
  352. atmega328_pro8_isp: HFUSE = DE
  353. # Low power xtal (16MHz) 16KCK/14CK+65ms
  354. atmega328_pro8_isp: LFUSE = FF
  355. # 2.7V brownout
  356. atmega328_pro8_isp: EFUSE = 05
  357. atmega328_pro8_isp: isp
  358. # 1MHz clocked platforms
  359. #
  360. # These are capable of 9600 baud
  361. #
  362. luminet: TARGET = luminet
  363. luminet: MCU_TARGET = attiny84
  364. luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
  365. luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
  366. luminet: AVR_FREQ = 1000000L
  367. luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
  368. luminet: $(PROGRAM)_luminet.hex
  369. luminet: $(PROGRAM)_luminet.lst
  370. luminet_isp: luminet
  371. luminet_isp: TARGET = luminet
  372. luminet_isp: MCU_TARGET = attiny84
  373. # Brownout disabled
  374. luminet_isp: HFUSE = DF
  375. # 1MHz internal oscillator, slowly rising power
  376. luminet_isp: LFUSE = 62
  377. # Self-programming enable
  378. luminet_isp: EFUSE = FE
  379. luminet_isp: isp
  380. #
  381. # Generic build instructions
  382. #
  383. #
  384. isp: $(TARGET)
  385. $(ISPFUSES)
  386. $(ISPFLASH)
  387. isp-stk500: $(PROGRAM)_$(TARGET).hex
  388. $(STK500-1)
  389. $(STK500-2)
  390. %.elf: $(OBJ)
  391. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  392. $(SIZE) $@
  393. clean:
  394. rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
  395. %.lst: %.elf
  396. $(OBJDUMP) -h -S $< > $@
  397. %.hex: %.elf
  398. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
  399. %.srec: %.elf
  400. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
  401. %.bin: %.elf
  402. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@