From 323b9ea925bf45f56e7d9786b5f9325b03849fa6 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 6 Oct 2020 06:00:30 +0200 Subject: [PATCH 1/6] Makefile: Change the default board id to match Configuration.h change the default board to BOARD_RAMPS_14_EFB (1020) in the Makefile to avoid the following error message on a clean build (no variables given to make): src/pins/pins.h:743:6: error: \#error "Unknown MOTHERBOARD value set in Configuration.h" \#error "Unknown MOTHERBOARD value set in Configuration.h" ^ --- Marlin/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index 68dd05bdfbad..1b40881b529d 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -57,7 +57,7 @@ # # This defines the board to compile for (see boards.h for your board's ID) -HARDWARE_MOTHERBOARD ?= 11 +HARDWARE_MOTHERBOARD ?= 1020 # Arduino source install directory, and version number # On most linuxes this will be /usr/share/arduino From f0cb91e9f424832b2c8e190e998a0fcf7370befe Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 6 Oct 2020 06:07:20 +0200 Subject: [PATCH 2/6] Makefile: disable U8GLIB and TMC libraries Disable these two libraries because they're not provided with Arduino nor Marlin by default, so a no-arguments `make` simply fails. --- Marlin/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index 1b40881b529d..f72c314c0e0e 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -87,10 +87,10 @@ LIQUID_TWI2 ?= 0 WIRE ?= 0 # this defines if U8GLIB is needed (may require RELOC_WORKAROUND) -U8GLIB ?= 1 +U8GLIB ?= 0 # this defines whether to include the Trinamic TMCStepper library -TMC ?= 1 +TMC ?= 0 # this defines whether to include the AdaFruit NeoPixel library NEOPIXEL ?= 0 From a2a154ad2c93a933570eee30f82a676dd76f7833 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 6 Oct 2020 06:44:34 +0200 Subject: [PATCH 3/6] Makefile: Fix some libraries paths added to VPATH --- Marlin/Makefile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index f72c314c0e0e..f3e33473f31a 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -549,27 +549,36 @@ VPATH += $(BUILD_DIR) VPATH += $(HARDWARE_SRC) ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino)) -VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/LiquidCrystal/src -VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/SPI + # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8) + VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI + # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8) + VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src endif ifeq ($(IS_MCU),1) VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino + # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8) VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI + VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial + # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8) VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial/src endif VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src + ifeq ($(LIQUID_TWI2), 1) -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2 + WIRE = 1 + VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2 endif ifeq ($(WIRE), 1) -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility + # Old libraries (avr-core 1.6.21 / Arduino < 1.6.8) + VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire + VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/utility + # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8) + VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src + VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src/utility endif ifeq ($(NEOPIXEL), 1) VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel From ed85c0a09f4191f45506382bbcd22da0a6beb55e Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 6 Oct 2020 07:46:34 +0200 Subject: [PATCH 4/6] Makefile: Add Tone.cpp to the CXX source files Tone.cpp (from ADRUINO_DIR/hardware/arduino/avr/cores/arduino/) is required when the speaker function is enabled. Otherwise, the linker complains: applet/src/libs/buzzer.o: In function `Buzzer::tick()': buzzer.cpp:(.text._ZN6Buzzer4tickEv+0xb2): undefined reference to `tone(unsigned char, unsigned int, unsigned long)' collect2: error: ld returned 1 exit status --- Marlin/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Marlin/Makefile b/Marlin/Makefile index f3e33473f31a..d1b9e9a5a707 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -86,6 +86,10 @@ LIQUID_TWI2 ?= 0 # this defines if Wire is needed WIRE ?= 0 +# this defines if Tone is needed (i.e SPEAKER is defined in Configuration.h) +# Disabling this (and SPEAKER) saves approximatively 350 bytes of memory. +TONE ?= 1 + # this defines if U8GLIB is needed (may require RELOC_WORKAROUND) U8GLIB ?= 0 @@ -650,6 +654,10 @@ ifeq ($(WIRE), 1) LIB_CXXSRC += Wire.cpp endif +ifeq ($(TONE), 1) + LIB_CXXSRC += Tone.cpp +endif + ifeq ($(U8GLIB), 1) LIB_CXXSRC += U8glib.cpp 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 From efbcf91acdaec634c46c9b7f00534661fac4d285 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 6 Oct 2020 08:05:35 +0200 Subject: [PATCH 5/6] Makefile: formating, wrap long lines when possible --- Marlin/Makefile | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index d1b9e9a5a707..9ffc6b03aba9 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -67,17 +67,19 @@ ARDUINO_VERSION ?= 106 # The installed Libraries are in the User folder ARDUINO_USER_DIR ?= ${HOME}/Arduino -# You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin) +# You can optionally set a path to the avr-gcc tools. Requires a trailing +# slash. (ex: /usr/local/avr-gcc/bin) AVR_TOOLS_PATH ?= -#Programmer configuration +# Programmer configuration UPLOAD_RATE ?= 57600 AVRDUDE_PROGRAMMER ?= arduino # on most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1 UPLOAD_PORT ?= /dev/ttyUSB0 -#Directory used to build files in, contains all the build files, from object files to the final hex file -#on linux it is best to put an absolute path like /home/username/tmp . +# Directory used to build files in, contains all the build files, from object +# files to the final hex file on linux it is best to put an absolute path +# like /home/username/tmp . BUILD_DIR ?= applet # This defines whether Liquid_TWI2 support will be built @@ -660,11 +662,17 @@ endif ifeq ($(U8GLIB), 1) LIB_CXXSRC += U8glib.cpp - 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 + 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 endif ifeq ($(TMC), 1) - 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 TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp + 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 \ + TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp endif ifeq ($(RELOC_WORKAROUND), 1) @@ -710,13 +718,19 @@ CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VER CXXDEFS = $(CDEFS) ifeq ($(HARDWARE_VARIANT), Teensy) - CDEFS += -DUSB_SERIAL + CDEFS += -DUSB_SERIAL LIB_SRC += usb.c pins_teensy.c LIB_CXXSRC += usb_api.cpp else ifeq ($(HARDWARE_VARIANT), archim) - CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"' - 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 + CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ + CDEFS += -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON + CDEFS += '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"' + + 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 + LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c ifeq ($(U8GLIB), 1) @@ -742,16 +756,20 @@ CTUNING = -fsigned-char -funsigned-bitfields -fno-exceptions \ ifneq ($(HARDWARE_MOTHERBOARD),) CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD} endif + #CEXTRA = -Wa,-adhlns=$(<:.c=.lst) CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA) $(CTUNING) $(CSTANDARD) CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD) ASFLAGS := $(CDEFS) #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs + ifeq ($(HARDWARE_VARIANT), archim) LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align LD_SUFFIX = $(LDLIBS) - LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid + + LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty + LDFLAGS += -u _lseek -u _read -u _write -u _exit -u kill -u _getpid else LD_PREFIX = -Wl,--gc-sections,--relax LDFLAGS = -lm @@ -868,7 +886,7 @@ extcoff: $(TARGET).elf .elf.eep: -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ # Create extended listing file from ELF output file. .elf.lss: From b270a4cd1af76708860f0c08e3dad44776ab67b3 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 6 Oct 2020 08:06:20 +0200 Subject: [PATCH 6/6] Makefile: Use CXX to build .elf target Most of the time, CC resolves to avr-gcc, which is the C compiler, and hence won't be able to properly link C++ objects (It won't pass the proper flags to the linker). So use CXX instead. --- Marlin/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index 9ffc6b03aba9..bb5fbc861cf5 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -900,7 +900,7 @@ extcoff: $(TARGET).elf $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h $(Pecho) " CXX $@" - $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX) + $P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX) # Object files that were found in "src" will be stored in $(BUILD_DIR) # in directories that mirror the structure of "src"