My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. # Sprinter Arduino Project Makefile
  2. #
  3. # Makefile Based on:
  4. # Arduino 0011 Makefile
  5. # Arduino adaptation by mellis, eighthave, oli.keller
  6. #
  7. # This has been tested with Arduino 0022.
  8. #
  9. # This makefile allows you to build sketches from the command line
  10. # without the Arduino environment (or Java).
  11. #
  12. # Detailed instructions for using the makefile:
  13. #
  14. # 1. Modify the line containg "INSTALL_DIR" to point to the directory that
  15. # contains the Arduino installation (for example, under Mac OS X, this
  16. # might be /Applications/arduino-0012).
  17. #
  18. # 2. Modify the line containing "PORT" to refer to the filename
  19. # representing the USB or serial connection to your Arduino board
  20. # (e.g. PORT = /dev/tty.USB0). If the exact name of this file
  21. # changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
  22. #
  23. # 3. Set the line containing "MCU" to match your board's processor.
  24. # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
  25. # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
  26. # change F_CPU to 8000000.
  27. #
  28. # 4. Type "make" and press enter to compile/verify your program.
  29. #
  30. # 5. Type "make upload", reset your Arduino board, and press enter to
  31. # upload your program to the Arduino board.
  32. #
  33. # $Id$
  34. #For "old" Arduino Mega
  35. MCU = atmega1280
  36. #For Arduino Mega2560
  37. #MCU = atmega2560
  38. #For Sanguinololu
  39. #MCU = atmega644p
  40. #Arduino install directory
  41. INSTALL_DIR = ../../arduino-0022/
  42. F_CPU = 16000000
  43. UPLOAD_RATE = 115200
  44. AVRDUDE_PROGRAMMER = arduino
  45. PORT = /dev/arduino
  46. TARGET = $(notdir $(CURDIR))
  47. ############################################################################
  48. # Below here nothing should be changed...
  49. ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
  50. AVR_TOOLS_PATH =
  51. SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
  52. $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
  53. $(ARDUINO)/wiring_pulse.c \
  54. $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
  55. CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
  56. $(ARDUINO)/Print.cpp Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
  57. FORMAT = ihex
  58. # Name of this Makefile (used for "make depend").
  59. MAKEFILE = Makefile
  60. # Debugging format.
  61. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  62. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  63. DEBUG = stabs
  64. OPT = s
  65. # Place -D or -U options here
  66. CDEFS = -DF_CPU=$(F_CPU)
  67. CXXDEFS = -DF_CPU=$(F_CPU)
  68. # Place -I options here
  69. CINCS = -I$(ARDUINO)
  70. CXXINCS = -I$(ARDUINO)
  71. # Compiler flag to set the C Standard level.
  72. # c89 - "ANSI" C
  73. # gnu89 - c89 plus GCC extensions
  74. # c99 - ISO C99 standard (not yet fully implemented)
  75. # gnu99 - c99 plus GCC extensions
  76. #CSTANDARD = -std=gnu99
  77. CDEBUG = -g$(DEBUG)
  78. CWARN = -Wall -Wstrict-prototypes
  79. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22
  80. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  81. CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
  82. CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
  83. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  84. LDFLAGS = -lm
  85. # Programming support using avrdude. Settings and variables.
  86. AVRDUDE_PORT = $(PORT)
  87. AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
  88. AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
  89. -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
  90. -b $(UPLOAD_RATE)
  91. # Program settings
  92. CC = $(AVR_TOOLS_PATH)avr-gcc
  93. CXX = $(AVR_TOOLS_PATH)avr-g++
  94. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  95. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  96. AR = $(AVR_TOOLS_PATH)avr-ar
  97. SIZE = $(AVR_TOOLS_PATH)avr-size
  98. NM = $(AVR_TOOLS_PATH)avr-nm
  99. AVRDUDE = avrdude
  100. REMOVE = rm -f
  101. MV = mv -f
  102. # Define all object files.
  103. OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
  104. # Define all listing files.
  105. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  106. # Combine all necessary flags and optional flags.
  107. # Add target processor to flags.
  108. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  109. ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
  110. ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
  111. # Default target.
  112. all: build sizeafter
  113. build: elf hex
  114. applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
  115. # Here is the "preprocessing".
  116. # It creates a .cpp file based with the same name as the .pde file.
  117. # On top of the new .cpp file comes the WProgram.h header.
  118. # At the end there is a generic main() function attached.
  119. # Then the .cpp file will be compiled. Errors during compile will
  120. # refer to this new, automatically generated, file.
  121. # Not the original .pde file you actually edit...
  122. @echo " WR applet/$(TARGET).cpp"
  123. @test -d applet || mkdir applet
  124. @echo '#include "WProgram.h"' > applet/$(TARGET).cpp
  125. @cat $(TARGET).pde >> applet/$(TARGET).cpp
  126. @cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
  127. elf: applet/$(TARGET).elf
  128. hex: applet/$(TARGET).hex
  129. eep: applet/$(TARGET).eep
  130. lss: applet/$(TARGET).lss
  131. sym: applet/$(TARGET).sym
  132. # Program the device.
  133. upload: applet/$(TARGET).hex
  134. stty hup < $(PORT); true
  135. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  136. stty -hup < $(PORT); true
  137. # Display size of file.
  138. HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
  139. ELFSIZE = $(SIZE) applet/$(TARGET).elf
  140. sizebefore:
  141. @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  142. sizeafter:
  143. @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  144. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  145. COFFCONVERT=$(OBJCOPY) --debugging \
  146. --change-section-address .data-0x800000 \
  147. --change-section-address .bss-0x800000 \
  148. --change-section-address .noinit-0x800000 \
  149. --change-section-address .eeprom-0x810000
  150. coff: applet/$(TARGET).elf
  151. $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
  152. extcoff: $(TARGET).elf
  153. $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
  154. .SUFFIXES: .elf .hex .eep .lss .sym
  155. .PRECIOUS: .o
  156. .elf.hex:
  157. @echo " COPY $@"
  158. @$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  159. .elf.eep:
  160. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  161. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  162. # Create extended listing file from ELF output file.
  163. .elf.lss:
  164. $(OBJDUMP) -h -S $< > $@
  165. # Create a symbol table from ELF output file.
  166. .elf.sym:
  167. $(NM) -n $< > $@
  168. # Link: create ELF output file from library.
  169. applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
  170. @echo " CXX $@"
  171. @$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
  172. applet/core.a: $(OBJ) Configuration.h
  173. @for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
  174. %.o: %.c Configuration.h $(MAKEFILE)
  175. @echo " CC $@"
  176. @$(CC) -c $(ALL_CFLAGS) $< -o $@
  177. %.o: %.cpp Configuration.h $(MAKEFILE)
  178. @echo " CXX $@"
  179. @$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
  180. # Target: clean project.
  181. clean:
  182. @echo " RM applet/*"
  183. @$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
  184. applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
  185. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  186. @echo " RMDIR applet/"
  187. @rmdir applet
  188. depend:
  189. if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
  190. then \
  191. sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
  192. $(MAKEFILE).$$$$ && \
  193. $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
  194. fi
  195. echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
  196. >> $(MAKEFILE); \
  197. $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
  198. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter