My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Makefile 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  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 macOS, 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. Set
  26. # "PROG_MCU" as the AVR part name corresponding to "MCU". You can use the
  27. # following command to get a list of correspondences: `avrdude -c alf -p x`
  28. # Older boards are atmega8 based, newer ones like Arduino Mini, Bluetooth
  29. # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
  30. # change F_CPU to 8000000. If you are using Gen7 electronics, you
  31. # probably need to use 20000000. Either way, you must regenerate
  32. # the speed lookup table with create_speed_lookuptable.py.
  33. #
  34. # 4. Type "make" and press enter to compile/verify your program.
  35. #
  36. # 5. Type "make upload", reset your Arduino board, and press enter to
  37. # upload your program to the Arduino board.
  38. #
  39. # Note that all settings at the top of this file can be overridden from
  40. # the command line with, for example, "make HARDWARE_MOTHERBOARD=71"
  41. #
  42. # To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use...
  43. #
  44. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  45. # HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino
  46. #
  47. # To compile and upload simply add "upload" to the end of the line...
  48. #
  49. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  50. # HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino upload
  51. #
  52. # If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or
  53. # start upload manually (using stk500) like so:
  54. #
  55. # avrdude -C /root/arduino/hardware/tools/avr/etc/avrdude.conf -v -p m2560 -c stk500 \
  56. # -U flash:w:applet/Marlin.hex:i -P /dev/ttyUSB0
  57. #
  58. # Or, try disconnecting USB to power down and then reconnecting before running avrdude.
  59. #
  60. # This defines the board to compile for (see boards.h for your board's ID)
  61. HARDWARE_MOTHERBOARD ?= 1020
  62. ifeq ($(OS),Windows_NT)
  63. # Windows
  64. ARDUINO_INSTALL_DIR ?= ${HOME}/Arduino
  65. ARDUINO_USER_DIR ?= ${HOME}/Arduino
  66. else
  67. UNAME_S := $(shell uname -s)
  68. ifeq ($(UNAME_S),Linux)
  69. # Linux
  70. ARDUINO_INSTALL_DIR ?= /usr/share/arduino
  71. ARDUINO_USER_DIR ?= ${HOME}/Arduino
  72. endif
  73. ifeq ($(UNAME_S),Darwin)
  74. # Darwin (macOS)
  75. ARDUINO_INSTALL_DIR ?= /Applications/Arduino.app/Contents/Java
  76. ARDUINO_USER_DIR ?= ${HOME}/Documents/Arduino
  77. AVR_TOOLS_PATH ?= /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/
  78. endif
  79. endif
  80. # Arduino source install directory, and version number
  81. # On most linuxes this will be /usr/share/arduino
  82. ARDUINO_INSTALL_DIR ?= ${HOME}/Arduino
  83. ARDUINO_VERSION ?= 106
  84. # The installed Libraries are in the User folder
  85. ARDUINO_USER_DIR ?= ${HOME}/Arduino
  86. # You can optionally set a path to the avr-gcc tools.
  87. # Requires a trailing slash. For example, /usr/local/avr-gcc/bin/
  88. AVR_TOOLS_PATH ?=
  89. # Programmer configuration
  90. UPLOAD_RATE ?= 57600
  91. AVRDUDE_PROGRAMMER ?= arduino
  92. # On most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
  93. UPLOAD_PORT ?= /dev/ttyUSB0
  94. # Directory used to build files in, contains all the build files, from object
  95. # files to the final hex file on linux it is best to put an absolute path
  96. # like /home/username/tmp .
  97. BUILD_DIR ?= applet
  98. # This defines whether Liquid_TWI2 support will be built
  99. LIQUID_TWI2 ?= 0
  100. # This defines if Wire is needed
  101. WIRE ?= 0
  102. # This defines if Tone is needed (i.e SPEAKER is defined in Configuration.h)
  103. # Disabling this (and SPEAKER) saves approximatively 350 bytes of memory.
  104. TONE ?= 1
  105. # This defines if U8GLIB is needed (may require RELOC_WORKAROUND)
  106. U8GLIB ?= 0
  107. # This defines whether to include the Trinamic TMCStepper library
  108. TMC ?= 0
  109. # This defines whether to include the AdaFruit NeoPixel library
  110. NEOPIXEL ?= 0
  111. ############
  112. # Try to automatically determine whether RELOC_WORKAROUND is needed based
  113. # on GCC versions:
  114. # https://www.avrfreaks.net/comment/1789106#comment-1789106
  115. CC_MAJ:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC__ | cut -f3 -d\ )
  116. CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ )
  117. CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ )
  118. CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) )))
  119. ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1)
  120. @echo This version of GCC is likely broken. Enabling relocation workaround.
  121. RELOC_WORKAROUND = 1
  122. endif
  123. ############################################################################
  124. # Below here nothing should be changed...
  125. # Here the Arduino variant is selected by the board type
  126. # HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
  127. # MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...
  128. ifeq ($(HARDWARE_MOTHERBOARD),0)
  129. # No motherboard selected
  130. #
  131. # RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560
  132. #
  133. # MEGA/RAMPS up to 1.2
  134. else ifeq ($(HARDWARE_MOTHERBOARD),1000)
  135. # RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
  136. else ifeq ($(HARDWARE_MOTHERBOARD),1010)
  137. # RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
  138. else ifeq ($(HARDWARE_MOTHERBOARD),1011)
  139. # RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
  140. else ifeq ($(HARDWARE_MOTHERBOARD),1012)
  141. # RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
  142. else ifeq ($(HARDWARE_MOTHERBOARD),1013)
  143. # RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
  144. else ifeq ($(HARDWARE_MOTHERBOARD),1014)
  145. # RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
  146. else ifeq ($(HARDWARE_MOTHERBOARD),1020)
  147. # RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
  148. else ifeq ($(HARDWARE_MOTHERBOARD),1021)
  149. # RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
  150. else ifeq ($(HARDWARE_MOTHERBOARD),1022)
  151. # RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
  152. else ifeq ($(HARDWARE_MOTHERBOARD),1023)
  153. # RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
  154. else ifeq ($(HARDWARE_MOTHERBOARD),1024)
  155. # RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
  156. else ifeq ($(HARDWARE_MOTHERBOARD),1030)
  157. # RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
  158. else ifeq ($(HARDWARE_MOTHERBOARD),1031)
  159. # RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
  160. else ifeq ($(HARDWARE_MOTHERBOARD),1032)
  161. # RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
  162. else ifeq ($(HARDWARE_MOTHERBOARD),1033)
  163. # RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
  164. else ifeq ($(HARDWARE_MOTHERBOARD),1034)
  165. #
  166. # RAMPS Derivatives - ATmega1280, ATmega2560
  167. #
  168. # 3Drag Controller
  169. else ifeq ($(HARDWARE_MOTHERBOARD),1100)
  170. # Velleman K8200 Controller (derived from 3Drag Controller)
  171. else ifeq ($(HARDWARE_MOTHERBOARD),1101)
  172. # Velleman K8400 Controller (derived from 3Drag Controller)
  173. else ifeq ($(HARDWARE_MOTHERBOARD),1102)
  174. # Velleman K8600 Controller (Vertex Nano)
  175. else ifeq ($(HARDWARE_MOTHERBOARD),1103)
  176. # Velleman K8800 Controller (Vertex Delta)
  177. else ifeq ($(HARDWARE_MOTHERBOARD),1104)
  178. # 2PrintBeta BAM&DICE with STK drivers
  179. else ifeq ($(HARDWARE_MOTHERBOARD),1105)
  180. # 2PrintBeta BAM&DICE Due with STK drivers
  181. else ifeq ($(HARDWARE_MOTHERBOARD),1106)
  182. # MKS BASE v1.0
  183. else ifeq ($(HARDWARE_MOTHERBOARD),1107)
  184. # MKS v1.4 with A4982 stepper drivers
  185. else ifeq ($(HARDWARE_MOTHERBOARD),1108)
  186. # MKS v1.5 with Allegro A4982 stepper drivers
  187. else ifeq ($(HARDWARE_MOTHERBOARD),1109)
  188. # MKS v1.6 with Allegro A4982 stepper drivers
  189. else ifeq ($(HARDWARE_MOTHERBOARD),1110)
  190. # MKS BASE 1.0 with Heroic HR4982 stepper drivers
  191. else ifeq ($(HARDWARE_MOTHERBOARD),1111)
  192. # MKS GEN v1.3 or 1.4
  193. else ifeq ($(HARDWARE_MOTHERBOARD),1112)
  194. # MKS GEN L
  195. else ifeq ($(HARDWARE_MOTHERBOARD),1113)
  196. # zrib V2.0 control board (Chinese RAMPS replica)
  197. else ifeq ($(HARDWARE_MOTHERBOARD),1114)
  198. # BigTreeTech or BIQU KFB2.0
  199. else ifeq ($(HARDWARE_MOTHERBOARD),1115)
  200. # Felix 2.0+ Electronics Board (RAMPS like)
  201. else ifeq ($(HARDWARE_MOTHERBOARD),1116)
  202. # Invent-A-Part RigidBoard
  203. else ifeq ($(HARDWARE_MOTHERBOARD),1117)
  204. # Invent-A-Part RigidBoard V2
  205. else ifeq ($(HARDWARE_MOTHERBOARD),1118)
  206. # Sainsmart 2-in-1 board
  207. else ifeq ($(HARDWARE_MOTHERBOARD),1119)
  208. # Ultimaker
  209. else ifeq ($(HARDWARE_MOTHERBOARD),1120)
  210. # Ultimaker (Older electronics. Pre 1.5.4. This is rare)
  211. else ifeq ($(HARDWARE_MOTHERBOARD),1121)
  212. MCU ?= atmega1280
  213. PROG_MCU ?= m1280
  214. # Azteeg X3
  215. else ifeq ($(HARDWARE_MOTHERBOARD),1122)
  216. # Azteeg X3 Pro
  217. else ifeq ($(HARDWARE_MOTHERBOARD),1123)
  218. # Ultimainboard 2.x (Uses TEMP_SENSOR 20)
  219. else ifeq ($(HARDWARE_MOTHERBOARD),1124)
  220. # Rumba
  221. else ifeq ($(HARDWARE_MOTHERBOARD),1125)
  222. # Raise3D Rumba
  223. else ifeq ($(HARDWARE_MOTHERBOARD),1126)
  224. # Rapide Lite RL200 Rumba
  225. else ifeq ($(HARDWARE_MOTHERBOARD),1127)
  226. # Formbot T-Rex 2 Plus
  227. else ifeq ($(HARDWARE_MOTHERBOARD),1128)
  228. # Formbot T-Rex 3
  229. else ifeq ($(HARDWARE_MOTHERBOARD),1129)
  230. # Formbot Raptor
  231. else ifeq ($(HARDWARE_MOTHERBOARD),1130)
  232. # Formbot Raptor 2
  233. else ifeq ($(HARDWARE_MOTHERBOARD),1131)
  234. # bq ZUM Mega 3D
  235. else ifeq ($(HARDWARE_MOTHERBOARD),1132)
  236. # MakeBoard Mini v2.1.2 is a control board sold by MicroMake
  237. else ifeq ($(HARDWARE_MOTHERBOARD),1133)
  238. # TriGorilla Anycubic version 1.3 based on RAMPS EFB
  239. else ifeq ($(HARDWARE_MOTHERBOARD),1134)
  240. # TriGorilla Anycubic version 1.4 based on RAMPS EFB
  241. else ifeq ($(HARDWARE_MOTHERBOARD),1135)
  242. # TriGorilla Anycubic version 1.4 Rev 1.1
  243. else ifeq ($(HARDWARE_MOTHERBOARD),1136)
  244. # Creality: Ender-4, CR-8
  245. else ifeq ($(HARDWARE_MOTHERBOARD),1137)
  246. # Creality: CR10S, CR20, CR-X
  247. else ifeq ($(HARDWARE_MOTHERBOARD),1138)
  248. # Dagoma F5
  249. else ifeq ($(HARDWARE_MOTHERBOARD),1139)
  250. # FYSETC F6 1.3
  251. else ifeq ($(HARDWARE_MOTHERBOARD),1140)
  252. # FYSETC F6 1.5
  253. else ifeq ($(HARDWARE_MOTHERBOARD),1141)
  254. # Duplicator i3 Plus
  255. else ifeq ($(HARDWARE_MOTHERBOARD),1142)
  256. # VORON
  257. else ifeq ($(HARDWARE_MOTHERBOARD),1143)
  258. # TRONXY V3 1.0
  259. else ifeq ($(HARDWARE_MOTHERBOARD),1144)
  260. # Z-Bolt X Series
  261. else ifeq ($(HARDWARE_MOTHERBOARD),1145)
  262. # TT OSCAR
  263. else ifeq ($(HARDWARE_MOTHERBOARD),1146)
  264. # Overlord/Overlord Pro
  265. else ifeq ($(HARDWARE_MOTHERBOARD),1147)
  266. # ADIMLab Gantry v1
  267. else ifeq ($(HARDWARE_MOTHERBOARD),1148)
  268. # ADIMLab Gantry v2
  269. else ifeq ($(HARDWARE_MOTHERBOARD),1149)
  270. # BIQU Tango V1
  271. else ifeq ($(HARDWARE_MOTHERBOARD),1150)
  272. # MKS GEN L V2
  273. else ifeq ($(HARDWARE_MOTHERBOARD),1151)
  274. # MKS GEN L V2.1
  275. else ifeq ($(HARDWARE_MOTHERBOARD),1152)
  276. # Copymaster 3D
  277. else ifeq ($(HARDWARE_MOTHERBOARD),1153)
  278. # Ortur 4
  279. else ifeq ($(HARDWARE_MOTHERBOARD),1154)
  280. # Tenlog D3 Hero
  281. else ifeq ($(HARDWARE_MOTHERBOARD),1155)
  282. #
  283. # RAMBo and derivatives
  284. #
  285. # Rambo
  286. else ifeq ($(HARDWARE_MOTHERBOARD),1200)
  287. # Mini-Rambo
  288. else ifeq ($(HARDWARE_MOTHERBOARD),1201)
  289. # Mini-Rambo 1.0a
  290. else ifeq ($(HARDWARE_MOTHERBOARD),1202)
  291. # Einsy Rambo
  292. else ifeq ($(HARDWARE_MOTHERBOARD),1203)
  293. # Einsy Retro
  294. else ifeq ($(HARDWARE_MOTHERBOARD),1204)
  295. # abee Scoovo X9H
  296. else ifeq ($(HARDWARE_MOTHERBOARD),1205)
  297. # Rambo ThinkerV2
  298. else ifeq ($(HARDWARE_MOTHERBOARD),1206)
  299. #
  300. # Other ATmega1280, ATmega2560
  301. #
  302. # Cartesio CN Controls V11
  303. else ifeq ($(HARDWARE_MOTHERBOARD),1300)
  304. # Cartesio CN Controls V12
  305. else ifeq ($(HARDWARE_MOTHERBOARD),1301)
  306. # Cartesio CN Controls V15
  307. else ifeq ($(HARDWARE_MOTHERBOARD),1302)
  308. # Cheaptronic v1.0
  309. else ifeq ($(HARDWARE_MOTHERBOARD),1303)
  310. # Cheaptronic v2.0
  311. else ifeq ($(HARDWARE_MOTHERBOARD),1304)
  312. # Makerbot Mightyboard Revision E
  313. else ifeq ($(HARDWARE_MOTHERBOARD),1305)
  314. # Megatronics
  315. else ifeq ($(HARDWARE_MOTHERBOARD),1306)
  316. # Megatronics v2.0
  317. else ifeq ($(HARDWARE_MOTHERBOARD),1307)
  318. # Megatronics v3.0
  319. else ifeq ($(HARDWARE_MOTHERBOARD),1308)
  320. # Megatronics v3.1
  321. else ifeq ($(HARDWARE_MOTHERBOARD),1309)
  322. # Megatronics v3.2
  323. else ifeq ($(HARDWARE_MOTHERBOARD),1310)
  324. # Elefu Ra Board (v3)
  325. else ifeq ($(HARDWARE_MOTHERBOARD),1311)
  326. # Leapfrog
  327. else ifeq ($(HARDWARE_MOTHERBOARD),1312)
  328. # Mega controller
  329. else ifeq ($(HARDWARE_MOTHERBOARD),1313)
  330. # Geeetech GT2560 Rev B for Mecreator2
  331. else ifeq ($(HARDWARE_MOTHERBOARD),1314)
  332. # Geeetech GT2560 Rev. A
  333. else ifeq ($(HARDWARE_MOTHERBOARD),1315)
  334. # Geeetech GT2560 Rev. A+ (with auto level probe)
  335. else ifeq ($(HARDWARE_MOTHERBOARD),1316)
  336. # Geeetech GT2560 Rev B for A10(M/D)
  337. else ifeq ($(HARDWARE_MOTHERBOARD),1317)
  338. # Geeetech GT2560 Rev B for A20(M/D)
  339. else ifeq ($(HARDWARE_MOTHERBOARD),1318)
  340. # Einstart retrofit
  341. else ifeq ($(HARDWARE_MOTHERBOARD),1319)
  342. # Wanhao 0ne+ i3 Mini
  343. else ifeq ($(HARDWARE_MOTHERBOARD),1320)
  344. #
  345. # ATmega1281, ATmega2561
  346. #
  347. # Minitronics v1.0/1.1
  348. else ifeq ($(HARDWARE_MOTHERBOARD),1400)
  349. MCU ?= atmega1281
  350. PROG_MCU ?= m1281
  351. # Silvergate v1.0
  352. else ifeq ($(HARDWARE_MOTHERBOARD),1401)
  353. MCU ?= atmega1281
  354. PROG_MCU ?= m1281
  355. #
  356. # Sanguinololu and Derivatives - ATmega644P, ATmega1284P
  357. #
  358. # Sanguinololu < 1.2
  359. else ifeq ($(HARDWARE_MOTHERBOARD),1500)
  360. HARDWARE_VARIANT ?= Sanguino
  361. MCU ?= atmega644p
  362. PROG_MCU ?= m644p
  363. # Sanguinololu 1.2 and above
  364. else ifeq ($(HARDWARE_MOTHERBOARD),1501)
  365. HARDWARE_VARIANT ?= Sanguino
  366. MCU ?= atmega644p
  367. PROG_MCU ?= m644p
  368. # Melzi
  369. else ifeq ($(HARDWARE_MOTHERBOARD),1502)
  370. HARDWARE_VARIANT ?= Sanguino
  371. MCU ?= atmega644p
  372. PROG_MCU ?= m644p
  373. # Melzi V2.0
  374. else ifeq ($(HARDWARE_MOTHERBOARD),1503)
  375. HARDWARE_VARIANT ?= Sanguino
  376. MCU ?= atmega1284p
  377. PROG_MCU ?= m1284p
  378. # Melzi with ATmega1284 (MaKr3d version)
  379. else ifeq ($(HARDWARE_MOTHERBOARD),1504)
  380. HARDWARE_VARIANT ?= Sanguino
  381. MCU ?= atmega1284p
  382. PROG_MCU ?= m1284p
  383. # Melzi Creality3D board (for CR-10 etc)
  384. else ifeq ($(HARDWARE_MOTHERBOARD),1505)
  385. HARDWARE_VARIANT ?= Sanguino
  386. MCU ?= atmega1284p
  387. PROG_MCU ?= m1284p
  388. # Melzi Malyan M150 board
  389. else ifeq ($(HARDWARE_MOTHERBOARD),1506)
  390. HARDWARE_VARIANT ?= Sanguino
  391. MCU ?= atmega1284p
  392. PROG_MCU ?= m1284p
  393. # Tronxy X5S
  394. else ifeq ($(HARDWARE_MOTHERBOARD),1507)
  395. HARDWARE_VARIANT ?= Sanguino
  396. MCU ?= atmega1284p
  397. PROG_MCU ?= m1284p
  398. # STB V1.1
  399. else ifeq ($(HARDWARE_MOTHERBOARD),1508)
  400. HARDWARE_VARIANT ?= Sanguino
  401. MCU ?= atmega1284p
  402. PROG_MCU ?= m1284p
  403. # Azteeg X1
  404. else ifeq ($(HARDWARE_MOTHERBOARD),1509)
  405. HARDWARE_VARIANT ?= Sanguino
  406. MCU ?= atmega1284p
  407. PROG_MCU ?= m1284p
  408. # Anet 1.0 (Melzi clone)
  409. else ifeq ($(HARDWARE_MOTHERBOARD),1510)
  410. HARDWARE_VARIANT ?= Sanguino
  411. MCU ?= atmega1284p
  412. PROG_MCU ?= m1284p
  413. #
  414. # Other ATmega644P, ATmega644, ATmega1284P
  415. #
  416. # Gen3 Monolithic Electronics
  417. else ifeq ($(HARDWARE_MOTHERBOARD),1600)
  418. HARDWARE_VARIANT ?= Sanguino
  419. MCU ?= atmega644p
  420. PROG_MCU ?= m644p
  421. # Gen3+
  422. else ifeq ($(HARDWARE_MOTHERBOARD),1601)
  423. HARDWARE_VARIANT ?= Sanguino
  424. MCU ?= atmega644p
  425. PROG_MCU ?= m644p
  426. # Gen6
  427. else ifeq ($(HARDWARE_MOTHERBOARD),1602)
  428. HARDWARE_VARIANT ?= Gen6
  429. MCU ?= atmega644p
  430. PROG_MCU ?= m644p
  431. # Gen6 deluxe
  432. else ifeq ($(HARDWARE_MOTHERBOARD),1603)
  433. HARDWARE_VARIANT ?= Gen6
  434. MCU ?= atmega644p
  435. PROG_MCU ?= m644p
  436. # Gen7 custom (Alfons3 Version)
  437. else ifeq ($(HARDWARE_MOTHERBOARD),1604)
  438. HARDWARE_VARIANT ?= Gen7
  439. MCU ?= atmega644
  440. PROG_MCU ?= m644
  441. F_CPU ?= 20000000
  442. # Gen7 v1.1, v1.2
  443. else ifeq ($(HARDWARE_MOTHERBOARD),1605)
  444. HARDWARE_VARIANT ?= Gen7
  445. MCU ?= atmega644p
  446. PROG_MCU ?= m644p
  447. F_CPU ?= 20000000
  448. # Gen7 v1.3
  449. else ifeq ($(HARDWARE_MOTHERBOARD),1606)
  450. HARDWARE_VARIANT ?= Gen7
  451. MCU ?= atmega644p
  452. PROG_MCU ?= m644p
  453. F_CPU ?= 20000000
  454. # Gen7 v1.4
  455. else ifeq ($(HARDWARE_MOTHERBOARD),1607)
  456. HARDWARE_VARIANT ?= Gen7
  457. MCU ?= atmega1284p
  458. PROG_MCU ?= m1284p
  459. F_CPU ?= 20000000
  460. # Alpha OMCA board
  461. else ifeq ($(HARDWARE_MOTHERBOARD),1608)
  462. HARDWARE_VARIANT ?= SanguinoA
  463. MCU ?= atmega644
  464. PROG_MCU ?= m644
  465. # Final OMCA board
  466. else ifeq ($(HARDWARE_MOTHERBOARD),1609)
  467. HARDWARE_VARIANT ?= Sanguino
  468. MCU ?= atmega644p
  469. PROG_MCU ?= m644p
  470. # Sethi 3D_1
  471. else ifeq ($(HARDWARE_MOTHERBOARD),1610)
  472. HARDWARE_VARIANT ?= Sanguino
  473. MCU ?= atmega644p
  474. PROG_MCU ?= m644p
  475. #
  476. # Teensyduino - AT90USB1286, AT90USB1286P
  477. #
  478. # Teensylu
  479. else ifeq ($(HARDWARE_MOTHERBOARD),1700)
  480. HARDWARE_VARIANT ?= Teensy
  481. MCU ?= at90usb1286
  482. PROG_MCU ?= usb1286
  483. # Printrboard (AT90USB1286)
  484. else ifeq ($(HARDWARE_MOTHERBOARD),1701)
  485. HARDWARE_VARIANT ?= Teensy
  486. MCU ?= at90usb1286
  487. PROG_MCU ?= usb1286
  488. # Printrboard Revision F (AT90USB1286)
  489. else ifeq ($(HARDWARE_MOTHERBOARD),1702)
  490. HARDWARE_VARIANT ?= Teensy
  491. MCU ?= at90usb1286
  492. PROG_MCU ?= usb1286
  493. # Brainwave (AT90USB646)
  494. else ifeq ($(HARDWARE_MOTHERBOARD),1703)
  495. HARDWARE_VARIANT ?= Teensy
  496. MCU ?= at90usb646
  497. PROG_MCU ?= usb646
  498. # Brainwave Pro (AT90USB1286)
  499. else ifeq ($(HARDWARE_MOTHERBOARD),1704)
  500. HARDWARE_VARIANT ?= Teensy
  501. MCU ?= at90usb1286
  502. PROG_MCU ?= usb1286
  503. # SAV Mk-I (AT90USB1286)
  504. else ifeq ($(HARDWARE_MOTHERBOARD),1705)
  505. HARDWARE_VARIANT ?= Teensy
  506. MCU ?= at90usb1286
  507. PROG_MCU ?= usb1286
  508. # Teensy++2.0 (AT90USB1286)
  509. else ifeq ($(HARDWARE_MOTHERBOARD),1706)
  510. HARDWARE_VARIANT ?= Teensy
  511. MCU ?= at90usb1286
  512. PROG_MCU ?= usb1286
  513. # 5DPrint D8 Driver Board
  514. else ifeq ($(HARDWARE_MOTHERBOARD),1707)
  515. HARDWARE_VARIANT ?= Teensy
  516. MCU ?= at90usb1286
  517. PROG_MCU ?= usb1286
  518. # UltiMachine Archim1 (with DRV8825 drivers)
  519. else ifeq ($(HARDWARE_MOTHERBOARD),3023)
  520. HARDWARE_VARIANT ?= archim
  521. MCPU = cortex-m3
  522. F_CPU = 84000000
  523. IS_MCU = 0
  524. # UltiMachine Archim2 (with TMC2130 drivers)
  525. else ifeq ($(HARDWARE_MOTHERBOARD),3024)
  526. HARDWARE_VARIANT ?= archim
  527. MCPU = cortex-m3
  528. F_CPU = 84000000
  529. IS_MCU = 0
  530. endif
  531. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  532. # if you are setting this to something other than 16MHz
  533. # Do not put the UL suffix, it's done later on.
  534. # Set to 16Mhz if not yet set.
  535. F_CPU ?= 16000000
  536. # Set to microcontroller if IS_MCU not yet set
  537. IS_MCU ?= 1
  538. ifeq ($(IS_MCU),1)
  539. # Set to arduino, ATmega2560 if not yet set.
  540. HARDWARE_VARIANT ?= arduino
  541. MCU ?= atmega2560
  542. PROG_MCU ?= m2560
  543. TOOL_PREFIX = avr
  544. MCU_FLAGS = -mmcu=$(MCU)
  545. SIZE_FLAGS = --mcu=$(MCU) -C
  546. else
  547. TOOL_PREFIX = arm-none-eabi
  548. CPU_FLAGS = -mthumb -mcpu=$(MCPU)
  549. SIZE_FLAGS = -A
  550. endif
  551. # Arduino contained the main source code for the Arduino
  552. # Libraries, the "hardware variant" are for boards
  553. # that derives from that, and their source are present in
  554. # the main Marlin source directory
  555. TARGET = $(notdir $(CURDIR))
  556. # VPATH tells make to look into these directory for source files,
  557. # there is no need to specify explicit pathnames as long as the
  558. # directory is added here
  559. # The Makefile for previous versions of Marlin used VPATH for all
  560. # source files, but for Marlin 2.0, we use VPATH only for arduino
  561. # library files.
  562. VPATH = .
  563. VPATH += $(BUILD_DIR)
  564. VPATH += $(HARDWARE_SRC)
  565. ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
  566. # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
  567. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  568. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  569. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
  570. endif
  571. ifeq ($(IS_MCU),1)
  572. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
  573. # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
  574. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  575. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial
  576. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  577. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
  578. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial/src
  579. endif
  580. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
  581. ifeq ($(LIQUID_TWI2), 1)
  582. WIRE = 1
  583. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
  584. endif
  585. ifeq ($(WIRE), 1)
  586. # Old libraries (avr-core 1.6.21 / Arduino < 1.6.8)
  587. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire
  588. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/utility
  589. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  590. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src
  591. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src/utility
  592. endif
  593. ifeq ($(NEOPIXEL), 1)
  594. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
  595. endif
  596. ifeq ($(U8GLIB), 1)
  597. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib
  598. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/csrc
  599. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/cppsrc
  600. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/fntsrc
  601. endif
  602. ifeq ($(TMC), 1)
  603. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src
  604. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src/source
  605. endif
  606. ifeq ($(HARDWARE_VARIANT), arduino)
  607. HARDWARE_SUB_VARIANT ?= mega
  608. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
  609. else ifeq ($(HARDWARE_VARIANT), Sanguino)
  610. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/variants/sanguino
  611. else ifeq ($(HARDWARE_VARIANT), archim)
  612. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/libsam
  613. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/CMSIS/Include/
  614. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/Device/ATMEL/
  615. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino
  616. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/avr
  617. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/USB
  618. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/Wire/src
  619. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/SPI/src
  620. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/U8glib/src/clib
  621. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim
  622. LDSCRIPT = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/linker_scripts/gcc/flash.ld
  623. LDLIBS = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/libsam_sam3x8e_gcc_rel.a
  624. else
  625. HARDWARE_SUB_VARIANT ?= standard
  626. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
  627. endif
  628. LIB_SRC = wiring.c \
  629. wiring_analog.c wiring_digital.c \
  630. wiring_shift.c WInterrupts.c hooks.c
  631. ifeq ($(HARDWARE_VARIANT), archim)
  632. LIB_ASRC += wiring_pulse_asm.S
  633. else
  634. LIB_SRC += wiring_pulse.c
  635. endif
  636. ifeq ($(HARDWARE_VARIANT), Teensy)
  637. LIB_SRC = wiring.c
  638. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
  639. endif
  640. LIB_CXXSRC = WMath.cpp WString.cpp Print.cpp SPI.cpp
  641. ifeq ($(NEOPIXEL), 1)
  642. LIB_CXXSRC += Adafruit_NeoPixel.cpp
  643. endif
  644. ifeq ($(LIQUID_TWI2), 0)
  645. LIB_CXXSRC += LiquidCrystal.cpp
  646. else
  647. LIB_SRC += twi.c
  648. LIB_CXXSRC += Wire.cpp LiquidTWI2.cpp
  649. endif
  650. ifeq ($(WIRE), 1)
  651. LIB_SRC += twi.c
  652. LIB_CXXSRC += Wire.cpp
  653. endif
  654. ifeq ($(TONE), 1)
  655. LIB_CXXSRC += Tone.cpp
  656. endif
  657. ifeq ($(U8GLIB), 1)
  658. LIB_CXXSRC += U8glib.cpp
  659. LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c \
  660. u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c \
  661. u8g_font_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
  662. endif
  663. ifeq ($(TMC), 1)
  664. LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp \
  665. CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp \
  666. DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp \
  667. SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp \
  668. TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
  669. endif
  670. ifeq ($(RELOC_WORKAROUND), 1)
  671. LD_PREFIX=-nodefaultlibs
  672. LD_SUFFIX=-lm -lgcc -lc -lgcc
  673. endif
  674. #Check for Arduino 1.0.0 or higher and use the correct source files for that version
  675. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  676. LIB_CXXSRC += main.cpp
  677. else
  678. LIB_SRC += pins_arduino.c main.c
  679. endif
  680. FORMAT = ihex
  681. # Name of this Makefile (used for "make depend").
  682. MAKEFILE = Makefile
  683. # Debugging format.
  684. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  685. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  686. DEBUG = stabs
  687. OPT = s
  688. DEFINES ?=
  689. # Program settings
  690. CC = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-gcc
  691. CXX = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-g++
  692. OBJCOPY = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objcopy
  693. OBJDUMP = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objdump
  694. AR = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-ar
  695. SIZE = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-size
  696. NM = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-nm
  697. AVRDUDE = avrdude
  698. REMOVE = rm -f
  699. MV = mv -f
  700. # Place -D or -U options here
  701. CDEFS = -DF_CPU=$(F_CPU)UL ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION)
  702. CXXDEFS = $(CDEFS)
  703. ifeq ($(HARDWARE_VARIANT), Teensy)
  704. CDEFS += -DUSB_SERIAL
  705. LIB_SRC += usb.c pins_teensy.c
  706. LIB_CXXSRC += usb_api.cpp
  707. else ifeq ($(HARDWARE_VARIANT), archim)
  708. CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__
  709. CDEFS += -DUSB_VID=0x27B1 -DUSB_PID=0x0001 -DUSBCON
  710. CDEFS += '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
  711. LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp \
  712. UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp \
  713. PluggableUSB.cpp USBCore.cpp
  714. LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
  715. ifeq ($(U8GLIB), 1)
  716. LIB_SRC += u8g_com_api.c u8g_pb32h1.c
  717. endif
  718. endif
  719. # Add all the source directories as include directories too
  720. CINCS = ${addprefix -I ,${VPATH}}
  721. CXXINCS = ${addprefix -I ,${VPATH}}
  722. # Silence warnings for library code (won't work for .h files, unfortunately)
  723. LIBWARN = -w -Wno-packed-bitfield-compat
  724. # Compiler flag to set the C/CPP Standard level.
  725. CSTANDARD = -std=gnu99
  726. CXXSTANDARD = -std=gnu++11
  727. CDEBUG = -g$(DEBUG)
  728. CWARN = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
  729. CXXWARN = -Wall -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
  730. CTUNING = -fsigned-char -funsigned-bitfields -fno-exceptions \
  731. -fshort-enums -ffunction-sections -fdata-sections
  732. ifneq ($(HARDWARE_MOTHERBOARD),)
  733. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  734. endif
  735. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  736. CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti
  737. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  738. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD)
  739. ASFLAGS := $(CDEFS)
  740. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  741. ifeq ($(HARDWARE_VARIANT), archim)
  742. LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
  743. LD_SUFFIX = $(LDLIBS)
  744. LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty
  745. LDFLAGS += -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
  746. else
  747. LD_PREFIX = -Wl,--gc-sections,--relax
  748. LDFLAGS = -lm
  749. CTUNING += -flto
  750. endif
  751. # Programming support using avrdude. Settings and variables.
  752. AVRDUDE_PORT = $(UPLOAD_PORT)
  753. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  754. ifeq ($(shell uname -s), Linux)
  755. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  756. else
  757. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
  758. endif
  759. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  760. -p$(PROG_MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  761. -b$(UPLOAD_RATE)
  762. # Since Marlin 2.0, the source files may be distributed into several
  763. # different directories, so it is necessary to find them recursively
  764. SRC = $(shell find src -name '*.c' -type f)
  765. CXXSRC = $(shell find src -name '*.cpp' -type f)
  766. # Define all object files.
  767. OBJ = ${patsubst %.c, $(BUILD_DIR)/arduino/%.o, ${LIB_SRC}}
  768. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/arduino/%.o, ${LIB_CXXSRC}}
  769. OBJ += ${patsubst %.S, $(BUILD_DIR)/arduino/%.o, ${LIB_ASRC}}
  770. OBJ += ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  771. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  772. # Define all listing files.
  773. LST = $(LIB_ASRC:.S=.lst) $(LIB_CXXSRC:.cpp=.lst) $(LIB_SRC:.c=.lst)
  774. # Combine all necessary flags and optional flags.
  775. # Add target processor to flags.
  776. ALL_CFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(CFLAGS) -I.
  777. ALL_CXXFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(CXXFLAGS)
  778. ALL_ASFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(ASFLAGS) -x assembler-with-cpp
  779. # set V=1 (eg, "make V=1") to print the full commands etc.
  780. ifneq ($V,1)
  781. Pecho=@echo
  782. P=@
  783. else
  784. Pecho=@:
  785. P=
  786. endif
  787. # Create required build hierarchy if it does not exist
  788. $(shell mkdir -p $(dir $(OBJ)))
  789. # Default target.
  790. all: sizeafter
  791. build: elf hex bin
  792. elf: $(BUILD_DIR)/$(TARGET).elf
  793. bin: $(BUILD_DIR)/$(TARGET).bin
  794. hex: $(BUILD_DIR)/$(TARGET).hex
  795. eep: $(BUILD_DIR)/$(TARGET).eep
  796. lss: $(BUILD_DIR)/$(TARGET).lss
  797. sym: $(BUILD_DIR)/$(TARGET).sym
  798. # Program the device.
  799. # Do not try to reset an Arduino if it's not one
  800. upload: $(BUILD_DIR)/$(TARGET).hex
  801. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  802. stty hup < $(UPLOAD_PORT); true
  803. endif
  804. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  805. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  806. stty -hup < $(UPLOAD_PORT); true
  807. endif
  808. # Display size of file.
  809. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  810. ELFSIZE = $(SIZE) $(SIZE_FLAGS) $(BUILD_DIR)/$(TARGET).elf; \
  811. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  812. sizebefore:
  813. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  814. sizeafter: build
  815. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  816. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  817. COFFCONVERT=$(OBJCOPY) --debugging \
  818. --change-section-address .data-0x800000 \
  819. --change-section-address .bss-0x800000 \
  820. --change-section-address .noinit-0x800000 \
  821. --change-section-address .eeprom-0x810000
  822. coff: $(BUILD_DIR)/$(TARGET).elf
  823. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  824. extcoff: $(TARGET).elf
  825. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  826. .SUFFIXES: .elf .hex .eep .lss .sym .bin
  827. .PRECIOUS: .o
  828. .elf.hex:
  829. $(Pecho) " COPY $@"
  830. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  831. .elf.bin:
  832. $(Pecho) " COPY $@"
  833. $P $(OBJCOPY) -O binary -R .eeprom $< $@
  834. .elf.eep:
  835. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  836. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  837. # Create extended listing file from ELF output file.
  838. .elf.lss:
  839. $(OBJDUMP) -h -S $< > $@
  840. # Create a symbol table from ELF output file.
  841. .elf.sym:
  842. $(NM) -n $< > $@
  843. # Link: create ELF output file from library.
  844. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  845. $(Pecho) " CXX $@"
  846. $P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
  847. # Object files that were found in "src" will be stored in $(BUILD_DIR)
  848. # in directories that mirror the structure of "src"
  849. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  850. $(Pecho) " CC $<"
  851. $P $(CC) -MMD -c $(ALL_CFLAGS) $(CWARN) $< -o $@
  852. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  853. $(Pecho) " CXX $<"
  854. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(CXXWARN) $< -o $@
  855. # Object files for Arduino libs will be created in $(BUILD_DIR)/arduino
  856. $(BUILD_DIR)/arduino/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  857. $(Pecho) " CC $<"
  858. $P $(CC) -MMD -c $(ALL_CFLAGS) $(LIBWARN) $< -o $@
  859. $(BUILD_DIR)/arduino/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  860. $(Pecho) " CXX $<"
  861. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(LIBWARN) $< -o $@
  862. $(BUILD_DIR)/arduino/%.o: %.S $(MAKEFILE)
  863. $(Pecho) " CXX $<"
  864. $P $(CXX) -MMD -c $(ALL_ASFLAGS) $< -o $@
  865. # Target: clean project.
  866. clean:
  867. $(Pecho) " RMDIR $(BUILD_DIR)/"
  868. $P rm -rf $(BUILD_DIR)
  869. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  870. # Automaticaly include the dependency files created by gcc
  871. -include ${patsubst %.o, %.d, ${OBJ}}