Преглед изворни кода

Makefile support for 32-bit Archim board and new TMC library (#11997)

* Support new TMC library and 32-bit Archim board

- Added IS_MCU flag
  - When IS_MCU flag is 1, AVR compiler will be used
  - When IS_MCU flag is 0, ARM compiler will be used
- Added support for new TMC library
- Added support for a 32-bit Archim board, which could probably be used as a basis for other 32-bit boards.
Marcio Teixeira пре 6 година
родитељ
комит
03fc4d31d0
1 измењених фајлова са 240 додато и 179 уклоњено
  1. 240
    179
      Marlin/Makefile

+ 240
- 179
Marlin/Makefile Прегледај датотеку

@@ -89,8 +89,8 @@ WIRE               ?= 0
89 89
 # this defines if U8GLIB is needed (may require RELOC_WORKAROUND)
90 90
 U8GLIB             ?= 1
91 91
 
92
-# this defines whether to include the Trinamic TMC2630Stepper
93
-TMC2630            ?= 1
92
+# this defines whether to include the Trinamic TMCStepper library
93
+TMC                ?= 1
94 94
 
95 95
 ############
96 96
 # Try to automatically determine whether RELOC_WORKAROUND is needed based
@@ -103,7 +103,7 @@ CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | c
103 103
 CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) )))
104 104
 ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1)
105 105
   @echo This version of GCC is likely broken. Enabling relocation workaround.
106
-	RELOC_WORKAROUND = 1
106
+  RELOC_WORKAROUND = 1
107 107
 endif
108 108
 
109 109
 ############################################################################
@@ -195,7 +195,7 @@ else ifeq ($(HARDWARE_MOTHERBOARD),49)
195 195
 else ifeq ($(HARDWARE_MOTHERBOARD),7)
196 196
 # Ultimaker (Older electronics. Pre 1.5.4. This is rare)
197 197
 else ifeq ($(HARDWARE_MOTHERBOARD),71)
198
-MCU ?= atmega1280
198
+  MCU ?= atmega1280
199 199
 # Azteeg X3
200 200
 else ifeq ($(HARDWARE_MOTHERBOARD),67)
201 201
 # Azteeg X3 Pro
@@ -265,9 +265,9 @@ else ifeq ($(HARDWARE_MOTHERBOARD),75)
265 265
 #
266 266
 
267 267
 else ifeq ($(HARDWARE_MOTHERBOARD),702)
268
-MCU              ?= atmega1281
268
+  MCU              ?= atmega1281
269 269
 else ifeq ($(HARDWARE_MOTHERBOARD),25)
270
-MCU              ?= atmega1281
270
+  MCU              ?= atmega1281
271 271
 
272 272
 #
273 273
 # Sanguinololu and Derivatives - ATmega644P, ATmega1284P
@@ -275,44 +275,44 @@ MCU              ?= atmega1281
275 275
 
276 276
 # Sanguinololu < 1.2
277 277
 else ifeq ($(HARDWARE_MOTHERBOARD),6)
278
-HARDWARE_VARIANT ?= Sanguino
279
-MCU              ?= atmega644p
278
+  HARDWARE_VARIANT ?= Sanguino
279
+  MCU              ?= atmega644p
280 280
 # Sanguinololu 1.2 and above
281 281
 else ifeq ($(HARDWARE_MOTHERBOARD),62)
282
-HARDWARE_VARIANT ?= Sanguino
283
-MCU              ?= atmega644p
282
+  HARDWARE_VARIANT ?= Sanguino
283
+  MCU              ?= atmega644p
284 284
 # Melzi
285 285
 else ifeq ($(HARDWARE_MOTHERBOARD),63)
286
-HARDWARE_VARIANT ?= Sanguino
287
-MCU              ?= atmega644p
286
+  HARDWARE_VARIANT ?= Sanguino
287
+  MCU              ?= atmega644p
288 288
 # Melzi with ATmega1284 (MaKr3d version)
289 289
 else ifeq ($(HARDWARE_MOTHERBOARD),66)
290
-HARDWARE_VARIANT ?= Sanguino
291
-MCU              ?= atmega1284p
290
+  HARDWARE_VARIANT ?= Sanguino
291
+  MCU              ?= atmega1284p
292 292
 # Melzi Creality3D board (for CR-10 etc)
293 293
 else ifeq ($(HARDWARE_MOTHERBOARD),89)
294
-HARDWARE_VARIANT ?= Sanguino
295
-MCU              ?= atmega1284p
294
+  HARDWARE_VARIANT ?= Sanguino
295
+  MCU              ?= atmega1284p
296 296
 # Melzi Malyan M150 board
297 297
 else ifeq ($(HARDWARE_MOTHERBOARD),92)
298
-HARDWARE_VARIANT ?= Sanguino
299
-MCU              ?= atmega1284p
298
+  HARDWARE_VARIANT ?= Sanguino
299
+  MCU              ?= atmega1284p
300 300
 # Tronxy X5S
301 301
 else ifeq ($(HARDWARE_MOTHERBOARD),505)
302
-HARDWARE_VARIANT ?= Sanguino
303
-MCU              ?= atmega1284p
302
+  HARDWARE_VARIANT ?= Sanguino
303
+  MCU              ?= atmega1284p
304 304
 # STB V1.1
305 305
 else ifeq ($(HARDWARE_MOTHERBOARD),64)
306
-HARDWARE_VARIANT ?= Sanguino
307
-MCU              ?= atmega1284p
306
+  HARDWARE_VARIANT ?= Sanguino
307
+  MCU              ?= atmega1284p
308 308
 # Azteeg X1
309 309
 else ifeq ($(HARDWARE_MOTHERBOARD),65)
310
-HARDWARE_VARIANT ?= Sanguino
311
-MCU              ?= atmega1284p
310
+  HARDWARE_VARIANT ?= Sanguino
311
+  MCU              ?= atmega1284p
312 312
 # Anet 1.0 (Melzi clone)
313 313
 else ifeq ($(HARDWARE_MOTHERBOARD),69)
314
-HARDWARE_VARIANT ?= Sanguino
315
-MCU              ?= atmega1284p
314
+  HARDWARE_VARIANT ?= Sanguino
315
+  MCU              ?= atmega1284p
316 316
 
317 317
 #
318 318
 # Other ATmega644P, ATmega644, ATmega1284P
@@ -320,52 +320,52 @@ MCU              ?= atmega1284p
320 320
 
321 321
 # Gen3 Monolithic Electronics
322 322
 else ifeq ($(HARDWARE_MOTHERBOARD),22)
323
-HARDWARE_VARIANT ?= Sanguino
324
-MCU              ?= atmega644p
323
+  HARDWARE_VARIANT ?= Sanguino
324
+  MCU              ?= atmega644p
325 325
 # Gen3+
326 326
 else ifeq ($(HARDWARE_MOTHERBOARD),9)
327
-HARDWARE_VARIANT ?= Sanguino
328
-MCU              ?= atmega644p
327
+  HARDWARE_VARIANT ?= Sanguino
328
+  MCU              ?= atmega644p
329 329
 # Gen6
330 330
 else ifeq ($(HARDWARE_MOTHERBOARD),5)
331
-HARDWARE_VARIANT ?= Gen6
332
-MCU              ?= atmega644p
331
+  HARDWARE_VARIANT ?= Gen6
332
+  MCU              ?= atmega644p
333 333
 # Gen6 deluxe
334 334
 else ifeq ($(HARDWARE_MOTHERBOARD),51)
335
-HARDWARE_VARIANT ?= Gen6
336
-MCU              ?= atmega644p
335
+  HARDWARE_VARIANT ?= Gen6
336
+  MCU              ?= atmega644p
337 337
 # Gen7 custom (Alfons3 Version)
338 338
 else ifeq ($(HARDWARE_MOTHERBOARD),10)
339
-HARDWARE_VARIANT ?= Gen7
340
-MCU              ?= atmega644
341
-F_CPU            ?= 20000000
339
+  HARDWARE_VARIANT ?= Gen7
340
+  MCU              ?= atmega644
341
+  F_CPU            ?= 20000000
342 342
 # Gen7 v1.1, v1.2
343 343
 else ifeq ($(HARDWARE_MOTHERBOARD),11)
344
-HARDWARE_VARIANT ?= Gen7
345
-MCU              ?= atmega644p
346
-F_CPU            ?= 20000000
344
+  HARDWARE_VARIANT ?= Gen7
345
+  MCU              ?= atmega644p
346
+  F_CPU            ?= 20000000
347 347
 # Gen7 v1.3
348 348
 else ifeq ($(HARDWARE_MOTHERBOARD),12)
349
-HARDWARE_VARIANT ?= Gen7
350
-MCU              ?= atmega644p
351
-F_CPU            ?= 20000000
349
+  HARDWARE_VARIANT ?= Gen7
350
+  MCU              ?= atmega644p
351
+  F_CPU            ?= 20000000
352 352
 # Gen7 v1.4
353 353
 else ifeq ($(HARDWARE_MOTHERBOARD),13)
354
-HARDWARE_VARIANT ?= Gen7
355
-MCU              ?= atmega1284p
356
-F_CPU            ?= 20000000
354
+  HARDWARE_VARIANT ?= Gen7
355
+  MCU              ?= atmega1284p
356
+  F_CPU            ?= 20000000
357 357
 # Alpha OMCA board
358 358
 else ifeq ($(HARDWARE_MOTHERBOARD),90)
359
-HARDWARE_VARIANT ?= SanguinoA
360
-MCU              ?= atmega644
359
+  HARDWARE_VARIANT ?= SanguinoA
360
+  MCU              ?= atmega644
361 361
 # Final OMCA board
362 362
 else ifeq ($(HARDWARE_MOTHERBOARD),91)
363
-HARDWARE_VARIANT ?= Sanguino
364
-MCU              ?= atmega644p
363
+  HARDWARE_VARIANT ?= Sanguino
364
+  MCU              ?= atmega644p
365 365
 # Sethi 3D_1
366 366
 else ifeq ($(HARDWARE_MOTHERBOARD),20)
367
-HARDWARE_VARIANT ?= Sanguino
368
-MCU              ?= atmega644p
367
+  HARDWARE_VARIANT ?= Sanguino
368
+  MCU              ?= atmega644p
369 369
 
370 370
 #
371 371
 # Teensyduino - AT90USB1286, AT90USB1286P
@@ -373,37 +373,43 @@ MCU              ?= atmega644p
373 373
 
374 374
 # Teensylu
375 375
 else ifeq ($(HARDWARE_MOTHERBOARD),8)
376
-HARDWARE_VARIANT ?= Teensy
377
-MCU              ?= at90usb1286
376
+  HARDWARE_VARIANT ?= Teensy
377
+  MCU              ?= at90usb1286
378 378
 # Printrboard (AT90USB1286)
379 379
 else ifeq ($(HARDWARE_MOTHERBOARD),81)
380
-HARDWARE_VARIANT ?= Teensy
381
-MCU              ?= at90usb1286
380
+  HARDWARE_VARIANT ?= Teensy
381
+  MCU              ?= at90usb1286
382 382
 # Printrboard Revision F (AT90USB1286)
383 383
 else ifeq ($(HARDWARE_MOTHERBOARD),811)
384
-HARDWARE_VARIANT ?= Teensy
385
-MCU              ?= at90usb1286
384
+  HARDWARE_VARIANT ?= Teensy
385
+  MCU              ?= at90usb1286
386 386
 # Brainwave (AT90USB646)
387 387
 else ifeq ($(HARDWARE_MOTHERBOARD),82)
388
-HARDWARE_VARIANT ?= Teensy
389
-MCU              ?= at90usb646
388
+  HARDWARE_VARIANT ?= Teensy
389
+  MCU              ?= at90usb646
390 390
 # Brainwave Pro (AT90USB1286)
391 391
 else ifeq ($(HARDWARE_MOTHERBOARD),83)
392
-HARDWARE_VARIANT ?= Teensy
393
-MCU              ?= at90usb1286
392
+  HARDWARE_VARIANT ?= Teensy
393
+  MCU              ?= at90usb1286
394 394
 # SAV Mk-I (AT90USB1286)
395 395
 else ifeq ($(HARDWARE_MOTHERBOARD),84)
396
-HARDWARE_VARIANT ?= Teensy
397
-MCU              ?= at90usb1286
396
+  HARDWARE_VARIANT ?= Teensy
397
+  MCU              ?= at90usb1286
398 398
 # Teensy++2.0 (AT90USB1286)
399 399
 else ifeq ($(HARDWARE_MOTHERBOARD),85)
400
-HARDWARE_VARIANT ?= Teensy
401
-MCU              ?= at90usb1286
400
+  HARDWARE_VARIANT ?= Teensy
401
+  MCU              ?= at90usb1286
402 402
 # 5DPrint D8 Driver Board
403 403
 else ifeq ($(HARDWARE_MOTHERBOARD),88)
404
-HARDWARE_VARIANT ?= Teensy
405
-MCU              ?= at90usb1286
406
-
404
+  HARDWARE_VARIANT ?= Teensy
405
+  MCU              ?= at90usb1286
406
+
407
+# UltiMachine Archim2 (with TMC2130 drivers)
408
+else ifeq ($(HARDWARE_MOTHERBOARD),1590)
409
+  HARDWARE_VARIANT ?= archim
410
+  MCPU              = cortex-m3
411
+  F_CPU             = 84000000L
412
+  IS_MCU            = 0
407 413
 endif
408 414
 
409 415
 # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
@@ -411,9 +417,22 @@ endif
411 417
 # Set to 16Mhz if not yet set.
412 418
 F_CPU ?= 16000000
413 419
 
414
-# Set to arduino, ATmega2560 if not yet set.
415
-HARDWARE_VARIANT ?= arduino
416
-MCU ?= atmega2560
420
+# Set to microcontroller if IS_MCU not yet set
421
+IS_MCU ?= 1
422
+
423
+ifeq ($(IS_MCU),1)
424
+  # Set to arduino, ATmega2560 if not yet set.
425
+  HARDWARE_VARIANT ?= arduino
426
+  MCU ?= atmega2560
427
+
428
+  TOOL_PREFIX = avr
429
+  MCU_FLAGS   = -mmcu=$(MCU)
430
+  SIZE_FLAGS  = --mcu=$(MCU) -C
431
+else
432
+  TOOL_PREFIX = arm-none-eabi
433
+  CPU_FLAGS   = -mthumb -mcpu=$(MCPU)
434
+  SIZE_FLAGS  = -A
435
+endif
417 436
 
418 437
 # Arduino contained the main source code for the Arduino
419 438
 # Libraries, the "hardware variant" are for boards
@@ -434,19 +453,19 @@ VPATH = .
434 453
 VPATH += $(BUILD_DIR)
435 454
 VPATH += $(HARDWARE_SRC)
436 455
 
437
-# U8glib
438
-VPATH += $(ARDUINO_USER_DIR)/libraries/U8glib
439
-VPATH += $(ARDUINO_USER_DIR)/libraries/U8glib/clib
440
-
441 456
 ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
442 457
 VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/LiquidCrystal/src
443 458
 VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/SPI
444 459
 endif
445 460
 
446
-VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
461
+ifeq ($(IS_MCU),1)
462
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
463
+
464
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
465
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
466
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial/src
467
+endif
447 468
 
448
-VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
449
-VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
450 469
 VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
451 470
 ifeq ($(LIQUID_TWI2), 1)
452 471
 VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
@@ -462,71 +481,89 @@ VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
462 481
 endif
463 482
 ifeq ($(U8GLIB), 1)
464 483
 VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib
465
-VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/clib
484
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/csrc
485
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/cppsrc
486
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/fntsrc
466 487
 endif
467
-ifeq ($(TMC2630), 1)
468
-VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper/src
469
-VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper/src/source
488
+ifeq ($(TMC), 1)
489
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src
490
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src/source
470 491
 endif
471 492
 
472 493
 ifeq ($(HARDWARE_VARIANT), arduino)
473
-HARDWARE_SUB_VARIANT ?= mega
474
-VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
475
-else
476
-ifeq ($(HARDWARE_VARIANT), Sanguino)
477
-VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/variants/sanguino
494
+  HARDWARE_SUB_VARIANT ?= mega
495
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
496
+else ifeq ($(HARDWARE_VARIANT), Sanguino)
497
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/variants/sanguino
498
+else ifeq ($(HARDWARE_VARIANT), archim)
499
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/libsam
500
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/CMSIS/Include/
501
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/Device/ATMEL/
502
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino
503
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/avr
504
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/USB
505
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/Wire/src
506
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/SPI/src
507
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim
508
+  LDSCRIPT = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/linker_scripts/gcc/flash.ld
509
+  LDLIBS   = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/libsam_sam3x8e_gcc_rel.a
478 510
 else
479
-HARDWARE_SUB_VARIANT ?= standard
480
-VPATH += $(ARDUINO_INSTALL_DIR)/hardware/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
481
-endif
511
+  HARDWARE_SUB_VARIANT ?= standard
512
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
482 513
 endif
514
+
483 515
 LIB_SRC = wiring.c \
484
-	wiring_analog.c wiring_digital.c \
485
-	wiring_pulse.c \
486
-	wiring_shift.c WInterrupts.c hooks.c
516
+  wiring_analog.c wiring_digital.c \
517
+  wiring_shift.c WInterrupts.c hooks.c
518
+
519
+ifeq ($(HARDWARE_VARIANT), archim)
520
+  LIB_ASRC += wiring_pulse_asm.S
521
+else
522
+  LIB_SRC += wiring_pulse.c
523
+endif
487 524
 
488 525
 ifeq ($(HARDWARE_VARIANT), Teensy)
489
-LIB_SRC = wiring.c
490
-VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
526
+  LIB_SRC = wiring.c
527
+  VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
491 528
 endif
492 529
 
493
-LIB_CXXSRC = WMath.cpp WString.cpp Print.cpp SPI.cpp Tone.cpp
530
+LIB_CXXSRC = WMath.cpp WString.cpp Print.cpp SPI.cpp
494 531
 
495 532
 ifeq ($(NEOPIXEL), 1)
496
-LIB_CXXSRC += Adafruit_NeoPixel.cpp
533
+  LIB_CXXSRC += Adafruit_NeoPixel.cpp
497 534
 endif
498 535
 
499 536
 ifeq ($(LIQUID_TWI2), 0)
500
-LIB_CXXSRC += LiquidCrystal.cpp
537
+  LIB_CXXSRC += LiquidCrystal.cpp
501 538
 else
502
-LIB_SRC += twi.c
503
-LIB_CXXSRC += Wire.cpp LiquidTWI2.cpp
539
+  LIB_SRC += twi.c
540
+  LIB_CXXSRC += Wire.cpp LiquidTWI2.cpp
504 541
 endif
505 542
 
506 543
 ifeq ($(WIRE), 1)
507
-LIB_SRC += twi.c
508
-LIB_CXXSRC += Wire.cpp
544
+  LIB_SRC += twi.c
545
+  LIB_CXXSRC += Wire.cpp
509 546
 endif
510 547
 
511 548
 ifeq ($(U8GLIB), 1)
512
-LIB_CXXSRC += U8glib.cpp
513
-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
549
+  LIB_CXXSRC += U8glib.cpp
550
+  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_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
514 551
 endif
515 552
 
516
-ifeq ($(TMC2630), 1)
517
-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
553
+ifeq ($(TMC), 1)
554
+  LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp CHOPCONF.cpp  GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp DRVSTATUS.cpp ENCMODE.cpp  RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
518 555
 endif
519 556
 
520 557
 ifeq ($(RELOC_WORKAROUND), 1)
521
-LD_PREFIX=-nodefaultlibs
522
-LD_SUFFIX=-lm -lgcc -lc -lgcc
558
+  LD_PREFIX=-nodefaultlibs
559
+  LD_SUFFIX=-lm -lgcc -lc -lgcc
523 560
 endif
524 561
 
525 562
 #Check for Arduino 1.0.0 or higher and use the correct source files for that version
526 563
 ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
527
-LIB_CXXSRC += main.cpp
564
+  LIB_CXXSRC += main.cpp
528 565
 else
529
-LIB_SRC += pins_arduino.c main.c
566
+  LIB_SRC += pins_arduino.c main.c
530 567
 endif
531 568
 
532 569
 FORMAT = ihex
@@ -544,62 +581,77 @@ OPT = s
544 581
 DEFINES ?=
545 582
 
546 583
 # Program settings
547
-CC = $(AVR_TOOLS_PATH)avr-gcc
548
-CXX = $(AVR_TOOLS_PATH)avr-g++
549
-OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
550
-OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
551
-AR  = $(AVR_TOOLS_PATH)avr-ar
552
-SIZE = $(AVR_TOOLS_PATH)avr-size
553
-NM = $(AVR_TOOLS_PATH)avr-nm
584
+CC = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-gcc
585
+CXX = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-g++
586
+OBJCOPY = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objcopy
587
+OBJDUMP = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objdump
588
+AR  = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-ar
589
+SIZE = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-size
590
+NM = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-nm
554 591
 AVRDUDE = avrdude
555 592
 REMOVE = rm -f
556 593
 MV = mv -f
557 594
 
558 595
 # Place -D or -U options here
559
-CDEFS    = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
596
+CDEFS    = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION)
560 597
 CXXDEFS  = $(CDEFS)
561 598
 
562 599
 ifeq ($(HARDWARE_VARIANT), Teensy)
563
-CDEFS  += -DUSB_SERIAL
564
-LIB_SRC    += usb.c pins_teensy.c
565
-LIB_CXXSRC += usb_api.cpp
600
+  CDEFS  += -DUSB_SERIAL
601
+  LIB_SRC    += usb.c pins_teensy.c
602
+  LIB_CXXSRC += usb_api.cpp
603
+
604
+else ifeq ($(HARDWARE_VARIANT), archim)
605
+  CDEFS      += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
606
+  LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp  USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp  USBCore.cpp
607
+  LIB_SRC    += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
566 608
 endif
567 609
 
568 610
 # Add all the source directories as include directories too
569 611
 CINCS = ${addprefix -I ,${VPATH}}
570 612
 CXXINCS = ${addprefix -I ,${VPATH}}
571 613
 
614
+# Silence warnings for library code (won't work for .h files, unfortunately)
615
+LIBWARN = -w -Wno-packed-bitfield-compat
616
+
572 617
 # Compiler flag to set the C/CPP Standard level.
573 618
 CSTANDARD = -std=gnu99
574 619
 CXXSTANDARD = -std=gnu++11
575 620
 CDEBUG = -g$(DEBUG)
576
-CWARN = -Wall -Wstrict-prototypes
577
-CTUNING = -w -fsigned-char -funsigned-bitfields -fpack-struct \
578
-	-fshort-enums -ffunction-sections -fdata-sections -flto \
579
-	-DARDUINO=$(ARDUINO_VERSION)
621
+CWARN   = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas
622
+CXXWARN = -Wall                     -Wno-packed-bitfield-compat -Wno-pragmas
623
+CTUNING = -fsigned-char -funsigned-bitfields -fpack-struct -fno-exceptions \
624
+          -fshort-enums -ffunction-sections -fdata-sections
580 625
 ifneq ($(HARDWARE_MOTHERBOARD),)
581
-CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
626
+  CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
582 627
 endif
583 628
 #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
584
-CEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics
585
-
586
-CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(CSTANDARD)
587
-CXXFLAGS :=         $(CDEFS) $(CINCS) -O$(OPT) -Wall    $(CEXTRA) $(CTUNING) $(CXXSTANDARD)
629
+CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti
630
+CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA)   $(CTUNING) $(CSTANDARD)
631
+CXXFLAGS :=         $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD)
632
+ASFLAGS :=          $(CDEFS)
588 633
 #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
589
-LDFLAGS = -lm
590
-
634
+ifeq ($(HARDWARE_VARIANT), archim)
635
+  LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
636
+  LD_SUFFIX = $(LDLIBS)
637
+  LDFLAGS   = -lm -gcc -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
638
+else
639
+  LD_PREFIX = -Wl,--gc-sections,--relax
640
+  LDFLAGS   = -lm
641
+  CTUNING   += -flto
642
+endif
591 643
 
592 644
 # Programming support using avrdude. Settings and variables.
593 645
 AVRDUDE_PORT = $(UPLOAD_PORT)
594 646
 AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
595 647
 ifeq ($(shell uname -s), Linux)
596
-AVRDUDE_CONF = /etc/avrdude/avrdude.conf
648
+  AVRDUDE_CONF = /etc/avrdude/avrdude.conf
597 649
 else
598
-AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
650
+  AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
599 651
 endif
600 652
 AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
601
-	-p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
602
-	-b$(UPLOAD_RATE)
653
+  -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
654
+  -b$(UPLOAD_RATE)
603 655
 
604 656
 # Since Marlin 2.0, the source files may be distributed into several
605 657
 # different directories, so it is necessary to find them recursively
@@ -619,17 +671,17 @@ LST = $(LIB_ASRC:.S=.lst) $(LIB_CXXSRC:.cpp=.lst) $(LIB_SRC:.c=.lst)
619 671
 
620 672
 # Combine all necessary flags and optional flags.
621 673
 # Add target processor to flags.
622
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
623
-ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
624
-ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
674
+ALL_CFLAGS   = $(MCU_FLAGS) $(CPU_FLAGS) $(CFLAGS) -I.
675
+ALL_CXXFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(CXXFLAGS)
676
+ALL_ASFLAGS  = $(MCU_FLAGS) $(CPU_FLAGS) $(ASFLAGS) -x assembler-with-cpp
625 677
 
626 678
 # set V=1 (eg, "make V=1") to print the full commands etc.
627 679
 ifneq ($V,1)
628
- Pecho=@echo
629
- P=@
680
+  Pecho=@echo
681
+  P=@
630 682
 else
631
- Pecho=@:
632
- P=
683
+  Pecho=@:
684
+  P=
633 685
 endif
634 686
 
635 687
 # Create required build hierarchy if it does not exist
@@ -639,9 +691,10 @@ $(shell mkdir -p $(dir $(OBJ)))
639 691
 # Default target.
640 692
 all: sizeafter
641 693
 
642
-build: elf hex
694
+build: elf hex bin
643 695
 
644 696
 elf: $(BUILD_DIR)/$(TARGET).elf
697
+bin: $(BUILD_DIR)/$(TARGET).bin
645 698
 hex: $(BUILD_DIR)/$(TARGET).hex
646 699
 eep: $(BUILD_DIR)/$(TARGET).eep
647 700
 lss: $(BUILD_DIR)/$(TARGET).lss
@@ -651,93 +704,101 @@ sym: $(BUILD_DIR)/$(TARGET).sym
651 704
 # Do not try to reset an Arduino if it's not one
652 705
 upload: $(BUILD_DIR)/$(TARGET).hex
653 706
 ifeq (${AVRDUDE_PROGRAMMER}, arduino)
654
-	stty hup < $(UPLOAD_PORT); true
707
+  stty hup < $(UPLOAD_PORT); true
655 708
 endif
656
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
709
+  $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
657 710
 ifeq (${AVRDUDE_PROGRAMMER}, arduino)
658
-	stty -hup < $(UPLOAD_PORT); true
711
+  stty -hup < $(UPLOAD_PORT); true
659 712
 endif
660 713
 
661
-	# Display size of file.
714
+  # Display size of file.
662 715
 HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
663
-ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
716
+ELFSIZE = $(SIZE)  $(SIZE_FLAGS) $(BUILD_DIR)/$(TARGET).elf; \
664 717
           $(SIZE)  $(BUILD_DIR)/$(TARGET).elf
665 718
 sizebefore:
666
-	$P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
719
+  $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
667 720
 
668 721
 sizeafter: build
669
-	$P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
722
+  $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
670 723
 
671 724
 
672 725
 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
673 726
 COFFCONVERT=$(OBJCOPY) --debugging \
674
-	--change-section-address .data-0x800000 \
675
-	--change-section-address .bss-0x800000 \
676
-	--change-section-address .noinit-0x800000 \
677
-	--change-section-address .eeprom-0x810000
727
+  --change-section-address .data-0x800000 \
728
+  --change-section-address .bss-0x800000 \
729
+  --change-section-address .noinit-0x800000 \
730
+  --change-section-address .eeprom-0x810000
678 731
 
679 732
 
680 733
 coff: $(BUILD_DIR)/$(TARGET).elf
681
-	$(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
734
+  $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
682 735
 
683 736
 
684 737
 extcoff: $(TARGET).elf
685
-	$(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
738
+  $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
686 739
 
687 740
 
688
-.SUFFIXES: .elf .hex .eep .lss .sym
741
+.SUFFIXES: .elf .hex .eep .lss .sym .bin
689 742
 .PRECIOUS: .o
690 743
 
691 744
 .elf.hex:
692
-	$(Pecho) "  COPY  $@"
693
-	$P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
745
+  $(Pecho) "  COPY  $@"
746
+  $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
747
+
748
+.elf.bin:
749
+  $(Pecho) "  COPY  $@"
750
+  $P $(OBJCOPY) -O binary -R .eeprom $< $@
694 751
 
695 752
 .elf.eep:
696
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
697
-		--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
753
+  -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
754
+    --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
698 755
 
699 756
 # Create extended listing file from ELF output file.
700 757
 .elf.lss:
701
-	$(OBJDUMP) -h -S $< > $@
758
+  $(OBJDUMP) -h -S $< > $@
702 759
 
703 760
 # Create a symbol table from ELF output file.
704 761
 .elf.sym:
705
-	$(NM) -n $< > $@
762
+  $(NM) -n $< > $@
706 763
 
707
-	# Link: create ELF output file from library.
764
+  # Link: create ELF output file from library.
708 765
 
709 766
 $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
710
-	$(Pecho) "  CXX   $@"
711
-	$P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -Wl,--gc-sections,--relax -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
767
+  $(Pecho) "  CXX   $@"
768
+  $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
712 769
 
713 770
 # Object files that were found in "src" will be stored in $(BUILD_DIR)
714 771
 # in directories that mirror the structure of "src"
715 772
 
716 773
 $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
717
-	$(Pecho) "  CC    $<"
718
-	$P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
774
+  $(Pecho) "  CC    $<"
775
+  $P $(CC) -MMD -c $(ALL_CFLAGS) $(CWARN) $< -o $@
719 776
 
720 777
 $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
721
-	$(Pecho) "  CXX   $<"
722
-	$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
778
+  $(Pecho) "  CXX   $<"
779
+  $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(CXXWARN) $< -o $@
723 780
 
724 781
 # Object files for Arduino libs will be created in $(BUILD_DIR)/arduino
725 782
 
726 783
 $(BUILD_DIR)/arduino/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
727
-	$(Pecho) "  CC    $<"
728
-	$P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
784
+  $(Pecho) "  CC    $<"
785
+  $P $(CC) -MMD -c $(ALL_CFLAGS) $(LIBWARN) $< -o $@
729 786
 
730 787
 $(BUILD_DIR)/arduino/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
731
-	$(Pecho) "  CXX   $<"
732
-	$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
788
+  $(Pecho) "  CXX   $<"
789
+  $P $(CXX) -MMD -c $(ALL_CXXFLAGS)  $(LIBWARN) $< -o $@
790
+
791
+$(BUILD_DIR)/arduino/%.o: %.S $(MAKEFILE)
792
+  $(Pecho) "  CXX   $<"
793
+  $P $(CXX) -MMD -c $(ALL_ASFLAGS) $< -o $@
733 794
 
734 795
 # Target: clean project.
735 796
 clean:
736
-	$(Pecho) "  RMDIR $(BUILD_DIR)/"
737
-	$P rm -rf $(BUILD_DIR)
797
+  $(Pecho) "  RMDIR $(BUILD_DIR)/"
798
+  $P rm -rf $(BUILD_DIR)
738 799
 
739 800
 
740
-.PHONY:	all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
801
+.PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
741 802
 
742 803
 # Automaticaly include the dependency files created by gcc
743 804
 -include ${patsubst %.o, %.d, ${OBJ}}

Loading…
Откажи
Сачувај