My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. If you are using Gen7 electronics, you
  27. # probably need to use 20000000. Either way, you must regenerate
  28. # the speed lookup table with create_speed_lookuptable.py.
  29. #
  30. # 4. Type "make" and press enter to compile/verify your program.
  31. #
  32. # 5. Type "make upload", reset your Arduino board, and press enter to
  33. # upload your program to the Arduino board.
  34. #
  35. # $Id$
  36. #For "old" Arduino Mega
  37. #MCU = atmega1280
  38. #For Arduino Mega2560
  39. #MCU = atmega2560
  40. #For Sanguinololu
  41. MCU = atmega644p
  42. # Here you select "arduino", "Sanguino", "Gen7", ...
  43. HARDWARE_VARIANT = Sanguino
  44. # This defined the board you are compiling for
  45. HARDWARE_MOTHERBOARD = 91
  46. # Arduino source install directory
  47. INSTALL_DIR = ../../arduino-0022
  48. # Arduino containd the main source code for the Arduino
  49. # Libraries, the "hardware variant" are for boards
  50. # that derives from that, and their source are present in
  51. # the main Marlin source directory
  52. ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
  53. ifeq (${HARDWARE_VARIANT}, arduino)
  54. HARDWARE_SRC= $(ARDUINO)
  55. else
  56. HARDWARE_SRC= $(HARDWARE_VARIANT)/cores/arduino
  57. endif
  58. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  59. # if you are setting this to something other than 16MHz
  60. F_CPU = 16000000
  61. UPLOAD_RATE = 115200
  62. AVRDUDE_PROGRAMMER = arduino
  63. PORT = /dev/arduino
  64. TARGET = $(notdir $(CURDIR))
  65. # VPATH tells make to look into these directory for source files,
  66. # there is no need to specify explicit pathnames as long as the
  67. # directory is added here
  68. VPATH = .
  69. VPATH += applet
  70. VPATH += $(HARDWARE_SRC)
  71. VPATH += $(ARDUINO)
  72. VPATH += $(INSTALL_DIR)/libraries/LiquidCrystal
  73. ############################################################################
  74. # Below here nothing should be changed...
  75. AVR_TOOLS_PATH =
  76. SRC = pins_arduino.c wiring.c \
  77. wiring_analog.c wiring_digital.c \
  78. wiring_pulse.c \
  79. wiring_shift.c WInterrupts.c
  80. CXXSRC = WMath.cpp WString.cpp Print.cpp \
  81. Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp \
  82. SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp \
  83. planner.cpp stepper.cpp temperature.cpp cardreader.cpp
  84. #CXXSRC += LiquidCrystal.cpp ultralcd.cpp
  85. #CXXSRC += ultralcd.cpp
  86. FORMAT = ihex
  87. # Name of this Makefile (used for "make depend").
  88. MAKEFILE = Makefile
  89. # Debugging format.
  90. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  91. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  92. DEBUG = stabs
  93. OPT = s
  94. # Place -D or -U options here
  95. CDEFS = -DF_CPU=$(F_CPU)
  96. CXXDEFS = -DF_CPU=$(F_CPU)
  97. # Add all the source directories as include directories too
  98. CINCS = ${addprefix -I ,${VPATH}}
  99. CXXINCS = ${addprefix -I ,${VPATH}}
  100. # Compiler flag to set the C Standard level.
  101. # c89 - "ANSI" C
  102. # gnu89 - c89 plus GCC extensions
  103. # c99 - ISO C99 standard (not yet fully implemented)
  104. # gnu99 - c99 plus GCC extensions
  105. #CSTANDARD = -std=gnu99
  106. CDEBUG = -g$(DEBUG)
  107. CWARN = -Wall -Wstrict-prototypes
  108. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  109. -fshort-enums -w -ffunction-sections -fdata-sections \
  110. -DARDUINO=22
  111. ifneq (${HARDWARE_MOTHERBOARD},)
  112. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  113. endif
  114. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  115. CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
  116. CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
  117. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  118. LDFLAGS = -lm
  119. # Programming support using avrdude. Settings and variables.
  120. AVRDUDE_PORT = $(PORT)
  121. AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
  122. AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
  123. -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
  124. -b $(UPLOAD_RATE)
  125. # Program settings
  126. CC = $(AVR_TOOLS_PATH)avr-gcc
  127. CXX = $(AVR_TOOLS_PATH)avr-g++
  128. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  129. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  130. AR = $(AVR_TOOLS_PATH)avr-ar
  131. SIZE = $(AVR_TOOLS_PATH)avr-size
  132. NM = $(AVR_TOOLS_PATH)avr-nm
  133. AVRDUDE = avrdude
  134. REMOVE = rm -f
  135. MV = mv -f
  136. # Define all object files.
  137. OBJ = ${patsubst %.c, applet/%.o, ${SRC}}
  138. OBJ += ${patsubst %.cpp, applet/%.o, ${CXXSRC}}
  139. OBJ += ${patsubst %.S, applet/%.o, ${ASRC}}
  140. # Define all listing files.
  141. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  142. # Combine all necessary flags and optional flags.
  143. # Add target processor to flags.
  144. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  145. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  146. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  147. # Default target.
  148. all: sizeafter
  149. build: applet elf hex
  150. # Creates the object directory
  151. applet:
  152. @mkdir -p applet
  153. # the .cpp for Marlin depends on the .pde
  154. #applet/$(TARGET).cpp: $(TARGET).pde
  155. # ..and the .o depends from the .cpp
  156. #applet/%.o: applet/%.cpp
  157. applet/%.cpp: %.pde $(MAKEFILE)
  158. # Here is the "preprocessing".
  159. # It creates a .cpp file based with the same name as the .pde file.
  160. # On top of the new .cpp file comes the WProgram.h header.
  161. @echo " WR $@"
  162. @echo '#include "WProgram.h"' > $@
  163. @echo '#include "$<"' >>$@
  164. @echo '#include "$(ARDUINO)/main.cpp"' >> $@
  165. elf: applet/$(TARGET).elf
  166. hex: applet/$(TARGET).hex
  167. eep: applet/$(TARGET).eep
  168. lss: applet/$(TARGET).lss
  169. sym: applet/$(TARGET).sym
  170. # Program the device.
  171. # Do not try to reset an arduino if it's not one
  172. upload: applet/$(TARGET).hex
  173. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  174. stty hup < $(PORT); true
  175. endif
  176. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  177. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  178. stty -hup < $(PORT); true
  179. endif
  180. # Display size of file.
  181. HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
  182. ELFSIZE = $(SIZE) applet/$(TARGET).elf
  183. sizebefore:
  184. @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  185. sizeafter: build
  186. @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  187. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  188. COFFCONVERT=$(OBJCOPY) --debugging \
  189. --change-section-address .data-0x800000 \
  190. --change-section-address .bss-0x800000 \
  191. --change-section-address .noinit-0x800000 \
  192. --change-section-address .eeprom-0x810000
  193. coff: applet/$(TARGET).elf
  194. $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
  195. extcoff: $(TARGET).elf
  196. $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
  197. .SUFFIXES: .elf .hex .eep .lss .sym
  198. .PRECIOUS: .o
  199. .elf.hex:
  200. @echo " COPY $@"
  201. @$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  202. .elf.eep:
  203. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  204. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  205. # Create extended listing file from ELF output file.
  206. .elf.lss:
  207. $(OBJDUMP) -h -S $< > $@
  208. # Create a symbol table from ELF output file.
  209. .elf.sym:
  210. $(NM) -n $< > $@
  211. # Link: create ELF output file from library.
  212. applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
  213. @echo " CXX $@"
  214. @$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
  215. applet/core.a: $(OBJ)
  216. @for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
  217. applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  218. @echo " CC $@"
  219. @$(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  220. applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  221. @echo " CXX $@"
  222. @$(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  223. # Target: clean project.
  224. clean:
  225. @echo " RM applet/*"
  226. @$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
  227. applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
  228. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  229. @echo " RMDIR applet/"
  230. @rm -rf applet
  231. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
  232. # Automaticaly include the dependency files created by gcc
  233. -include ${wildcard applet/*.d}