Can't get Marlin-Unified v2 to compile with Arduino 0022

Troubleshooting talk for software

Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Mon-16-Feb

I'm trying to get the "official" printrbot Marlin version:

https://github.com/Printrbot/Marlin/rel ... unified-v2

to compile with the "supported" arduino release:

http://www.reprap-usa.com/download/arduino0022.zip

I've loaded the above under C:\Program Files (x86)\Arduino

when I then attempt to "Verify" the Marlin.pde sketch, I get the following errors:

Code: Select all

In file included from cardreader.cpp:1:
/Marlin.h:32:23: error: WProgram.h: No such file or directory
/Marlin.h:46:21: error: WString.h: No such file or directory
In file included from /Marlin.h:15,
                 from cardreader.cpp:1:
c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/util/delay.h: In function 'void _delay_us(double)':
c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/util/delay.h:111: error: 'null' was not declared in this scope
c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/util/delay.h: In function 'void _delay_ms(double)':
c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/util/delay.h:145: error: 'null' was not declared in this scope
In file included from cardreader.cpp:1:
/Marlin.h: In function 'void serialprintPGM(const char*)':
Marlin.h:87: error: 'Serial' was not declared in this scope
In file included from /cardreader.h:8,
                 from cardreader.cpp:2:
/SdFile.h: At global scope:
SdFile.h:35: error: expected class-name before '{' token
cardreader.cpp: In constructor 'CardReader::CardReader()':
cardreader.cpp:31: error: 'millis' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::lsDive(const char*, SdFile)':
cardreader.cpp:82: error: 'Serial' was not declared in this scope
cardreader.cpp:83: error: 'Serial' was not declared in this scope
cardreader.cpp:116: error: 'Serial' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::initsd()':
cardreader.cpp:158: error: 'Serial' was not declared in this scope
cardreader.cpp:163: error: 'Serial' was not declared in this scope
cardreader.cpp:168: error: 'Serial' was not declared in this scope
cardreader.cpp:174: error: 'Serial' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::openFile(char*, bool)':
cardreader.cpp:253: error: 'Serial' was not declared in this scope
cardreader.cpp:257: error: 'Serial' was not declared in this scope
cardreader.cpp:289: error: 'Serial' was not declared in this scope
cardreader.cpp:300: error: 'Serial' was not declared in this scope
cardreader.cpp:309: error: 'Serial' was not declared in this scope
cardreader.cpp:316: error: 'Serial' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::removeFile(char*)':
cardreader.cpp:349: error: 'Serial' was not declared in this scope
cardreader.cpp:353: error: 'Serial' was not declared in this scope
cardreader.cpp:382: error: 'Serial' was not declared in this scope
cardreader.cpp:388: error: 'Serial' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::getStatus()':
cardreader.cpp:398: error: 'Serial' was not declared in this scope
cardreader.cpp:403: error: 'Serial' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::write_command(char*)':
cardreader.cpp:425: error: 'Serial' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::checkautostart(bool)':
cardreader.cpp:436: error: 'millis' was not declared in this scope
cardreader.cpp:450: error: 'tolower' was not declared in this scope
cardreader.cpp:459: error: 'tolower' was not declared in this scope
cardreader.cpp: In member function 'void CardReader::chdir(const char*)':
cardreader.cpp:521: error: 'Serial' was not declared in this scope


I'm trying to get this to compile so I can then load it into Eclipse to actually look at code. The Arduino IDE leaves a lot to be desired in terms of being able to browse code.

One thing that has me completely stumped, is I can see a "makefile" in the Marlin directory. I thought maybe that's what needed to be modified. When I open it directly via Word I get the following:

Code: Select all
# Sprinter Arduino Project Makefile
#
# Makefile Based on:
# Arduino 0011 Makefile
# Arduino adaptation by mellis, eighthave, oli.keller
# Marlin adaption by Daid
#
# This has been tested with Arduino 0022.
#
# This makefile allows you to build sketches from the command line
# without the Arduino environment (or Java).
#
# Detailed instructions for using the makefile:
#
#  1. Modify the line containg "ARDUINO_INSTALL_DIR" to point to the directory that
#     contains the Arduino installation (for example, under Mac OS X, this
#     might be /Applications/arduino-0012).
#
#  2. Modify the line containing "UPLOAD_PORT" to refer to the filename
#     representing the USB or serial connection to your Arduino board
#     (e.g. UPLOAD_PORT = /dev/tty.USB0).  If the exact name of this file
#     changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*).
#
#  3. Set the line containing "MCU" to match your board's processor.
#     Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
#     or Diecimila have the atmega168.  If you're using a LilyPad Arduino,
#     change F_CPU to 8000000. If you are using Gen7 electronics, you
#     probably need to use 20000000. Either way, you must regenerate
#     the speed lookup table with create_speed_lookuptable.py.
#
#  4. Type "make" and press enter to compile/verify your program.
#
#  5. Type "make upload", reset your Arduino board, and press enter to
#     upload your program to the Arduino board.
#
# Note that all settings are set with ?=, this means you can override them
# from the commandline with "make HARDWARE_MOTHERBOARD=71" for example

# This defined the board you are compiling for (see Configuration.h for the options)
HARDWARE_MOTHERBOARD ?= 11

# Arduino source install directory, and version number
ARDUINO_INSTALL_DIR  ?= ../../arduino-0022
ARDUINO_VERSION      ?= 22

# 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
UPLOAD_RATE        ?= 115200
AVRDUDE_PROGRAMMER ?= arduino
UPLOAD_PORT        ?= /dev/arduino

#Directory used to build files in, contains all the build files, from object files to the final hex file.
BUILD_DIR          ?= applet

############################################################################
# Below here nothing should be changed...

# Here the Arduino variant is selected by the board type
# HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
# MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...

#Gen7
ifeq ($(HARDWARE_MOTHERBOARD),10)
HARDWARE_VARIANT ?= Gen7
MCU              ?= atmega644
F_CPU            ?= 20000000
else ifeq  ($(HARDWARE_MOTHERBOARD),11)
HARDWARE_VARIANT ?= Gen7
MCU              ?= atmega644p
F_CPU            ?= 20000000
else ifeq  ($(HARDWARE_MOTHERBOARD),12)
HARDWARE_VARIANT ?= Gen7
MCU              ?= atmega644p
F_CPU            ?= 20000000
else ifeq  ($(HARDWARE_MOTHERBOARD),13)
HARDWARE_VARIANT ?= Gen7
MCU              ?= atmega1284p
F_CPU            ?= 20000000

#RAMPS
else ifeq  ($(HARDWARE_MOTHERBOARD),3)
HARDWARE_VARIANT ?= arduino
MCU              ?= atmega2560
else ifeq  ($(HARDWARE_MOTHERBOARD),33)
HARDWARE_VARIANT ?= arduino
MCU              ?= atmega2560
else ifeq  ($(HARDWARE_MOTHERBOARD),34)
HARDWARE_VARIANT ?= arduino
MCU              ?= atmega2560

#Duemilanove w/ ATMega328P pin assignment
else ifeq  ($(HARDWARE_MOTHERBOARD),4)
HARDWARE_VARIANT ?= arduino
HARDWARE_SUB_VARIANT ?= standard
MCU              ?= atmega328p

#Gen6
else ifeq  ($(HARDWARE_MOTHERBOARD),5)
HARDWARE_VARIANT ?= Gen6
MCU              ?= atmega644p
else ifeq  ($(HARDWARE_MOTHERBOARD),51)
HARDWARE_VARIANT ?= Gen6
MCU              ?= atmega644p

#Sanguinololu
else ifeq  ($(HARDWARE_MOTHERBOARD),6)
HARDWARE_VARIANT ?= Sanguino
MCU              ?= atmega644p
else ifeq  ($(HARDWARE_MOTHERBOARD),62)
HARDWARE_VARIANT ?= Sanguino
MCU              ?= atmega644p
else ifeq  ($(HARDWARE_MOTHERBOARD),63)
HARDWARE_VARIANT ?= Sanguino
MCU              ?= atmega644p

#Ultimaker
else ifeq  ($(HARDWARE_MOTHERBOARD),7)
HARDWARE_VARIANT ?= arduino
MCU              ?= atmega2560
else ifeq  ($(HARDWARE_MOTHERBOARD),71)
HARDWARE_VARIANT ?= arduino
MCU              ?= atmega1280

#Teensylu
else ifeq  ($(HARDWARE_MOTHERBOARD),8)
HARDWARE_VARIANT ?= Teensy
MCU              ?= at90usb1286
else ifeq  ($(HARDWARE_MOTHERBOARD),81)
HARDWARE_VARIANT ?= Teensy
MCU              ?= at90usb1286
else ifeq  ($(HARDWARE_MOTHERBOARD),82)
HARDWARE_VARIANT ?= Teensy
MCU              ?= at90usb646

#Gen3+
else ifeq  ($(HARDWARE_MOTHERBOARD),9)
HARDWARE_VARIANT ?= Sanguino
MCU              ?= atmega644p

#Megatronics
else ifeq  ($(HARDWARE_MOTHERBOARD),70)
HARDWARE_VARIANT ?= arduino
MCU              ?= atmega2560

#Alpha OMCA board
else ifeq  ($(HARDWARE_MOTHERBOARD),90)
HARDWARE_VARIANT ?= SanguinoA
MCU              ?= atmega644

#Final OMCA board
else ifeq  ($(HARDWARE_MOTHERBOARD),91)
HARDWARE_VARIANT ?= Sanguino
MCU              ?= atmega644p

#Rambo
else ifeq  ($(HARDWARE_MOTHERBOARD),301)
HARDWARE_VARIANT ?= arduino
MCU              ?= atmega2560

endif

# Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
# if you are setting this to something other than 16MHz
# Set to 16Mhz if not yet set.
F_CPU ?= 16000000

# 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
ifeq ($(HARDWARE_VARIANT), arduino)
HARDWARE_DIR = $(ARDUINO_INSTALL_DIR)/hardware
else
ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
HARDWARE_DIR = ../ArduinoAddons/Arduino_1.x.x
else
HARDWARE_DIR = ../ArduinoAddons/Arduino_0.xx
endif
endif
HARDWARE_SRC = $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/cores/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 += $(BUILD_DIR)
VPATH += $(HARDWARE_SRC)
ifeq ($(HARDWARE_VARIANT), arduino)
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/SPI
else
VPATH += $(HARDWARE_DIR)/libraries/LiquidCrystal
VPATH += $(HARDWARE_DIR)/libraries/SPI
endif
ifeq ($(HARDWARE_VARIANT), arduino)
HARDWARE_SUB_VARIANT ?= mega
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/variants/$(HARDWARE_SUB_VARIANT)
else
HARDWARE_SUB_VARIANT ?= standard
VPATH += $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
endif
SRC = wiring.c \
   wiring_analog.c wiring_digital.c \
   wiring_pulse.c \
   wiring_shift.c WInterrupts.c
CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp   \
   MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp   \
   SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp      \
   stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \
   watchdog.cpp
CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp Servo.cpp Tone.cpp

#Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version
ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
CXXSRC += main.cpp
else
SRC += pins_arduino.c main.c
endif

FORMAT = ihex

# Name of this Makefile (used for "make depend").
MAKEFILE = Makefile

# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
DEBUG = stabs

OPT = s

DEFINES ?=

# Program settings
CC = $(AVR_TOOLS_PATH)avr-gcc
CXX = $(AVR_TOOLS_PATH)avr-g++
OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
AR  = $(AVR_TOOLS_PATH)avr-ar
SIZE = $(AVR_TOOLS_PATH)avr-size
NM = $(AVR_TOOLS_PATH)avr-nm
AVRDUDE = avrdude
REMOVE = rm -f
MV = mv -f

# Place -D or -U options here
CDEFS    = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
CXXDEFS  = $(CDEFS)

ifeq ($(HARDWARE_VARIANT), Teensy)
CDEFS  += -DUSB_SERIAL
SRC    += usb.c pins_teensy.c
CXXSRC += usb_api.cpp
endif

# Add all the source directories as include directories too
CINCS = ${addprefix -I ,${VPATH}}
CXXINCS = ${addprefix -I ,${VPATH}}

# Compiler flag to set the C Standard level.
# c89   - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99   - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
#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=$(ARDUINO_VERSION)
ifneq ($(HARDWARE_MOTHERBOARD),)
CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
endif
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)

CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
CXXFLAGS :=         $(CDEFS) $(CINCS) -O$(OPT) -Wall    $(CEXTRA) $(CTUNING)
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
LDFLAGS = -lm


# Programming support using avrdude. Settings and variables.
AVRDUDE_PORT = $(UPLOAD_PORT)
AVRDUDE_WRITE_FLASH = -U flash:w:$(BUILD_DIR)/$(TARGET).hex:i
AVRDUDE_FLAGS = -D -C $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \
   -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
   -b $(UPLOAD_RATE)

# Define all object files.
OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}}

# Define all listing files.
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) $(CXXFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)

# set V=1 (eg, "make V=1") to print the full commands etc.
ifneq ($V,1)
 Pecho=@echo
 P=@
else
 Pecho=@:
 P=
endif

# Default target.
all: sizeafter

build: $(BUILD_DIR) elf hex

# Creates the object directory
$(BUILD_DIR):
   $P mkdir -p $(BUILD_DIR)

elf: $(BUILD_DIR)/$(TARGET).elf
hex: $(BUILD_DIR)/$(TARGET).hex
eep: $(BUILD_DIR)/$(TARGET).eep
lss: $(BUILD_DIR)/$(TARGET).lss
sym: $(BUILD_DIR)/$(TARGET).sym

# Program the device.
# Do not try to reset an arduino if it's not one
upload: $(BUILD_DIR)/$(TARGET).hex
ifeq (${AVRDUDE_PROGRAMMER}, arduino)
   stty hup < $(UPLOAD_PORT); true
endif
   $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
ifeq (${AVRDUDE_PROGRAMMER}, arduino)
   stty -hup < $(UPLOAD_PORT); true
endif

   # Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
          $(SIZE)  $(BUILD_DIR)/$(TARGET).elf
sizebefore:
   $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi

sizeafter: build
   $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi


# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
   --change-section-address .data-0x800000 \
   --change-section-address .bss-0x800000 \
   --change-section-address .noinit-0x800000 \
   --change-section-address .eeprom-0x810000


coff: $(BUILD_DIR)/$(TARGET).elf
   $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof


extcoff: $(TARGET).elf
   $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof


.SUFFIXES: .elf .hex .eep .lss .sym
.PRECIOUS: .o

.elf.hex:
   $(Pecho) "  COPY  $@"
   $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@

.elf.eep:
   -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
      --change-section-lma .eeprom=0 -O $(FORMAT) $< $@

# Create extended listing file from ELF output file.
.elf.lss:
   $(OBJDUMP) -h -S $< > $@

# Create a symbol table from ELF output file.
.elf.sym:
   $(NM) -n $< > $@

   # Link: create ELF output file from library.
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
   $(Pecho) "  CXX   $@"
   $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS)

$(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
   $(Pecho) "  CC    $<"
   $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
   $(Pecho) "  CXX   $<"
   $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@

$(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
   $(Pecho) "  CXX   $<"
   $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@


# Target: clean project.
clean:
   $(Pecho) "  RM    $(BUILD_DIR)/*"
   $P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \
      $(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \
      $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
   $(Pecho) "  RMDIR $(BUILD_DIR)/"
   $P rm -rf $(BUILD_DIR)


.PHONY:   all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter

# Automaticaly include the dependency files created by gcc
-include ${wildcard $(BUILD_DIR)/*.d}


However when I open the same exact file in Arduino IDE I'm getting:

Code: Select all
/* -*- c++ -*- */

/*
    Reprap firmware based on Sprinter and grbl.
 Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 This firmware is a mashup between Sprinter and grbl.
  (https://github.com/kliment/Sprinter)
  (https://github.com/simen/grbl/tree)
 
 It has preliminary support for Matthew Roberts advance algorithm
    http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
 */

/* All the implementation is done in *.cpp files to get better compatibility with avr-gcc without the Arduino IDE */
/* Use this file to help the Arduino IDE find which Arduino libraries are needed and to keep documentation on GCode */

#include "Configuration.h"
#include "pins.h"

#ifdef ULTRA_LCD
  #if defined(LCD_I2C_TYPE_PCF8575)
    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
  #elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)
    #include <Wire.h>
    #include <LiquidTWI2.h>
  #elif defined(DOGLCD)
    #include <U8glib.h> // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/)
  #else
    #include <LiquidCrystal.h> // library for character LCD
  #endif
#endif

#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
#include <SPI.h>
#endif


Reminds me why I retired from the software industry. If you really want to fritter away time and raise your blood pressure, try debugging software issues.
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2

Can't get Marlin-Unified v2 to compile with Arduino 0022

Sponsor

Sponsor
 

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby PxT » 2014-Feb-Mon-19-Feb

jeromedayton wrote: The Arduino IDE leaves a lot to be desired in terms of being able to browse code.



When I open it directly via Word



:shock:

I mean really, don't try to use Word for anything useful related to this… Word has its uses, but editing source code is by no means one of them.

Anyway, to fix the errors you are seeing in Arduino you most likely just need to select the correct board type from the menus. That will make sure that all the right libraries are included. Make sure you have installed Teensyduino if you haven't done so already. RJ has put up some good instructions for Windows users at http://www.printrbottalk.com/wiki/index ... wareUpdate


I'm trying to get this to compile so I can then load it into Eclipse to actually look at code.


There's no need to compile anything if all you want to do is look at the code. Eclipse or any IDE of your choice should be able to open up the source code just fine. Arduino works just as well as most even if it is a bit clunky some times. The tabs across the top represent your individual files, there's not really much to it other than that.
  • 0

User avatar
PxT
Print complete...
 
Posts: 1339
Joined: 2011-Dec-Mon-16-Dec
Location: Sacramento, CA
Reputation: 97

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Mon-20-Feb

I mean really, don't try to use Word for anything useful related to this… Word has its uses, but editing source code is by no means one of them.


I mistyped, that should have been wordpad which I find does a much better job of working with the various newline/carriage return combinations that Notepad.

Anyway, to fix the errors you are seeing in Arduino you most likely just need to select the correct board type from the menus. That will make sure that all the right libraries are included. Make sure you have installed Teensyduino if you haven't done so already. RJ has put up some good instructions for Windows users at http://www.printrbottalk.com/wiki/index ... wareUpdate


I've actually been working from those directions. That's why the questions.

There's no need to compile anything if all you want to do is look at the code. Eclipse or any IDE of your choice should be able to open up the source code just fine.


What I've read has said that IF you want the Eclipse IDE to be readily find references and defnitions of functions, variables, etc. then it must be compile-able because this implies that all the links (uses of headers, etc.) are there and properly constructed.

I'm not a newbie to software development having done it for 4 decades. I just find the Arduino dev environment to be incredibly primitive and trying. No search across files. No showing you which file you are currently in if you're tab is not in the current window. No ability to find all references to a function/variable. No ability to see what portions of code are currently compileable because compiler variables/directives have been defined. Etc. Thus my desire to make it Eclipse friendly.
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Mon-21-Feb

One mystery solved. Apparently the Marlin.pde file IS the makefile that Arduino uses and any attempt to open the actual Makefile in that directory redirects you to this file.
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby RetireeJay » 2014-Feb-Mon-21-Feb

Yeah, when I went searching for the software identification string that prints out when Repetier connects, I had to search file by file, using the Control-Alt-arrow key combination to move between files. When I finally found it, I discovered that there was no way to know WHAT file I was looking at! The list of tabs across the top had been used up and there was no tab highlighted. And there is no standardization within the files to say what the name of the file is on the first line.

But with enough sleuthing, I finally figured out it's in "Language.h" :)
  • 0

Printrbot Plus operational January 2013
Brass threaded rods (5/16" X 18) & nuts for Z axis
GT2 belts & pulleys
Cable chain to reduce probability of fatigue failure in wires
E3D V5 Hot End, 0.4mm nozzle, also 0.8 and 0.25 in use occasionally
PB fan mount + 40mm fan -- using printed mount adapter, not the E3D supplied fan
Injection molded extruder gears
Optical Z "endstop" (custom designed and built)
Have used many pounds of T-Glase filament. Now also doing some work with Ninjaflex SemiFlex
Print on glass with Scotch Craft Stick or other glue stick
"My next printer is..." Prusa i3 MK3, upgraded to MK3S
User avatar
RetireeJay
My next printer is...
 
Posts: 5003
Joined: 2013-Jan-Wed-13-Jan
Location: Greenville, SC
Reputation: 498

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby PxT » 2014-Feb-Tue-01-Feb

jeromedayton wrote:One mystery solved. Apparently the Marlin.pde file IS the makefile that Arduino uses and any attempt to open the actual Makefile in that directory redirects you to this file.


That's not quite accurate. The pde file is the "sketch" file (in Arduino terms), it's not equivalent to a Makefile because it is really just C++ code. The Arduino IDE automatically adds some code to the sketch behind the scenes when you hit the compile button. That's why you won't find a main() function or some of the other standard stuff you would expect in C / C++ code.

The Makefile is not C / C++, it has its own syntax (which the make binary understands). It is only used if you are compiling from the command-line without the Arduino GUI and is used to tell the command-line compilers how to build the binary. Opening it with the Arduino IDE is usually useless which is (probably, I'm guessing here) why it redirects you to the .pde file.
  • 0

User avatar
PxT
Print complete...
 
Posts: 1339
Joined: 2011-Dec-Mon-16-Dec
Location: Sacramento, CA
Reputation: 97

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Tue-14-Feb

Woohoo success. I followed all of RetireeJay's directions for "How to install the 1.05 Arduino in Four Steps", restarted Arduino, selected Tools / Boards / "[usbtinyisp]Teensylu/Printrboard", selected Verify and it successfully compiled. I hadn't seen that choice for boards before and when I had compiled before, it always prompted me to set the board selection to "Teensys++ 2.0". So RJ you should add this to the firmware directions.

Now to see if I can get Eclipse to successfully load the project.
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby RetireeJay » 2014-Feb-Tue-16-Feb

jeromedayton wrote:So RJ you should add this to the firmware directions.


Thanks Jerome. I've added instructions to select a board that mentions "Printrboard" in the name. I've also added a bit about the way that Arduino and Teensyduino want to do the flashing for you but you need to use FLIP.
  • 0

Printrbot Plus operational January 2013
Brass threaded rods (5/16" X 18) & nuts for Z axis
GT2 belts & pulleys
Cable chain to reduce probability of fatigue failure in wires
E3D V5 Hot End, 0.4mm nozzle, also 0.8 and 0.25 in use occasionally
PB fan mount + 40mm fan -- using printed mount adapter, not the E3D supplied fan
Injection molded extruder gears
Optical Z "endstop" (custom designed and built)
Have used many pounds of T-Glase filament. Now also doing some work with Ninjaflex SemiFlex
Print on glass with Scotch Craft Stick or other glue stick
"My next printer is..." Prusa i3 MK3, upgraded to MK3S
User avatar
RetireeJay
My next printer is...
 
Posts: 5003
Joined: 2013-Jan-Wed-13-Jan
Location: Greenville, SC
Reputation: 498

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Tue-16-Feb

Still trying to get Eclipse to work with the "Official" printrbot release from here:

https://github.com/Printrbot/Marlin/rel ... unified-v2

And the 1.0.5 version of Arduino IDE.

To get Eclipse to work, it needs to point to a Makefile that works. When I try to use the native tools that come with Arduino for the make I'm getting the following error:

Code: Select all
C:\Users\Dayton\Dropbox\3dPrinting\Software\MarlinUnifiedV2\Marlin>make --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-pc-mingw32
Reading makefiles...
Updating goal targets....
 File `all' does not exist.
   File `sizeafter' does not exist.
     File `build' does not exist.
       File `elf' does not exist.
         File `applet/Marlin.elf' does not exist.
           File `applet/wiring.o' does not exist.
          Must remake target `applet/wiring.o'.
make: *** No rule to make target `applet/wiring.o', needed by `applet/Marlin.elf'.  Stop.


Searching the web for the last error seems to indicate that it there are extra characters in the Makefile for the ARDUINO_INSTALL_DIR or the AVR_TOOLS_PATH lines but I've scrubbed them repeatedly.

Code: Select all
# This defined the board you are compiling for (see Configuration.h for the options)
HARDWARE_MOTHERBOARD ?= 81

# Arduino source install directory, and version number
ARDUINO_INSTALL_DIR ?= C:/Arduino
ARDUINO_VERSION ?= 105   

# You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
AVR_TOOLS_PATH ?= C:/Arduino/hardware/tools/avr/bin/

#Programmer configuration
UPLOAD_RATE        ?= 250000
AVRDUDE_PROGRAMMER ?= arduino
UPLOAD_PORT        ?= /dev/arduino

#Directory used to build files in, contains all the build files, from object files to the final hex file.
BUILD_DIR          ?= applet


I only got this far after renaming several directories that either had spaces or "()" in them as make and/or arduino doesn't like directory/filenames with those characters.

Anyone have any ideas on how to get the make to work?
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby PxT » 2014-Feb-Tue-19-Feb

What you're asking is non-trivial to accomplish but you can read here for a starting point: http://playground.arduino.cc/Code/Eclipse
  • 0

User avatar
PxT
Print complete...
 
Posts: 1339
Joined: 2011-Dec-Mon-16-Dec
Location: Sacramento, CA
Reputation: 97

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Tue-20-Feb

PxT-

Thanks for the pointer. The plugin adds two things, one of which is needed. First it allows for an "Upload to Target Device" from the menu, which we can't use since we have to use Flip. But it DOES add the Arduino tool chain which we need to create an executable.

However it still needs the Makefile in the

https://github.com/Printrbot/Marlin/rel ... unified-v2

release to actually build with the command line Arduino toolset, which it doesn't do at present.

But I now have enough of Eclipse working that I can actually wander around the code and see stuff. I just can't compile. I'll have to make any changes I want in Eclipse and then go back to the Arduino IDE to actually get a flashable executable.

My motivation for this is my Printrbot Simple has been in-operable for almost 3 weeks now, with the dreaded: "Extruder switched off. MINTEMP triggered !" message and I can find no good cause for it. So I'm about to add some debug messages to that section of the code so I can see more precisely what is going on.
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby PxT » 2014-Feb-Wed-14-Feb

It looks like the Makefile needs a couple of tweaks to work correctly with the at90usb1286 / Teensy chip variants that the Printrbot code is configured for.

Try this Makefile: https://gist.github.com/PxT/4b9c9809407 ... a/Makefile
Modify the ARDUINO_INSTALL_DIR and AVR_TOOLS_PATH variables to match your setup, then see if you can run make.

That one works for me with Arduino 1.05 and the default Printrbot fork of Marlin. Please let me know if it works and I will see about getting the change merged back to the Printrbot-official source tree.
  • 0

User avatar
PxT
Print complete...
 
Posts: 1339
Joined: 2011-Dec-Mon-16-Dec
Location: Sacramento, CA
Reputation: 97

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Wed-15-Feb

While I can't compile in Eclipse, I've got enough of it working that I could wander around and find the section of code in temperature.cpp that was reporting the MinTemp error and add some debug messages:

Code: Select all
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
    if(current_temperature_raw[0] >= minttemp_raw[0]) {
#else
    if(current_temperature_raw[0] <= minttemp_raw[0]) {
#endif
          SERIAL_PROTOCOLPGM("MinTemp Exception for Heater 0: Current:");
            SERIAL_PROTOCOL_F(analog2temp(current_temperature_raw[0], 0),1);
            SERIAL_PROTOCOLPGM(" Target:");
            SERIAL_PROTOCOL_F(target_temperature[0],1);
            SERIAL_PROTOCOLPGM(" Min Temp:");
            SERIAL_PROTOCOL_F(analog2temp(minttemp_raw[0], 0),1);
            SERIAL_PROTOCOLPGM(" Power:");
            SERIAL_PROTOCOL(getHeaterPower(0));

            SERIAL_PROTOCOLLN("");

        min_temp_error(0);
    }


Which produced this in my output:

Code: Select all
11:43:06.290 : N57 G1 X91.269 Y6.936 E54.7832 F1080 *47
11:43:06.581 : MinTemp Exception for Heater 0: Current:0.0 Target:195 Min Temp:5.1 Power:127
11:43:06.584 : Error:0
11:43:06.584 : : Extruder switched off. MINTEMP triggered !
11:43:06.610 : Error:Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)


Interesting to note that the min temp is actually defined in two places:

Code: Select all
Configuration.h: #define HEATER_0_MINTEMP 5
thermistortables.h: #  define HEATER_0_RAW_LO_TEMP 16383


The two files have to be kept in synch if you want to change MinTemp. All in all I'm disappointed but not suprised by the quality of the code particularly since it has had so many hands in it.

I initially refused to believe it was a thermistor problem as the Repetier-Host was NOT reporting 0 Celsius but it must be dropping messages. So I am in fact experiencing a faulty thermistor connection somewhere. Now I know how to proceed to fix my Simple.
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2

Re: Can't get Marlin-Unified v2 to compile with Arduino 0022

Postby jeromedayton » 2014-Feb-Wed-15-Feb

PxT wrote:It looks like the Makefile needs a couple of tweaks to work correctly with the at90usb1286 / Teensy chip variants that the Printrbot code is configured for.

Try this Makefile: https://gist.github.com/PxT/4b9c9809407 ... a/Makefile
Modify the ARDUINO_INSTALL_DIR and AVR_TOOLS_PATH variables to match your setup, then see if you can run make.

That one works for me with Arduino 1.05 and the default Printrbot fork of Marlin. Please let me know if it works and I will see about getting the change merged back to the Printrbot-official source tree.


Pxt-

I made the following changes to the above version of Makefile to accomodate Windows:

Code: Select all
# Arduino source install directory, and version number
ARDUINO_INSTALL_DIR  ?= C:/Arduino
ARDUINO_VERSION      ?= 105

# You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
AVR_TOOLS_PATH ?= C:/Arduino/hardware/tools/avr/bin/


And the command line Arduino make worked!!!!

Still can't get eclipse to compile though. It doesn't like things like:

Code: Select all
 while( MYSERIAL.available() > 0  && buflen < BUFSIZE) {

Description   Resource   Path   Location   Type
Method 'available' could not be resolved   Marlin_main.cpp   /Marlin   line 486   Semantic Error



I tried adding the __cxa_pure_virtual function but that didn't help. This is not a high priority item for me as I can always get Arduino to compile it for me now.

Thanks for your help!!!
  • 0

Jerome
Retired Software Developer
Printrbot Simple operational since Xmas 2013
Printrbot Jr v 2 with alu extruder March 2014
User avatar
jeromedayton
Waiting for extruder temp...
 
Posts: 82
Joined: 2014-Jan-Fri-15-Jan
Reputation: 2


Return to Troubleshooting talk

Who is online

Users browsing this forum: No registered users and 2 guests

cron