My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Makefile 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  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 knock off 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. #
  298. # Other ATmega1280, ATmega2560
  299. #
  300. # Cartesio CN Controls V11
  301. else ifeq ($(HARDWARE_MOTHERBOARD),1300)
  302. # Cartesio CN Controls V12
  303. else ifeq ($(HARDWARE_MOTHERBOARD),1301)
  304. # Cartesio CN Controls V15
  305. else ifeq ($(HARDWARE_MOTHERBOARD),1302)
  306. # Cheaptronic v1.0
  307. else ifeq ($(HARDWARE_MOTHERBOARD),1303)
  308. # Cheaptronic v2.0
  309. else ifeq ($(HARDWARE_MOTHERBOARD),1304)
  310. # Makerbot Mightyboard Revision E
  311. else ifeq ($(HARDWARE_MOTHERBOARD),1305)
  312. # Megatronics
  313. else ifeq ($(HARDWARE_MOTHERBOARD),1306)
  314. # Megatronics v2.0
  315. else ifeq ($(HARDWARE_MOTHERBOARD),1307)
  316. # Megatronics v3.0
  317. else ifeq ($(HARDWARE_MOTHERBOARD),1308)
  318. # Megatronics v3.1
  319. else ifeq ($(HARDWARE_MOTHERBOARD),1309)
  320. # Megatronics v3.2
  321. else ifeq ($(HARDWARE_MOTHERBOARD),1310)
  322. # Elefu Ra Board (v3)
  323. else ifeq ($(HARDWARE_MOTHERBOARD),1311)
  324. # Leapfrog
  325. else ifeq ($(HARDWARE_MOTHERBOARD),1312)
  326. # Mega controller
  327. else ifeq ($(HARDWARE_MOTHERBOARD),1313)
  328. # Geeetech GT2560 Rev B for Mecreator2
  329. else ifeq ($(HARDWARE_MOTHERBOARD),1314)
  330. # Geeetech GT2560 Rev. A
  331. else ifeq ($(HARDWARE_MOTHERBOARD),1315)
  332. # Geeetech GT2560 Rev. A+ (with auto level probe)
  333. else ifeq ($(HARDWARE_MOTHERBOARD),1316)
  334. # Geeetech GT2560 Rev B for A10(M/D)
  335. else ifeq ($(HARDWARE_MOTHERBOARD),1317)
  336. # Geeetech GT2560 Rev B for A20(M/D)
  337. else ifeq ($(HARDWARE_MOTHERBOARD),1318)
  338. # Einstart retrofit
  339. else ifeq ($(HARDWARE_MOTHERBOARD),1319)
  340. # Wanhao 0ne+ i3 Mini
  341. else ifeq ($(HARDWARE_MOTHERBOARD),1320)
  342. #
  343. # ATmega1281, ATmega2561
  344. #
  345. # Minitronics v1.0/1.1
  346. else ifeq ($(HARDWARE_MOTHERBOARD),1400)
  347. MCU ?= atmega1281
  348. PROG_MCU ?= m1281
  349. # Silvergate v1.0
  350. else ifeq ($(HARDWARE_MOTHERBOARD),1401)
  351. MCU ?= atmega1281
  352. PROG_MCU ?= m1281
  353. #
  354. # Sanguinololu and Derivatives - ATmega644P, ATmega1284P
  355. #
  356. # Sanguinololu < 1.2
  357. else ifeq ($(HARDWARE_MOTHERBOARD),1500)
  358. HARDWARE_VARIANT ?= Sanguino
  359. MCU ?= atmega644p
  360. PROG_MCU ?= m644p
  361. # Sanguinololu 1.2 and above
  362. else ifeq ($(HARDWARE_MOTHERBOARD),1501)
  363. HARDWARE_VARIANT ?= Sanguino
  364. MCU ?= atmega644p
  365. PROG_MCU ?= m644p
  366. # Melzi
  367. else ifeq ($(HARDWARE_MOTHERBOARD),1502)
  368. HARDWARE_VARIANT ?= Sanguino
  369. MCU ?= atmega644p
  370. PROG_MCU ?= m644p
  371. # Melzi V2.0
  372. else ifeq ($(HARDWARE_MOTHERBOARD),1503)
  373. HARDWARE_VARIANT ?= Sanguino
  374. MCU ?= atmega1284p
  375. PROG_MCU ?= m1284p
  376. # Melzi with ATmega1284 (MaKr3d version)
  377. else ifeq ($(HARDWARE_MOTHERBOARD),1504)
  378. HARDWARE_VARIANT ?= Sanguino
  379. MCU ?= atmega1284p
  380. PROG_MCU ?= m1284p
  381. # Melzi Creality3D board (for CR-10 etc)
  382. else ifeq ($(HARDWARE_MOTHERBOARD),1505)
  383. HARDWARE_VARIANT ?= Sanguino
  384. MCU ?= atmega1284p
  385. PROG_MCU ?= m1284p
  386. # Melzi Malyan M150 board
  387. else ifeq ($(HARDWARE_MOTHERBOARD),1506)
  388. HARDWARE_VARIANT ?= Sanguino
  389. MCU ?= atmega1284p
  390. PROG_MCU ?= m1284p
  391. # Tronxy X5S
  392. else ifeq ($(HARDWARE_MOTHERBOARD),1507)
  393. HARDWARE_VARIANT ?= Sanguino
  394. MCU ?= atmega1284p
  395. PROG_MCU ?= m1284p
  396. # STB V1.1
  397. else ifeq ($(HARDWARE_MOTHERBOARD),1508)
  398. HARDWARE_VARIANT ?= Sanguino
  399. MCU ?= atmega1284p
  400. PROG_MCU ?= m1284p
  401. # Azteeg X1
  402. else ifeq ($(HARDWARE_MOTHERBOARD),1509)
  403. HARDWARE_VARIANT ?= Sanguino
  404. MCU ?= atmega1284p
  405. PROG_MCU ?= m1284p
  406. # Anet 1.0 (Melzi clone)
  407. else ifeq ($(HARDWARE_MOTHERBOARD),1510)
  408. HARDWARE_VARIANT ?= Sanguino
  409. MCU ?= atmega1284p
  410. PROG_MCU ?= m1284p
  411. #
  412. # Other ATmega644P, ATmega644, ATmega1284P
  413. #
  414. # Gen3 Monolithic Electronics
  415. else ifeq ($(HARDWARE_MOTHERBOARD),1600)
  416. HARDWARE_VARIANT ?= Sanguino
  417. MCU ?= atmega644p
  418. PROG_MCU ?= m644p
  419. # Gen3+
  420. else ifeq ($(HARDWARE_MOTHERBOARD),1601)
  421. HARDWARE_VARIANT ?= Sanguino
  422. MCU ?= atmega644p
  423. PROG_MCU ?= m644p
  424. # Gen6
  425. else ifeq ($(HARDWARE_MOTHERBOARD),1602)
  426. HARDWARE_VARIANT ?= Gen6
  427. MCU ?= atmega644p
  428. PROG_MCU ?= m644p
  429. # Gen6 deluxe
  430. else ifeq ($(HARDWARE_MOTHERBOARD),1603)
  431. HARDWARE_VARIANT ?= Gen6
  432. MCU ?= atmega644p
  433. PROG_MCU ?= m644p
  434. # Gen7 custom (Alfons3 Version)
  435. else ifeq ($(HARDWARE_MOTHERBOARD),1604)
  436. HARDWARE_VARIANT ?= Gen7
  437. MCU ?= atmega644
  438. PROG_MCU ?= m644
  439. F_CPU ?= 20000000
  440. # Gen7 v1.1, v1.2
  441. else ifeq ($(HARDWARE_MOTHERBOARD),1605)
  442. HARDWARE_VARIANT ?= Gen7
  443. MCU ?= atmega644p
  444. PROG_MCU ?= m644p
  445. F_CPU ?= 20000000
  446. # Gen7 v1.3
  447. else ifeq ($(HARDWARE_MOTHERBOARD),1606)
  448. HARDWARE_VARIANT ?= Gen7
  449. MCU ?= atmega644p
  450. PROG_MCU ?= m644p
  451. F_CPU ?= 20000000
  452. # Gen7 v1.4
  453. else ifeq ($(HARDWARE_MOTHERBOARD),1607)
  454. HARDWARE_VARIANT ?= Gen7
  455. MCU ?= atmega1284p
  456. PROG_MCU ?= m1284p
  457. F_CPU ?= 20000000
  458. # Alpha OMCA board
  459. else ifeq ($(HARDWARE_MOTHERBOARD),1608)
  460. HARDWARE_VARIANT ?= SanguinoA
  461. MCU ?= atmega644
  462. PROG_MCU ?= m644
  463. # Final OMCA board
  464. else ifeq ($(HARDWARE_MOTHERBOARD),1609)
  465. HARDWARE_VARIANT ?= Sanguino
  466. MCU ?= atmega644p
  467. PROG_MCU ?= m644p
  468. # Sethi 3D_1
  469. else ifeq ($(HARDWARE_MOTHERBOARD),1610)
  470. HARDWARE_VARIANT ?= Sanguino
  471. MCU ?= atmega644p
  472. PROG_MCU ?= m644p
  473. #
  474. # Teensyduino - AT90USB1286, AT90USB1286P
  475. #
  476. # Teensylu
  477. else ifeq ($(HARDWARE_MOTHERBOARD),1700)
  478. HARDWARE_VARIANT ?= Teensy
  479. MCU ?= at90usb1286
  480. PROG_MCU ?= usb1286
  481. # Printrboard (AT90USB1286)
  482. else ifeq ($(HARDWARE_MOTHERBOARD),1701)
  483. HARDWARE_VARIANT ?= Teensy
  484. MCU ?= at90usb1286
  485. PROG_MCU ?= usb1286
  486. # Printrboard Revision F (AT90USB1286)
  487. else ifeq ($(HARDWARE_MOTHERBOARD),1702)
  488. HARDWARE_VARIANT ?= Teensy
  489. MCU ?= at90usb1286
  490. PROG_MCU ?= usb1286
  491. # Brainwave (AT90USB646)
  492. else ifeq ($(HARDWARE_MOTHERBOARD),1703)
  493. HARDWARE_VARIANT ?= Teensy
  494. MCU ?= at90usb646
  495. PROG_MCU ?= usb646
  496. # Brainwave Pro (AT90USB1286)
  497. else ifeq ($(HARDWARE_MOTHERBOARD),1704)
  498. HARDWARE_VARIANT ?= Teensy
  499. MCU ?= at90usb1286
  500. PROG_MCU ?= usb1286
  501. # SAV Mk-I (AT90USB1286)
  502. else ifeq ($(HARDWARE_MOTHERBOARD),1705)
  503. HARDWARE_VARIANT ?= Teensy
  504. MCU ?= at90usb1286
  505. PROG_MCU ?= usb1286
  506. # Teensy++2.0 (AT90USB1286)
  507. else ifeq ($(HARDWARE_MOTHERBOARD),1706)
  508. HARDWARE_VARIANT ?= Teensy
  509. MCU ?= at90usb1286
  510. PROG_MCU ?= usb1286
  511. # 5DPrint D8 Driver Board
  512. else ifeq ($(HARDWARE_MOTHERBOARD),1707)
  513. HARDWARE_VARIANT ?= Teensy
  514. MCU ?= at90usb1286
  515. PROG_MCU ?= usb1286
  516. # UltiMachine Archim1 (with DRV8825 drivers)
  517. else ifeq ($(HARDWARE_MOTHERBOARD),3023)
  518. HARDWARE_VARIANT ?= archim
  519. MCPU = cortex-m3
  520. F_CPU = 84000000
  521. IS_MCU = 0
  522. # UltiMachine Archim2 (with TMC2130 drivers)
  523. else ifeq ($(HARDWARE_MOTHERBOARD),3024)
  524. HARDWARE_VARIANT ?= archim
  525. MCPU = cortex-m3
  526. F_CPU = 84000000
  527. IS_MCU = 0
  528. endif
  529. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  530. # if you are setting this to something other than 16MHz
  531. # Do not put the UL suffix, it's done later on.
  532. # Set to 16Mhz if not yet set.
  533. F_CPU ?= 16000000
  534. # Set to microcontroller if IS_MCU not yet set
  535. IS_MCU ?= 1
  536. ifeq ($(IS_MCU),1)
  537. # Set to arduino, ATmega2560 if not yet set.
  538. HARDWARE_VARIANT ?= arduino
  539. MCU ?= atmega2560
  540. PROG_MCU ?= m2560
  541. TOOL_PREFIX = avr
  542. MCU_FLAGS = -mmcu=$(MCU)
  543. SIZE_FLAGS = --mcu=$(MCU) -C
  544. else
  545. TOOL_PREFIX = arm-none-eabi
  546. CPU_FLAGS = -mthumb -mcpu=$(MCPU)
  547. SIZE_FLAGS = -A
  548. endif
  549. # Arduino contained the main source code for the Arduino
  550. # Libraries, the "hardware variant" are for boards
  551. # that derives from that, and their source are present in
  552. # the main Marlin source directory
  553. TARGET = $(notdir $(CURDIR))
  554. # VPATH tells make to look into these directory for source files,
  555. # there is no need to specify explicit pathnames as long as the
  556. # directory is added here
  557. # The Makefile for previous versions of Marlin used VPATH for all
  558. # source files, but for Marlin 2.0, we use VPATH only for arduino
  559. # library files.
  560. VPATH = .
  561. VPATH += $(BUILD_DIR)
  562. VPATH += $(HARDWARE_SRC)
  563. ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
  564. # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
  565. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  566. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  567. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
  568. endif
  569. ifeq ($(IS_MCU),1)
  570. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
  571. # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
  572. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  573. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial
  574. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  575. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
  576. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial/src
  577. endif
  578. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
  579. ifeq ($(LIQUID_TWI2), 1)
  580. WIRE = 1
  581. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
  582. endif
  583. ifeq ($(WIRE), 1)
  584. # Old libraries (avr-core 1.6.21 / Arduino < 1.6.8)
  585. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire
  586. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/utility
  587. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  588. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src
  589. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src/utility
  590. endif
  591. ifeq ($(NEOPIXEL), 1)
  592. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
  593. endif
  594. ifeq ($(U8GLIB), 1)
  595. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib
  596. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/csrc
  597. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/cppsrc
  598. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/fntsrc
  599. endif
  600. ifeq ($(TMC), 1)
  601. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src
  602. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src/source
  603. endif
  604. ifeq ($(HARDWARE_VARIANT), arduino)
  605. HARDWARE_SUB_VARIANT ?= mega
  606. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
  607. else ifeq ($(HARDWARE_VARIANT), Sanguino)
  608. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/variants/sanguino
  609. else ifeq ($(HARDWARE_VARIANT), archim)
  610. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/libsam
  611. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/CMSIS/Include/
  612. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/Device/ATMEL/
  613. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino
  614. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/avr
  615. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/USB
  616. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/Wire/src
  617. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/SPI/src
  618. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/U8glib/src/clib
  619. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim
  620. LDSCRIPT = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/linker_scripts/gcc/flash.ld
  621. LDLIBS = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/libsam_sam3x8e_gcc_rel.a
  622. else
  623. HARDWARE_SUB_VARIANT ?= standard
  624. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
  625. endif
  626. LIB_SRC = wiring.c \
  627. wiring_analog.c wiring_digital.c \
  628. wiring_shift.c WInterrupts.c hooks.c
  629. ifeq ($(HARDWARE_VARIANT), archim)
  630. LIB_ASRC += wiring_pulse_asm.S
  631. else
  632. LIB_SRC += wiring_pulse.c
  633. endif
  634. ifeq ($(HARDWARE_VARIANT), Teensy)
  635. LIB_SRC = wiring.c
  636. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
  637. endif
  638. LIB_CXXSRC = WMath.cpp WString.cpp Print.cpp SPI.cpp
  639. ifeq ($(NEOPIXEL), 1)
  640. LIB_CXXSRC += Adafruit_NeoPixel.cpp
  641. endif
  642. ifeq ($(LIQUID_TWI2), 0)
  643. LIB_CXXSRC += LiquidCrystal.cpp
  644. else
  645. LIB_SRC += twi.c
  646. LIB_CXXSRC += Wire.cpp LiquidTWI2.cpp
  647. endif
  648. ifeq ($(WIRE), 1)
  649. LIB_SRC += twi.c
  650. LIB_CXXSRC += Wire.cpp
  651. endif
  652. ifeq ($(TONE), 1)
  653. LIB_CXXSRC += Tone.cpp
  654. endif
  655. ifeq ($(U8GLIB), 1)
  656. LIB_CXXSRC += U8glib.cpp
  657. LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c \
  658. u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c \
  659. u8g_font_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
  660. endif
  661. ifeq ($(TMC), 1)
  662. LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp \
  663. CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp \
  664. DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp \
  665. SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp \
  666. TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
  667. endif
  668. ifeq ($(RELOC_WORKAROUND), 1)
  669. LD_PREFIX=-nodefaultlibs
  670. LD_SUFFIX=-lm -lgcc -lc -lgcc
  671. endif
  672. #Check for Arduino 1.0.0 or higher and use the correct source files for that version
  673. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  674. LIB_CXXSRC += main.cpp
  675. else
  676. LIB_SRC += pins_arduino.c main.c
  677. endif
  678. FORMAT = ihex
  679. # Name of this Makefile (used for "make depend").
  680. MAKEFILE = Makefile
  681. # Debugging format.
  682. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  683. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  684. DEBUG = stabs
  685. OPT = s
  686. DEFINES ?=
  687. # Program settings
  688. CC = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-gcc
  689. CXX = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-g++
  690. OBJCOPY = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objcopy
  691. OBJDUMP = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objdump
  692. AR = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-ar
  693. SIZE = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-size
  694. NM = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-nm
  695. AVRDUDE = avrdude
  696. REMOVE = rm -f
  697. MV = mv -f
  698. # Place -D or -U options here
  699. CDEFS = -DF_CPU=$(F_CPU)UL ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION)
  700. CXXDEFS = $(CDEFS)
  701. ifeq ($(HARDWARE_VARIANT), Teensy)
  702. CDEFS += -DUSB_SERIAL
  703. LIB_SRC += usb.c pins_teensy.c
  704. LIB_CXXSRC += usb_api.cpp
  705. else ifeq ($(HARDWARE_VARIANT), archim)
  706. CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__
  707. CDEFS += -DUSB_VID=0x27B1 -DUSB_PID=0x0001 -DUSBCON
  708. CDEFS += '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
  709. LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp \
  710. UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp \
  711. PluggableUSB.cpp USBCore.cpp
  712. LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
  713. ifeq ($(U8GLIB), 1)
  714. LIB_SRC += u8g_com_api.c u8g_pb32h1.c
  715. endif
  716. endif
  717. # Add all the source directories as include directories too
  718. CINCS = ${addprefix -I ,${VPATH}}
  719. CXXINCS = ${addprefix -I ,${VPATH}}
  720. # Silence warnings for library code (won't work for .h files, unfortunately)
  721. LIBWARN = -w -Wno-packed-bitfield-compat
  722. # Compiler flag to set the C/CPP Standard level.
  723. CSTANDARD = -std=gnu99
  724. CXXSTANDARD = -std=gnu++11
  725. CDEBUG = -g$(DEBUG)
  726. CWARN = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
  727. CXXWARN = -Wall -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
  728. CTUNING = -fsigned-char -funsigned-bitfields -fno-exceptions \
  729. -fshort-enums -ffunction-sections -fdata-sections
  730. ifneq ($(HARDWARE_MOTHERBOARD),)
  731. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  732. endif
  733. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  734. CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti
  735. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  736. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD)
  737. ASFLAGS := $(CDEFS)
  738. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  739. ifeq ($(HARDWARE_VARIANT), archim)
  740. LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
  741. LD_SUFFIX = $(LDLIBS)
  742. LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty
  743. LDFLAGS += -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
  744. else
  745. LD_PREFIX = -Wl,--gc-sections,--relax
  746. LDFLAGS = -lm
  747. CTUNING += -flto
  748. endif
  749. # Programming support using avrdude. Settings and variables.
  750. AVRDUDE_PORT = $(UPLOAD_PORT)
  751. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  752. ifeq ($(shell uname -s), Linux)
  753. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  754. else
  755. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
  756. endif
  757. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  758. -p$(PROG_MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  759. -b$(UPLOAD_RATE)
  760. # Since Marlin 2.0, the source files may be distributed into several
  761. # different directories, so it is necessary to find them recursively
  762. SRC = $(shell find src -name '*.c' -type f)
  763. CXXSRC = $(shell find src -name '*.cpp' -type f)
  764. # Define all object files.
  765. OBJ = ${patsubst %.c, $(BUILD_DIR)/arduino/%.o, ${LIB_SRC}}
  766. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/arduino/%.o, ${LIB_CXXSRC}}
  767. OBJ += ${patsubst %.S, $(BUILD_DIR)/arduino/%.o, ${LIB_ASRC}}
  768. OBJ += ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  769. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  770. # Define all listing files.
  771. LST = $(LIB_ASRC:.S=.lst) $(LIB_CXXSRC:.cpp=.lst) $(LIB_SRC:.c=.lst)
  772. # Combine all necessary flags and optional flags.
  773. # Add target processor to flags.
  774. ALL_CFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(CFLAGS) -I.
  775. ALL_CXXFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(CXXFLAGS)
  776. ALL_ASFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(ASFLAGS) -x assembler-with-cpp
  777. # set V=1 (eg, "make V=1") to print the full commands etc.
  778. ifneq ($V,1)
  779. Pecho=@echo
  780. P=@
  781. else
  782. Pecho=@:
  783. P=
  784. endif
  785. # Create required build hierarchy if it does not exist
  786. $(shell mkdir -p $(dir $(OBJ)))
  787. # Default target.
  788. all: sizeafter
  789. build: elf hex bin
  790. elf: $(BUILD_DIR)/$(TARGET).elf
  791. bin: $(BUILD_DIR)/$(TARGET).bin
  792. hex: $(BUILD_DIR)/$(TARGET).hex
  793. eep: $(BUILD_DIR)/$(TARGET).eep
  794. lss: $(BUILD_DIR)/$(TARGET).lss
  795. sym: $(BUILD_DIR)/$(TARGET).sym
  796. # Program the device.
  797. # Do not try to reset an Arduino if it's not one
  798. upload: $(BUILD_DIR)/$(TARGET).hex
  799. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  800. stty hup < $(UPLOAD_PORT); true
  801. endif
  802. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  803. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  804. stty -hup < $(UPLOAD_PORT); true
  805. endif
  806. # Display size of file.
  807. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  808. ELFSIZE = $(SIZE) $(SIZE_FLAGS) $(BUILD_DIR)/$(TARGET).elf; \
  809. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  810. sizebefore:
  811. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  812. sizeafter: build
  813. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  814. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  815. COFFCONVERT=$(OBJCOPY) --debugging \
  816. --change-section-address .data-0x800000 \
  817. --change-section-address .bss-0x800000 \
  818. --change-section-address .noinit-0x800000 \
  819. --change-section-address .eeprom-0x810000
  820. coff: $(BUILD_DIR)/$(TARGET).elf
  821. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  822. extcoff: $(TARGET).elf
  823. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  824. .SUFFIXES: .elf .hex .eep .lss .sym .bin
  825. .PRECIOUS: .o
  826. .elf.hex:
  827. $(Pecho) " COPY $@"
  828. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  829. .elf.bin:
  830. $(Pecho) " COPY $@"
  831. $P $(OBJCOPY) -O binary -R .eeprom $< $@
  832. .elf.eep:
  833. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  834. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  835. # Create extended listing file from ELF output file.
  836. .elf.lss:
  837. $(OBJDUMP) -h -S $< > $@
  838. # Create a symbol table from ELF output file.
  839. .elf.sym:
  840. $(NM) -n $< > $@
  841. # Link: create ELF output file from library.
  842. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  843. $(Pecho) " CXX $@"
  844. $P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
  845. # Object files that were found in "src" will be stored in $(BUILD_DIR)
  846. # in directories that mirror the structure of "src"
  847. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  848. $(Pecho) " CC $<"
  849. $P $(CC) -MMD -c $(ALL_CFLAGS) $(CWARN) $< -o $@
  850. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  851. $(Pecho) " CXX $<"
  852. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(CXXWARN) $< -o $@
  853. # Object files for Arduino libs will be created in $(BUILD_DIR)/arduino
  854. $(BUILD_DIR)/arduino/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  855. $(Pecho) " CC $<"
  856. $P $(CC) -MMD -c $(ALL_CFLAGS) $(LIBWARN) $< -o $@
  857. $(BUILD_DIR)/arduino/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  858. $(Pecho) " CXX $<"
  859. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(LIBWARN) $< -o $@
  860. $(BUILD_DIR)/arduino/%.o: %.S $(MAKEFILE)
  861. $(Pecho) " CXX $<"
  862. $P $(CXX) -MMD -c $(ALL_ASFLAGS) $< -o $@
  863. # Target: clean project.
  864. clean:
  865. $(Pecho) " RMDIR $(BUILD_DIR)/"
  866. $P rm -rf $(BUILD_DIR)
  867. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  868. # Automaticaly include the dependency files created by gcc
  869. -include ${patsubst %.o, %.d, ${OBJ}}