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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. # Marlin Firmware Arduino Project Makefile
  2. #
  3. # Makefile Based on:
  4. # Arduino 0011 Makefile
  5. # Arduino adaptation by mellis, eighthave, oli.keller
  6. # Marlin adaption by Daid
  7. # Marlin 2.0 support and RELOC_WORKAROUND by @marcio-ao
  8. #
  9. # This has been tested with Arduino 0022.
  10. #
  11. # This makefile allows you to build sketches from the command line
  12. # without the Arduino environment (or Java).
  13. #
  14. # Detailed instructions for using the makefile:
  15. #
  16. # 1. Modify the line containing "ARDUINO_INSTALL_DIR" to point to the directory that
  17. # contains the Arduino installation (for example, under Mac OS X, this
  18. # might be /Applications/Arduino.app/Contents/Resources/Java).
  19. #
  20. # 2. Modify the line containing "UPLOAD_PORT" to refer to the filename
  21. # representing the USB or serial connection to your Arduino board
  22. # (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file
  23. # changes, you can use * as a wild card (e.g. UPLOAD_PORT = /dev/tty.usb*).
  24. #
  25. # 3. Set the line containing "MCU" to match your board's processor.
  26. # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
  27. # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
  28. # change F_CPU to 8000000. If you are using Gen7 electronics, you
  29. # probably need to use 20000000. Either way, you must regenerate
  30. # the speed lookup table with create_speed_lookuptable.py.
  31. #
  32. # 4. Type "make" and press enter to compile/verify your program.
  33. #
  34. # 5. Type "make upload", reset your Arduino board, and press enter to
  35. # upload your program to the Arduino board.
  36. #
  37. # Note that all settings at the top of this file can be overriden from
  38. # the command line with, for example, "make HARDWARE_MOTHERBOARD=71"
  39. #
  40. # To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use...
  41. #
  42. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  43. # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino
  44. #
  45. # To compile and upload simply add "upload" to the end of the line...
  46. #
  47. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  48. # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino upload
  49. #
  50. # If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or
  51. # start upload manually (using stk500) like so:
  52. #
  53. # avrdude -C /root/arduino/hardware/tools/avr/etc/avrdude.conf -v -p m2560 -c stk500 \
  54. # -U flash:w:applet/Marlin.hex:i -P /dev/ttyUSB0
  55. #
  56. # Or, try disconnecting USB to power down and then reconnecting before running avrdude.
  57. #
  58. # This defines the board to compile for (see boards.h for your board's ID)
  59. HARDWARE_MOTHERBOARD ?= 11
  60. # Arduino source install directory, and version number
  61. # On most linuxes this will be /usr/share/arduino
  62. ARDUINO_INSTALL_DIR ?= ${HOME}/Arduino
  63. ARDUINO_VERSION ?= 106
  64. # The installed Libraries are in the User folder
  65. ARDUINO_USER_DIR ?= ${HOME}/Arduino
  66. # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
  67. AVR_TOOLS_PATH ?=
  68. #Programmer configuration
  69. UPLOAD_RATE ?= 57600
  70. AVRDUDE_PROGRAMMER ?= arduino
  71. # on most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
  72. UPLOAD_PORT ?= /dev/ttyUSB0
  73. #Directory used to build files in, contains all the build files, from object files to the final hex file
  74. #on linux it is best to put an absolute path like /home/username/tmp .
  75. BUILD_DIR ?= applet
  76. # This defines whether Liquid_TWI2 support will be built
  77. LIQUID_TWI2 ?= 0
  78. # this defines if Wire is needed
  79. WIRE ?= 0
  80. # this defines if U8GLIB is needed (may require RELOC_WORKAROUND)
  81. U8GLIB ?= 1
  82. # this defines whether to include the Trinamic TMC2630Stepper
  83. TMC2630 ?= 1
  84. ############
  85. # Try to automatically determine whether RELOC_WORKAROUND is needed based
  86. # on GCC versions:
  87. # http://www.avrfreaks.net/comment/1789106#comment-1789106
  88. CC_MAJ:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC__ | cut -f3 -d\ )
  89. CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ )
  90. CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ )
  91. CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) )))
  92. ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1)
  93. @echo This version of GCC is likely broken. Enabling relocation workaround.
  94. RELOC_WORKAROUND = 1
  95. endif
  96. ############################################################################
  97. # Below here nothing should be changed...
  98. # Here the Arduino variant is selected by the board type
  99. # HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
  100. # MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...
  101. ifeq ($(HARDWARE_MOTHERBOARD),0)
  102. # No motherboard selected
  103. #
  104. # RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560
  105. #
  106. # MEGA/RAMPS up to 1.2
  107. else ifeq ($(HARDWARE_MOTHERBOARD),3)
  108. # RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
  109. else ifeq ($(HARDWARE_MOTHERBOARD),33)
  110. # RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
  111. else ifeq ($(HARDWARE_MOTHERBOARD),34)
  112. # RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
  113. else ifeq ($(HARDWARE_MOTHERBOARD),35)
  114. # RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
  115. else ifeq ($(HARDWARE_MOTHERBOARD),36)
  116. # RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
  117. else ifeq ($(HARDWARE_MOTHERBOARD),38)
  118. # RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
  119. else ifeq ($(HARDWARE_MOTHERBOARD),43)
  120. # RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
  121. else ifeq ($(HARDWARE_MOTHERBOARD),44)
  122. # RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
  123. else ifeq ($(HARDWARE_MOTHERBOARD),45)
  124. # RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
  125. else ifeq ($(HARDWARE_MOTHERBOARD),46)
  126. # RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
  127. else ifeq ($(HARDWARE_MOTHERBOARD),48)
  128. # RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
  129. else ifeq ($(HARDWARE_MOTHERBOARD),143)
  130. # RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
  131. else ifeq ($(HARDWARE_MOTHERBOARD),144)
  132. # RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
  133. else ifeq ($(HARDWARE_MOTHERBOARD),145)
  134. # RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
  135. else ifeq ($(HARDWARE_MOTHERBOARD),146)
  136. # RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
  137. else ifeq ($(HARDWARE_MOTHERBOARD),148)
  138. #
  139. # RAMPS Derivatives - ATmega1280, ATmega2560
  140. #
  141. # 3Drag Controller
  142. else ifeq ($(HARDWARE_MOTHERBOARD),77)
  143. # Velleman K8200 Controller (derived from 3Drag Controller)
  144. else ifeq ($(HARDWARE_MOTHERBOARD),78)
  145. # Velleman K8400 Controller (derived from 3Drag Controller)
  146. else ifeq ($(HARDWARE_MOTHERBOARD),79)
  147. # 2PrintBeta BAM&DICE with STK drivers
  148. else ifeq ($(HARDWARE_MOTHERBOARD),401)
  149. # 2PrintBeta BAM&DICE Due with STK drivers
  150. else ifeq ($(HARDWARE_MOTHERBOARD),402)
  151. # MKS BASE v1.0
  152. else ifeq ($(HARDWARE_MOTHERBOARD),40)
  153. # MKS v1.5 with Allegro A4982 stepper drivers
  154. else ifeq ($(HARDWARE_MOTHERBOARD),405)
  155. # MKS BASE 1.0 with Heroic HR4982 stepper drivers
  156. else ifeq ($(HARDWARE_MOTHERBOARD),41)
  157. # MKS GEN v1.3 or 1.4
  158. else ifeq ($(HARDWARE_MOTHERBOARD),47)
  159. # MKS GEN L
  160. else ifeq ($(HARDWARE_MOTHERBOARD),53)
  161. # zrib V2.0 control board (Chinese knock off RAMPS replica)
  162. else ifeq ($(HARDWARE_MOTHERBOARD),504)
  163. # Felix 2.0+ Electronics Board (RAMPS like)
  164. else ifeq ($(HARDWARE_MOTHERBOARD),37)
  165. # Invent-A-Part RigidBoard
  166. else ifeq ($(HARDWARE_MOTHERBOARD),42)
  167. # Invent-A-Part RigidBoard V2
  168. else ifeq ($(HARDWARE_MOTHERBOARD),52)
  169. # Sainsmart 2-in-1 board
  170. else ifeq ($(HARDWARE_MOTHERBOARD),49)
  171. # Ultimaker
  172. else ifeq ($(HARDWARE_MOTHERBOARD),7)
  173. # Ultimaker (Older electronics. Pre 1.5.4. This is rare)
  174. else ifeq ($(HARDWARE_MOTHERBOARD),71)
  175. MCU ?= atmega1280
  176. # Azteeg X3
  177. else ifeq ($(HARDWARE_MOTHERBOARD),67)
  178. # Azteeg X3 Pro
  179. else ifeq ($(HARDWARE_MOTHERBOARD),68)
  180. # Ultimainboard 2.x (Uses TEMP_SENSOR 20)
  181. else ifeq ($(HARDWARE_MOTHERBOARD),72)
  182. # Rumba
  183. else ifeq ($(HARDWARE_MOTHERBOARD),80)
  184. # bq ZUM Mega 3D
  185. else ifeq ($(HARDWARE_MOTHERBOARD),503)
  186. # MakeBoard Mini v2.1.2 is a control board sold by MicroMake
  187. else ifeq ($(HARDWARE_MOTHERBOARD),431)
  188. # TriGorilla Anycubic version 1.3 based on RAMPS EFB
  189. else ifeq ($(HARDWARE_MOTHERBOARD),343)
  190. # TriGorilla Anycubic version 1.4 based on RAMPS EFB
  191. else ifeq ($(HARDWARE_MOTHERBOARD),443)
  192. # Creality: Ender-4, CR-8
  193. else ifeq ($(HARDWARE_MOTHERBOARD),243)
  194. #
  195. # Other ATmega1280, ATmega2560
  196. #
  197. # Cartesio CN Controls V11
  198. else ifeq ($(HARDWARE_MOTHERBOARD),111)
  199. # Cartesio CN Controls V12
  200. else ifeq ($(HARDWARE_MOTHERBOARD),112)
  201. # Cheaptronic v1.0
  202. else ifeq ($(HARDWARE_MOTHERBOARD),2)
  203. # Cheaptronic v2.0
  204. else ifeq ($(HARDWARE_MOTHERBOARD),21)
  205. # Makerbot Mightyboard Revision E
  206. else ifeq ($(HARDWARE_MOTHERBOARD),200)
  207. # Megatronics
  208. else ifeq ($(HARDWARE_MOTHERBOARD),70)
  209. # Megatronics v2.0
  210. else ifeq ($(HARDWARE_MOTHERBOARD),701)
  211. # Megatronics v3.0
  212. else ifeq ($(HARDWARE_MOTHERBOARD),703)
  213. # Megatronics v3.1
  214. else ifeq ($(HARDWARE_MOTHERBOARD),704)
  215. # Rambo
  216. else ifeq ($(HARDWARE_MOTHERBOARD),301)
  217. # Mini-Rambo
  218. else ifeq ($(HARDWARE_MOTHERBOARD),302)
  219. # Mini-Rambo 1.0a
  220. else ifeq ($(HARDWARE_MOTHERBOARD),303)
  221. # Einsy Rambo
  222. else ifeq ($(HARDWARE_MOTHERBOARD),304)
  223. # Einsy Retro
  224. else ifeq ($(HARDWARE_MOTHERBOARD),305)
  225. # Elefu Ra Board (v3)
  226. else ifeq ($(HARDWARE_MOTHERBOARD),21)
  227. # Leapfrog
  228. else ifeq ($(HARDWARE_MOTHERBOARD),999)
  229. # Mega controller
  230. else ifeq ($(HARDWARE_MOTHERBOARD),310)
  231. # abee Scoovo X9H
  232. else ifeq ($(HARDWARE_MOTHERBOARD),321)
  233. # Geeetech GT2560 Rev. A
  234. else ifeq ($(HARDWARE_MOTHERBOARD),74)
  235. # Geeetech GT2560 Rev. A+ (with auto level probe)
  236. else ifeq ($(HARDWARE_MOTHERBOARD),75)
  237. #
  238. # ATmega1281, ATmega2561
  239. #
  240. else ifeq ($(HARDWARE_MOTHERBOARD),702)
  241. MCU ?= atmega1281
  242. else ifeq ($(HARDWARE_MOTHERBOARD),25)
  243. MCU ?= atmega1281
  244. #
  245. # Sanguinololu and Derivatives - ATmega644P, ATmega1284P
  246. #
  247. # Sanguinololu < 1.2
  248. else ifeq ($(HARDWARE_MOTHERBOARD),6)
  249. HARDWARE_VARIANT ?= Sanguino
  250. MCU ?= atmega644p
  251. # Sanguinololu 1.2 and above
  252. else ifeq ($(HARDWARE_MOTHERBOARD),62)
  253. HARDWARE_VARIANT ?= Sanguino
  254. MCU ?= atmega644p
  255. # Melzi
  256. else ifeq ($(HARDWARE_MOTHERBOARD),63)
  257. HARDWARE_VARIANT ?= Sanguino
  258. MCU ?= atmega644p
  259. # Melzi with ATmega1284 (MaKr3d version)
  260. else ifeq ($(HARDWARE_MOTHERBOARD),66)
  261. HARDWARE_VARIANT ?= Sanguino
  262. MCU ?= atmega1284p
  263. # Melzi Creality3D board (for CR-10 etc)
  264. else ifeq ($(HARDWARE_MOTHERBOARD),89)
  265. HARDWARE_VARIANT ?= Sanguino
  266. MCU ?= atmega1284p
  267. # Melzi Malyan M150 board
  268. else ifeq ($(HARDWARE_MOTHERBOARD),92)
  269. HARDWARE_VARIANT ?= Sanguino
  270. MCU ?= atmega1284p
  271. # Tronxy X5S
  272. else ifeq ($(HARDWARE_MOTHERBOARD),505)
  273. HARDWARE_VARIANT ?= Sanguino
  274. MCU ?= atmega1284p
  275. # STB V1.1
  276. else ifeq ($(HARDWARE_MOTHERBOARD),64)
  277. HARDWARE_VARIANT ?= Sanguino
  278. MCU ?= atmega1284p
  279. # Azteeg X1
  280. else ifeq ($(HARDWARE_MOTHERBOARD),65)
  281. HARDWARE_VARIANT ?= Sanguino
  282. MCU ?= atmega1284p
  283. # Anet 1.0 (Melzi clone)
  284. else ifeq ($(HARDWARE_MOTHERBOARD),69)
  285. HARDWARE_VARIANT ?= Sanguino
  286. MCU ?= atmega1284p
  287. #
  288. # Other ATmega644P, ATmega644, ATmega1284P
  289. #
  290. # Gen3 Monolithic Electronics
  291. else ifeq ($(HARDWARE_MOTHERBOARD),22)
  292. HARDWARE_VARIANT ?= Sanguino
  293. MCU ?= atmega644p
  294. # Gen3+
  295. else ifeq ($(HARDWARE_MOTHERBOARD),9)
  296. HARDWARE_VARIANT ?= Sanguino
  297. MCU ?= atmega644p
  298. # Gen6
  299. else ifeq ($(HARDWARE_MOTHERBOARD),5)
  300. HARDWARE_VARIANT ?= Gen6
  301. MCU ?= atmega644p
  302. # Gen6 deluxe
  303. else ifeq ($(HARDWARE_MOTHERBOARD),51)
  304. HARDWARE_VARIANT ?= Gen6
  305. MCU ?= atmega644p
  306. # Gen7 custom (Alfons3 Version)
  307. else ifeq ($(HARDWARE_MOTHERBOARD),10)
  308. HARDWARE_VARIANT ?= Gen7
  309. MCU ?= atmega644
  310. F_CPU ?= 20000000
  311. # Gen7 v1.1, v1.2
  312. else ifeq ($(HARDWARE_MOTHERBOARD),11)
  313. HARDWARE_VARIANT ?= Gen7
  314. MCU ?= atmega644p
  315. F_CPU ?= 20000000
  316. # Gen7 v1.3
  317. else ifeq ($(HARDWARE_MOTHERBOARD),12)
  318. HARDWARE_VARIANT ?= Gen7
  319. MCU ?= atmega644p
  320. F_CPU ?= 20000000
  321. # Gen7 v1.4
  322. else ifeq ($(HARDWARE_MOTHERBOARD),13)
  323. HARDWARE_VARIANT ?= Gen7
  324. MCU ?= atmega1284p
  325. F_CPU ?= 20000000
  326. # Alpha OMCA board
  327. else ifeq ($(HARDWARE_MOTHERBOARD),90)
  328. HARDWARE_VARIANT ?= SanguinoA
  329. MCU ?= atmega644
  330. # Final OMCA board
  331. else ifeq ($(HARDWARE_MOTHERBOARD),91)
  332. HARDWARE_VARIANT ?= Sanguino
  333. MCU ?= atmega644p
  334. # Sethi 3D_1
  335. else ifeq ($(HARDWARE_MOTHERBOARD),20)
  336. HARDWARE_VARIANT ?= Sanguino
  337. MCU ?= atmega644p
  338. #
  339. # Teensyduino - AT90USB1286, AT90USB1286P
  340. #
  341. # Teensylu
  342. else ifeq ($(HARDWARE_MOTHERBOARD),8)
  343. HARDWARE_VARIANT ?= Teensy
  344. MCU ?= at90usb1286
  345. # Printrboard (AT90USB1286)
  346. else ifeq ($(HARDWARE_MOTHERBOARD),81)
  347. HARDWARE_VARIANT ?= Teensy
  348. MCU ?= at90usb1286
  349. # Printrboard Revision F (AT90USB1286)
  350. else ifeq ($(HARDWARE_MOTHERBOARD),811)
  351. HARDWARE_VARIANT ?= Teensy
  352. MCU ?= at90usb1286
  353. # Brainwave (AT90USB646)
  354. else ifeq ($(HARDWARE_MOTHERBOARD),82)
  355. HARDWARE_VARIANT ?= Teensy
  356. MCU ?= at90usb646
  357. # Brainwave Pro (AT90USB1286)
  358. else ifeq ($(HARDWARE_MOTHERBOARD),83)
  359. HARDWARE_VARIANT ?= Teensy
  360. MCU ?= at90usb1286
  361. # SAV Mk-I (AT90USB1286)
  362. else ifeq ($(HARDWARE_MOTHERBOARD),84)
  363. HARDWARE_VARIANT ?= Teensy
  364. MCU ?= at90usb1286
  365. # Teensy++2.0 (AT90USB1286)
  366. else ifeq ($(HARDWARE_MOTHERBOARD),85)
  367. HARDWARE_VARIANT ?= Teensy
  368. MCU ?= at90usb1286
  369. # 5DPrint D8 Driver Board
  370. else ifeq ($(HARDWARE_MOTHERBOARD),88)
  371. HARDWARE_VARIANT ?= Teensy
  372. MCU ?= at90usb1286
  373. endif
  374. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  375. # if you are setting this to something other than 16MHz
  376. # Set to 16Mhz if not yet set.
  377. F_CPU ?= 16000000
  378. # Set to arduino, ATmega2560 if not yet set.
  379. HARDWARE_VARIANT ?= arduino
  380. MCU ?= atmega2560
  381. # Arduino contained the main source code for the Arduino
  382. # Libraries, the "hardware variant" are for boards
  383. # that derives from that, and their source are present in
  384. # the main Marlin source directory
  385. TARGET = $(notdir $(CURDIR))
  386. # VPATH tells make to look into these directory for source files,
  387. # there is no need to specify explicit pathnames as long as the
  388. # directory is added here
  389. # The Makefile for previous versions of Marlin used VPATH for all
  390. # source files, but for Marlin 2.0, we use VPATH only for arduino
  391. # library files.
  392. VPATH = .
  393. VPATH += $(BUILD_DIR)
  394. VPATH += $(HARDWARE_SRC)
  395. # U8glib
  396. VPATH += $(ARDUINO_USER_DIR)/libraries/U8glib
  397. VPATH += $(ARDUINO_USER_DIR)/libraries/U8glib/clib
  398. ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
  399. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/LiquidCrystal/src
  400. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/SPI
  401. endif
  402. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
  403. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  404. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
  405. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
  406. ifeq ($(LIQUID_TWI2), 1)
  407. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  408. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  409. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
  410. endif
  411. ifeq ($(WIRE), 1)
  412. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  413. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  414. endif
  415. ifeq ($(NEOPIXEL), 1)
  416. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
  417. endif
  418. ifeq ($(U8GLIB), 1)
  419. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib
  420. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/clib
  421. endif
  422. ifeq ($(TMC2630), 1)
  423. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper/src
  424. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper/src/source
  425. endif
  426. ifeq ($(HARDWARE_VARIANT), arduino)
  427. HARDWARE_SUB_VARIANT ?= mega
  428. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
  429. else
  430. ifeq ($(HARDWARE_VARIANT), Sanguino)
  431. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/variants/sanguino
  432. else
  433. HARDWARE_SUB_VARIANT ?= standard
  434. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
  435. endif
  436. endif
  437. LIB_SRC = wiring.c \
  438. wiring_analog.c wiring_digital.c \
  439. wiring_pulse.c \
  440. wiring_shift.c WInterrupts.c hooks.c
  441. ifeq ($(HARDWARE_VARIANT), Teensy)
  442. LIB_SRC = wiring.c
  443. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
  444. endif
  445. LIB_CXXSRC = WMath.cpp WString.cpp Print.cpp SPI.cpp Tone.cpp
  446. ifeq ($(NEOPIXEL), 1)
  447. LIB_CXXSRC += Adafruit_NeoPixel.cpp
  448. endif
  449. ifeq ($(LIQUID_TWI2), 0)
  450. LIB_CXXSRC += LiquidCrystal.cpp
  451. else
  452. LIB_SRC += twi.c
  453. LIB_CXXSRC += Wire.cpp LiquidTWI2.cpp
  454. endif
  455. ifeq ($(WIRE), 1)
  456. LIB_SRC += twi.c
  457. LIB_CXXSRC += Wire.cpp
  458. endif
  459. ifeq ($(U8GLIB), 1)
  460. LIB_CXXSRC += U8glib.cpp
  461. LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c u8g_font_data.c
  462. endif
  463. ifeq ($(TMC2630), 1)
  464. LIB_CXXSRC += TMC2130Stepper.cpp TMC2130Stepper_COOLCONF.cpp TMC2130Stepper_DRV_STATUS.cpp TMC2130Stepper_IHOLD_IRUN.cpp TMC2130Stepper_CHOPCONF.cpp TMC2130Stepper_GCONF.cpp TMC2130Stepper_PWMCONF.cpp SW_SPI.cpp
  465. endif
  466. ifeq ($(RELOC_WORKAROUND), 1)
  467. LD_PREFIX=-nodefaultlibs
  468. LD_SUFFIX=-lm -lgcc -lc -lgcc
  469. endif
  470. #Check for Arduino 1.0.0 or higher and use the correct source files for that version
  471. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  472. LIB_CXXSRC += main.cpp
  473. else
  474. LIB_SRC += pins_arduino.c main.c
  475. endif
  476. FORMAT = ihex
  477. # Name of this Makefile (used for "make depend").
  478. MAKEFILE = Makefile
  479. # Debugging format.
  480. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  481. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  482. DEBUG = stabs
  483. OPT = s
  484. DEFINES ?=
  485. # Program settings
  486. CC = $(AVR_TOOLS_PATH)avr-gcc
  487. CXX = $(AVR_TOOLS_PATH)avr-g++
  488. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  489. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  490. AR = $(AVR_TOOLS_PATH)avr-ar
  491. SIZE = $(AVR_TOOLS_PATH)avr-size
  492. NM = $(AVR_TOOLS_PATH)avr-nm
  493. AVRDUDE = avrdude
  494. REMOVE = rm -f
  495. MV = mv -f
  496. # Place -D or -U options here
  497. CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
  498. CXXDEFS = $(CDEFS)
  499. ifeq ($(HARDWARE_VARIANT), Teensy)
  500. CDEFS += -DUSB_SERIAL
  501. LIB_SRC += usb.c pins_teensy.c
  502. LIB_CXXSRC += usb_api.cpp
  503. endif
  504. # Add all the source directories as include directories too
  505. CINCS = ${addprefix -I ,${VPATH}}
  506. CXXINCS = ${addprefix -I ,${VPATH}}
  507. # Compiler flag to set the C/CPP Standard level.
  508. CSTANDARD = -std=gnu99
  509. CXXSTANDARD = -std=gnu++11
  510. CDEBUG = -g$(DEBUG)
  511. CWARN = -Wall -Wstrict-prototypes
  512. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  513. -fshort-enums -w -ffunction-sections -fdata-sections \
  514. -flto \
  515. -DARDUINO=$(ARDUINO_VERSION)
  516. ifneq ($(HARDWARE_MOTHERBOARD),)
  517. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  518. endif
  519. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  520. CEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics
  521. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  522. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) $(CXXSTANDARD)
  523. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  524. LDFLAGS = -lm
  525. # Programming support using avrdude. Settings and variables.
  526. AVRDUDE_PORT = $(UPLOAD_PORT)
  527. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  528. ifeq ($(shell uname -s), Linux)
  529. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  530. else
  531. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
  532. endif
  533. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  534. -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  535. -b$(UPLOAD_RATE)
  536. # Since Marlin 2.0, the source files may be distributed into several
  537. # different directories, so it is necessary to find them recursively
  538. SRC = $(shell find src -name '*.c' -type f)
  539. CXXSRC = $(shell find src -name '*.cpp' -type f)
  540. # Define all object files.
  541. OBJ = ${patsubst %.c, $(BUILD_DIR)/arduino/%.o, ${LIB_SRC}}
  542. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/arduino/%.o, ${LIB_CXXSRC}}
  543. OBJ += ${patsubst %.S, $(BUILD_DIR)/arduino/%.o, ${LIB_ASRC}}
  544. OBJ += ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  545. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  546. # Define all listing files.
  547. LST = $(LIB_ASRC:.S=.lst) $(LIB_CXXSRC:.cpp=.lst) $(LIB_SRC:.c=.lst)
  548. # Combine all necessary flags and optional flags.
  549. # Add target processor to flags.
  550. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  551. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  552. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  553. # set V=1 (eg, "make V=1") to print the full commands etc.
  554. ifneq ($V,1)
  555. Pecho=@echo
  556. P=@
  557. else
  558. Pecho=@:
  559. P=
  560. endif
  561. # Create required build hierarchy if it does not exist
  562. $(shell mkdir -p $(dir $(OBJ)))
  563. # Default target.
  564. all: sizeafter
  565. build: elf hex
  566. elf: $(BUILD_DIR)/$(TARGET).elf
  567. hex: $(BUILD_DIR)/$(TARGET).hex
  568. eep: $(BUILD_DIR)/$(TARGET).eep
  569. lss: $(BUILD_DIR)/$(TARGET).lss
  570. sym: $(BUILD_DIR)/$(TARGET).sym
  571. # Program the device.
  572. # Do not try to reset an Arduino if it's not one
  573. upload: $(BUILD_DIR)/$(TARGET).hex
  574. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  575. stty hup < $(UPLOAD_PORT); true
  576. endif
  577. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  578. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  579. stty -hup < $(UPLOAD_PORT); true
  580. endif
  581. # Display size of file.
  582. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  583. ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
  584. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  585. sizebefore:
  586. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  587. sizeafter: build
  588. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  589. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  590. COFFCONVERT=$(OBJCOPY) --debugging \
  591. --change-section-address .data-0x800000 \
  592. --change-section-address .bss-0x800000 \
  593. --change-section-address .noinit-0x800000 \
  594. --change-section-address .eeprom-0x810000
  595. coff: $(BUILD_DIR)/$(TARGET).elf
  596. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  597. extcoff: $(TARGET).elf
  598. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  599. .SUFFIXES: .elf .hex .eep .lss .sym
  600. .PRECIOUS: .o
  601. .elf.hex:
  602. $(Pecho) " COPY $@"
  603. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  604. .elf.eep:
  605. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  606. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  607. # Create extended listing file from ELF output file.
  608. .elf.lss:
  609. $(OBJDUMP) -h -S $< > $@
  610. # Create a symbol table from ELF output file.
  611. .elf.sym:
  612. $(NM) -n $< > $@
  613. # Link: create ELF output file from library.
  614. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  615. $(Pecho) " CXX $@"
  616. $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -Wl,--gc-sections,--relax -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
  617. # Object files that were found in "src" will be stored in $(BUILD_DIR)
  618. # in directories that mirror the structure of "src"
  619. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  620. $(Pecho) " CC $<"
  621. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  622. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  623. $(Pecho) " CXX $<"
  624. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  625. # Object files for Arduino libs will be created in $(BUILD_DIR)/arduino
  626. $(BUILD_DIR)/arduino/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  627. $(Pecho) " CC $<"
  628. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  629. $(BUILD_DIR)/arduino/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  630. $(Pecho) " CXX $<"
  631. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  632. # Target: clean project.
  633. clean:
  634. $(Pecho) " RMDIR $(BUILD_DIR)/"
  635. $P rm -rf $(BUILD_DIR)
  636. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  637. # Automaticaly include the dependency files created by gcc
  638. -include ${patsubst %.o, %.d, ${OBJ}}