From aa6e6e914eb82f465ded1078331a6774146bfd65 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 22 Mar 2012 13:48:10 +0000 Subject: [PATCH 1/2] Makefile: Redone + Removed most explicit pathnames, use the standard make "VPATH" to let make find the files for itself. + Added a "hardware variant" variable that allows compiging Sanguino and Gen7 as well as "generic" arduino. + Allows overriding the MOTHERBOARD define from the Makefile + Removed the 'preprocessor' bit that wasn't needed, now just "include" the files that are needed, since it allows gcc to show the right file/line when displaying error/warnings. + Uses gcc's own dependency generator to generate the .d files, and and include these instead of self-patching the makefile Signed-off-by: Michel Pollet --- Marlin/Configuration.h | 4 +- Marlin/Makefile | 134 ++++++++++++++++++++++++++--------------- 2 files changed, 90 insertions(+), 48 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index eed528cb8..896c93aa1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -29,7 +29,9 @@ // Ultimaker = 7 // Teensylu = 8 // Gen3+ =9 +#ifndef MOTHERBOARD #define MOTHERBOARD 7 +#endif //=========================================================================== //=============================Thermal Settings ============================ @@ -193,7 +195,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //#define ULTRA_LCD //general lcd support, also 16x2 //#define SDSUPPORT // Enable SD Card Support in Hardware Console -#define ULTIPANEL +//#define ULTIPANEL #ifdef ULTIPANEL // #define NEWPANEL //enable this if you have a click-encoder panel #define SDSUPPORT diff --git a/Marlin/Makefile b/Marlin/Makefile index 955ccd5e3..d69884d74 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -35,14 +35,31 @@ # $Id$ #For "old" Arduino Mega -MCU = atmega1280 +#MCU = atmega1280 #For Arduino Mega2560 #MCU = atmega2560 #For Sanguinololu -#MCU = atmega644p +MCU = atmega644p -#Arduino install directory -INSTALL_DIR = ../../arduino-0022/ +# Here you select "arduino", "Sanguino", "Gen7", ... +HARDWARE_VARIANT = Sanguino +# This defined the board you are compiling for +HARDWARE_MOTHERBOARD = 91 + +# Arduino source install directory +INSTALL_DIR = ../../arduino-0022 + +# Arduino containd the main source code for the Arduino +# Libraries, the "hardware variant" are for boards +# that derives from that, and their source are present in +# the main Marlin source directory +ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino + +ifeq (${HARDWARE_VARIANT}, arduino) +HARDWARE_SRC= $(ARDUINO) +else +HARDWARE_SRC= $(HARDWARE_VARIANT)/cores/arduino +endif # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py # if you are setting this to something other than 16MHz @@ -54,21 +71,32 @@ PORT = /dev/arduino TARGET = $(notdir $(CURDIR)) +# VPATH tells make to look into these directory for source files, +# there is no need to specify explicit pathnames as long as the +# directory is added here + +VPATH = . +VPATH += applet +VPATH += $(HARDWARE_SRC) +VPATH += $(ARDUINO) +VPATH += $(INSTALL_DIR)/libraries/LiquidCrystal ############################################################################ # Below here nothing should be changed... -ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino AVR_TOOLS_PATH = -SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \ - $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \ - $(ARDUINO)/wiring_pulse.c \ - $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c -CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\ - $(ARDUINO)/Print.cpp applet/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 +SRC = pins_arduino.c wiring.c \ + wiring_analog.c wiring_digital.c \ + wiring_pulse.c \ + wiring_shift.c WInterrupts.c +CXXSRC = WMath.cpp WString.cpp 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 +#CXXSRC += LiquidCrystal.cpp ultralcd.cpp +#CXXSRC += ultralcd.cpp FORMAT = ihex - # Name of this Makefile (used for "make depend"). MAKEFILE = Makefile @@ -83,9 +111,9 @@ OPT = s CDEFS = -DF_CPU=$(F_CPU) CXXDEFS = -DF_CPU=$(F_CPU) -# Place -I options here -CINCS = -I$(ARDUINO) -CXXINCS = -I$(ARDUINO) +# Add all the source directories as include directories too +CINCS = ${patsubst %,-I%,${subst :, ,${VPATH}}} +CXXINCS = ${patsubst %,-I%,${subst :, ,${VPATH}}} # Compiler flag to set the C Standard level. # c89 - "ANSI" C @@ -95,7 +123,12 @@ CXXINCS = -I$(ARDUINO) #CSTANDARD = -std=gnu99 CDEBUG = -g$(DEBUG) CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22 +CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \ + -fshort-enums -w -ffunction-sections -fdata-sections \ + -DARDUINO=22 +ifneq (${HARDWARE_MOTHERBOARD},) +CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD} +endif #CEXTRA = -Wa,-adhlns=$(<:.c=.lst) CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) @@ -124,7 +157,9 @@ REMOVE = rm -f MV = mv -f # Define all object files. -OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) +OBJ = ${patsubst %.c, applet/%.o, ${SRC}} +OBJ += ${patsubst %.cpp, applet/%.o, ${CXXSRC}} +OBJ += ${patsubst %.S, applet/%.o, ${ASRC}} # Define all listing files. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) @@ -132,30 +167,32 @@ LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) # Combine all necessary flags and optional flags. # Add target processor to flags. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) +ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) # Default target. -all: build sizeafter +all: sizeafter -build: elf hex +build: applet elf hex -applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE) +# Creates the object directory +applet: + @mkdir -p applet + +# the .cpp for Marlin depends on the .pde +#applet/$(TARGET).cpp: $(TARGET).pde +# ..and the .o depends from the .cpp +#applet/%.o: applet/%.cpp applet/%.cpp: %.pde # Here is the "preprocessing". # It creates a .cpp file based with the same name as the .pde file. # On top of the new .cpp file comes the WProgram.h header. -# At the end there is a generic main() function attached. -# Then the .cpp file will be compiled. Errors during compile will -# refer to this new, automatically generated, file. -# Not the original .pde file you actually edit... @echo " WR $@" - @test -d $(dir $@) || mkdir $(dir $@) @echo '#include "WProgram.h"' > $@ - @cat $< >> $@ - @cat $(ARDUINO)/main.cpp >> $@ + @echo '#include "$<"' >>$@ + @echo '#include "$(ARDUINO)/main.cpp"' >> $@ elf: applet/$(TARGET).elf hex: applet/$(TARGET).hex @@ -164,11 +201,15 @@ lss: applet/$(TARGET).lss sym: applet/$(TARGET).sym # Program the device. +# Do not try to reset an arduino if it's not one upload: applet/$(TARGET).hex +ifeq (${AVRDUDE_PROGRAMMER}, arduino) stty hup < $(PORT); true +endif $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) +ifeq (${AVRDUDE_PROGRAMMER}, arduino) stty -hup < $(PORT); true - +endif # Display size of file. HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex @@ -176,7 +217,7 @@ ELFSIZE = $(SIZE) applet/$(TARGET).elf sizebefore: @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi -sizeafter: +sizeafter: build @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi @@ -220,16 +261,22 @@ applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h @echo " CXX $@" @$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS) -applet/core.a: $(OBJ) Configuration.h +applet/core.a: $(OBJ) @for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done -%.o: %.c Configuration.h $(MAKEFILE) +applet/%.o: %.c @echo " CC $@" - @$(CC) -c $(ALL_CFLAGS) $< -o $@ + @$(CC) -MMD -c $(ALL_CFLAGS) $< -o $@ -%.o: %.cpp Configuration.h $(MAKEFILE) +applet/%.o: %.cpp @echo " CXX $@" - @$(CXX) -c $(ALL_CXXFLAGS) $< -o $@ + @$(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@ + +# special rule for autogenerated files... +applet/%.o: applet/%.cpp + @echo " CXX $@" + @$(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@ + # Target: clean project. clean: @@ -238,17 +285,10 @@ clean: applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \ $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) @echo " RMDIR applet/" - @rmdir applet + @rm -rf applet -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE) .PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter + +# Automaticaly include the dependency files created by gcc +-include ${wildcard applet/*.d} From 5550e893d5a94cf1c01df9831b8a79850fe097ee Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 22 Mar 2012 13:51:21 +0000 Subject: [PATCH 2/2] New board variant, Open Motion Controller Open Hardware board currently used by the group build of http://tvrrug.org.uk The board can be found at http://solderpad.com/folknology/open-motion-controller/ Signed-off-by: Michel Pollet --- Marlin/pins.h | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/Marlin/pins.h b/Marlin/pins.h index ff43a6278..ced9b350f 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -934,6 +934,161 @@ +/**************************************************************************************** +* Open Motion controller with enable based extruders +* +* ATMega644 +* +* +---\/---+ +* (D 0) PB0 1| |40 PA0 (AI 0 / D31) +* (D 1) PB1 2| |39 PA1 (AI 1 / D30) +* INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29) +* PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28) +* PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27) +* MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26) +* MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25) +* SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24) +* RST 9| |32 AREF +* VCC 10| |31 GND +* GND 11| |30 AVCC +* XTAL2 12| |29 PC7 (D 23) +* XTAL1 13| |28 PC6 (D 22) +* RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI +* TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO +* INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS +* INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK +* PWM (D 12) PD4 18| |23 PC1 (D 17) SDA +* PWM (D 13) PD5 19| |22 PC0 (D 16) SCL +* PWM (D 14) PD6 20| |21 PD7 (D 15) PWM +* +--------+ +* +****************************************************************************************/ +#if MOTHERBOARD == 90 //Alpha OMCA board +#define KNOWN_BOARD 1 + +#ifndef __AVR_ATmega644__ +#error Oops! Make sure you have 'SanguinoA' selected from the 'Tools -> Boards' menu. +#endif + +#define X_STEP_PIN 21 +#define X_DIR_PIN 20 +#define X_ENABLE_PIN 24 +#define X_MIN_PIN 0 +#define X_MAX_PIN -1 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 +#define Y_MIN_PIN 1 +#define Y_MAX_PIN -1 + +#define Z_STEP_PIN 26 +#define Z_DIR_PIN 25 +#define Z_ENABLE_PIN 24 +#define Z_MIN_PIN 2 +#define Z_MAX_PIN -1 + +#define E0_STEP_PIN 28 +#define E0_DIR_PIN 27 +#define E0_ENABLE_PIN 24 + +#define E1_STEP_PIN -1 // 19 +#define E1_DIR_PIN -1 // 18 +#define E1_ENABLE_PIN 24 + +#define E2_STEP_PIN -1 // 17 +#define E2_DIR_PIN -1 // 16 +#define E2_ENABLE_PIN 24 + +#define SDPOWER -1 +#define SDSS 11 +#define SDCARDDETECT -1 // 10 optional also used as mode pin +#define LED_PIN -1 +#define FAN_PIN 3 +#define PS_ON_PIN -1 +#define KILL_PIN -1 + +#define HEATER_0_PIN 4 +#define HEATER_1_PIN -1 // 12 +#define HEATER_2_PIN -1 // 13 +#define TEMP_0_PIN 0 //D27 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! +#define TEMP_1_PIN -1 // 1 +#define TEMP_2_PIN -1 // 2 +#define HEATER_BED_PIN -1 // 14/15 +#define TEMP_BED_PIN -1 // 1,2 or I2C +/* Unused (1) (2) (3) 4 5 6 7 8 9 10 11 12 13 (14) (15) (16) 17 (18) (19) (20) (21) (22) (23) 24 (25) (26) (27) 28 (29) (30) (31) */ + +#endif + +#if MOTHERBOARD == 91 // Final OMCA board -- REF http://sanguino.cc/hardware +#define KNOWN_BOARD 1 + +#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) +#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. (Final OMCA board) +#endif + +#define X_STEP_PIN 26 +#define X_DIR_PIN 25 +#define X_ENABLE_PIN 10 +#define X_MIN_PIN 0 +#define X_MAX_PIN -1 + +#define Y_STEP_PIN 28 +#define Y_DIR_PIN 27 +#define Y_ENABLE_PIN 10 +#define Y_MIN_PIN 1 +#define Y_MAX_PIN -1 + +#define Z_STEP_PIN 23 +#define Z_DIR_PIN 22 +#define Z_ENABLE_PIN 10 +#define Z_MIN_PIN 2 +#define Z_MAX_PIN -1 + +#define E0_STEP_PIN 24 +#define E0_DIR_PIN 21 +#define E0_ENABLE_PIN 10 + +/* future proofing */ +#define __FS 20 +#define __FD 19 +#define __GS 18 +#define __GD 13 + +#define UNUSED_PWM 14 /* PWM on LEFT connector */ + +#define E1_STEP_PIN -1 // 21 +#define E1_DIR_PIN -1 // 20 +#define E1_ENABLE_PIN -1 // 19 + +#define E2_STEP_PIN -1 // 21 +#define E2_DIR_PIN -1 // 20 +#define E2_ENABLE_PIN -1 // 18 + +#define SDPOWER -1 +#define SDSS 11 +#define SDCARDDETECT -1 // 10 optional also used as mode pin +#define LED_PIN -1 +#define FAN_PIN 14 /* PWM on MIDDLE connector */ +#define PS_ON_PIN -1 +#define KILL_PIN -1 + +#define HEATER_0_PIN 3 /*DONE PWM on RIGHT connector */ +#define HEATER_1_PIN -1 +#define HEATER_2_PIN -1 +#define HEATER_1_PIN -1 +#define HEATER_2_PIN -1 +#define TEMP_0_PIN 0 // ANALOG INPUT NUMBERING +#define TEMP_1_PIN 1 // ANALOG +#define TEMP_2_PIN -1 // 2 +#define HEATER_BED_PIN 4 +#define TEMP_BED_PIN 2 // 1,2 or I2C + +#define I2C_SCL 16 +#define I2C_SDA 17 + +#endif + #ifndef KNOWN_BOARD #error Unknown MOTHERBOARD value in configuration.h