Running Marlin Firmware on a Printrboard

As of this writing, the official version of Marlin firmware from github does not yet work with Printrboard.  Printrboard is a fork of Teensylu, designed by the folks at Printrbot. Printrboard isn’t yet available for purchase, but since the design is open source, anyone can download it and get the PCB’s manufactured themselves. Sprinter is currently the only RepRap firmware works with Teensylu and Printrboard out of the box.  I am now successfuly running Marlin on my Printrboard.  Below is a video of Printrboard virtually printing a Printrbot with Marlin:

Last month, I submitted an issue with ErikZalm to get the compile errors fixed when compiling Marlin for Teensylu.  The main branch of Marlin now compiles for Teensylu by setting MOTHERBOARD = 8.  Unfortunately, this build setting won’t work with Printrboard, because some of the pins are different.  Also, there is a kill function that Marlin calls if it detects certain things like a shorted thermistor, etc… but it’s not able to send the error messages back to the host, so it looks like your board is just dead.
I think Erik is too busy right now getting V1 out the door to deal with making fixes for a couple of not so popular boards, so I’ve forked Marlin on github with my fixes for making it behave nicely with Teensylu and Printrboard.  You can download it here:  lincomatic/Marlin.
——————————–
For Firmware Hackers Only
For those who want to know what’s special about my branch of Marlin, it has to do with the mappings of the I/O pins.  The code in Marlin has two different ways to access digital I/O pins: 1) the Arduino digitalRead/Write() functions 2) fastio – there are macros and pin assignments in fastio.h.  In ErikZalm’s Marlin branch, the pin numbers are different between Arduino and fastio functions, which leads to confusion and bugs.  What I have done is use the digital pin definitions in Teensyduino’s core_pins.h and updated the pins in fastio.h to match them.  This way, a call to digitalRead(28) is equivalent to _READ(28).
EXECEPTIONS:
  1. in pins.h, analog pins use ADC numbering instead of digital pin numbering.  Therefore, even though B_THERM -> F0/ADC0 and E_THERM -> F1/ADC1, we are using them as ADC pins, so B_THERM=0 (ADC0) and E_THERM=1 (ADC1).
  2. Printrboard uses some pins that aren’t supported by Teensyduino, since they aren’t exposed in the Teensy hardware.  Therefore, those pins aren’t listed in core_pins.h.  I have added them to fastio.h, so they are accessible only with fastio macros.  They are digital pins 46 and 47 see the “//– Begin not supported by Teensyduino
    ” section of fastio.h

EXAMPLES:

XSTEP = physical pin 51. Looking at the AT90USB1286 spec sheet, pin 51 = PA0 (AD0)
in core_pins.h, #define PIN_A0 28
in fastio.h,

#define DIO28_PIN PINA0
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
#define DIO28_PWM NULL
#define DIO28_DDR DDRA

so in pins.h, X_STEP = 28

X_MIN = AT90USB1286 pin 9 = PE3
core_pins.h doesn’t have a definition for PIN_E3, because the pin isn’t accessible in Teensy++, so we can’t talk to that pin at all with the Arduino functions.  However, it’s in fastio.h:

//– Begin not supported by Teensyduino
//– don’t use Arduino functions on these pins pinMode/digitalWrite/etc
#define DIO47_PIN PINE3
#define DIO47_RPORT PINE
#define DIO47_WPORT PORTE
#define DIO47_PWM NULL
#define DIO47_DDR DDRE

so X_MIN = 47