Welcome! Log In Create A New Profile

Advanced

Issues compiling Marlin

Posted by jpff 
Issues compiling Marlin
March 10, 2025 03:30AM
Hi!

I'm having trouble compiling Marlin for Teensy 4.1 board with TMC2209 drivers, BLTouch sensor and DGUS_LCD_UI_RELOADED LCD enabled. I've tried the bugfix version however other new errors pop up while compiling! In both compilations I use a clean installation of platformio (i.e. I've deleted the .platformio folder from my user folder and reinstalled in each compilation for both production and bugfix branches).

When compiling for Marlin 2.1.2.5 which is the version I want to use I get these errors:

In file included from Marlin\src\gcode\feature\runout\../../../feature/../module/stepper/../../feature/../lcd/../module/settings.h:31:0,
                 from Marlin\src\gcode\feature\runout\../../../feature/../module/stepper/../../feature/../lcd/marlinui.h:31,
                 from Marlin\src\gcode\feature\runout\../../../feature/../module/stepper/../../feature/tmc_util.h:25,
                 from Marlin\src\gcode\feature\runout\../../../feature/../module/stepper/trinamic.h:35,
                 from Marlin\src\gcode\feature\runout\../../../feature/../module/stepper/indirection.h:77,
                 from Marlin\src\gcode\feature\runout\../../../feature/../module/stepper.h:47,
                 from Marlin\src\gcode\feature\runout\../../../feature/runout.h:31,
                 from Marlin\src\gcode\feature\runout\M412.cpp:28:
Marlin\src\gcode\feature\runout\../../../feature/../module/stepper/../../feature/../lcd/../module/../HAL/shared/eeprom_api.h:27:30: fatal error: ../../libs/crc16.h: No such file or directory
compilation terminated.
*** [.pio\build\teensy41\src\src\gcode\feature\runout\M412.cpp.o] Error 1
Marlin\src\inc\Warnings.cpp:86:6: warning: #warning "Note: Auto-assigned LCD_SERIAL_PORT. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" [-Wcpp]
     #warning "Note: Auto-assigned LCD_SERIAL_PORT. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)"
      ^
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp: In static member function 'static void DGUSDisplay::Init()':
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp:58:3: error: 'LCD_SERIAL' was not declared in this scope
   LCD_SERIAL.begin(LCD_BAUDRATE);
   ^
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp: In static member function 'static void DGUSDisplay::Read(uint16_t, uint8_t)':
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp:66:3: error: 'LCD_SERIAL' was not declared in this scope
   LCD_SERIAL.write(size);
   ^
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp: In static member function 'static void DGUSDisplay::Write(uint16_t, const void*, uint8_t)':
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp:77:5: error: 'LCD_SERIAL' was not declared in this scope
     LCD_SERIAL.write(*data++);
     ^
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp: In static member function 'static void DGUSDisplay::WriteString(uint16_t, const void*, uint8_t, bool, bool, bool)':
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp:111:5: error: 'LCD_SERIAL' was not declared in this scope
     LCD_SERIAL.write(' ');
     ^
Marlin\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp:114:5: error: 'LCD_SERIAL' was not declared in this scope
     LCD_SERIAL.write(*data++);
     ^
compilation terminated due to -fmax-errors=5.
*** [.pio\build\teensy41\src\src\lcd\extui\dgus_reloaded\DGUSDisplay.cpp.o] Error 1

I don't know why the LCD_SERIAL error, is this because Platformio is not automatically downloading the required libraries, or is it because more than one library is being downloaded and trying to link against?


And when compiling for the latest bugfix I get these:

In file included from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-1-axes.h:44:0,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/Conditionals-1-axes.h:32,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre.h:27,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-5-post.h:24,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-6-type.h:24,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfig.h:28,
                 from buildroot/share/PlatformIO/scripts/common-dependencies.h:29:
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration.h:284:11: error: missing binary operator before token "("
 #if EITHER(PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration.h:988:11: error: missing binary operator before token "("
 #if EITHER(MORGAN_SCARA, MP_SCARA)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration.h:1787:11: error: missing binary operator before token "("
 #if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration.h:1991:11: error: missing binary operator before token "("
 #if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
           ^
In file included from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-1-axes.h:44:0,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/Conditionals-1-axes.h:32,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre.h:27,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-5-post.h:24,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-6-type.h:24,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfig.h:28,
                 from buildroot/share/PlatformIO/scripts/common-dependencies.h:29:
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration.h:3039:11: error: missing binary operator before token "("
 #if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration.h:3327:11: error: missing binary operator before token "("
 #if EITHER(RGB_LED, RGBW_LED)
           ^
In file included from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-4-adv.h:33:0,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/Conditionals-4-adv.h:32,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre.h:30,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-5-post.h:24,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfigPre-6-type.h:24,
                 from buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/MarlinConfig.h:28,
                 from buildroot/share/PlatformIO/scripts/common-dependencies.h:29:
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:303:11: error: missing binary operator before token "("
   #if BOTH(ADAPTIVE_FAN_SLOWING, PIDTEMP)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:1086:11: error: missing binary operator before token "("
 #if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:1322:11: error: missing binary operator before token "("
 #if EITHER(DIGIPOT_MCP4018, DIGIPOT_MCP4451)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:1379:28: error: missing binary operator before token "("
 #if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI)
                            ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:1436:11: error: missing binary operator before token "("
 #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:1500:26: error: missing binary operator before token "("
 #if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
                          ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:2148:11: error: missing binary operator before token "("
 #if EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:2183:11: error: missing binary operator before token "("
 #if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:2191:9: error: missing binary operator before token "("
 #if BOTH(AUTO_BED_LEVELING_UBL, EEPROM_SETTINGS)
         ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:2305:11: error: missing binary operator before token "("
 #if EITHER(ARC_SUPPORT, BEZIER_CURVE_SUPPORT)
           ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:2393:9: error: missing binary operator before token "("
 #if BOTH(SDSUPPORT, DIRECT_STEPPING)
         ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:3173:13: error: missing binary operator before token "("
   #if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
             ^
buildroot/share/PlatformIO/scripts/../../../../Marlin/src/inc/../../Configuration_adv.h:3335:11: error: missing binary operator before token "("
 #if EITHER(SPINDLE_FEATURE, LASER_FEATURE)
           ^
UnicodeEncodeError: 'charmap' codec can't encode character '\u016f' in position 1650: character maps to :
  File "C:\Users\User\.platformio\penv\Lib\site-packages\platformio\builder\main.py", line 167:
    env.SConscript(env.GetExtraScripts("pre"), exports="env")
  File "C:\Users\User\.platformio\packages\tool-scons\scons-local-4.8.1\SCons\Script\SConscript.py", line 620:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\User\.platformio\packages\tool-scons\scons-local-4.8.1\SCons\Script\SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "F:\Documents\Projects\3D Printer Board\Marlin Firmware\Bugfix\Marlin-bugfix-2.1.x\buildroot\share\PlatformIO\scripts\preflight-checks.py", line 162:
    sanity_check_target()
  File "F:\Documents\Projects\3D Printer Board\Marlin Firmware\Bugfix\Marlin-bugfix-2.1.x\buildroot\share\PlatformIO\scripts\preflight-checks.py", line 82:
    file.write(modified_text)
  File "C:\Users\User\.platformio\python3\Lib\encodings\cp1252.py", line 19:
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]


I've attached my platformio.ini, Configuration.h, Configuration_adv.h and pins_TEENSY41.h which are all the files I believe I've changed thus far!

Thank you kindly in advance for any help!
Attachments:
open | download - platformio.ini (3.9 KB)
open | download - Configuration.h (126.5 KB)
open | download - Configuration_adv.h (173.3 KB)
open | download - pins_TEENSY41.h (5.5 KB)
Re: Issues compiling Marlin
March 10, 2025 05:24AM
using the provided files.

First error I see is

#error "DGUS_LEVEL_GRID_SIZE is incompatible with current mesh."  this need to be 5x5 not 10x10, a requirement of this display
Change #define GRID_MAX_POINTS_X to 5

Second error

Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp:58:3: error: 'LCD_SERIAL' was not declared in this scope

This is a serial display. you need to tell Marlin where it is attached.

Add this to your Configuration.h
#define LCD_SERIAL_PORT 5 // (as a guess from the updated pins file)

Next problem is a larger one, no one has been crazy enough to add a serial lcd support to teensy41 as of yet.

add the following to Marlin/src/HAL/TEENSY40_41/HAL.h lline 114
#ifdef LCD_SERIAL_PORT
  //#if !WITHIN(LCD_SERIAL_PORT, 0, 3)
  //  #error "LCD_SERIAL_PORT must be from 0 to 3."
  //#endif
  DECLARE_SERIAL(LCD_SERIAL_PORT);
  #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
  #if HAS_DGUS_LCD
    #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available()
  #endif
#endif

add this to Marlin/src/HAL/TEENSY40_41/HAL.cpp line 55
#ifdef LCD_SERIAL_PORT
  //#if WITHIN(SERIAL_PORT_3, 0, 8) 
    IMPLEMENT_SERIAL(LCD_SERIAL_PORT);
  //#endif
#endif

next error

Marlin/src/module/temperature.cpp:307:33: error: static assertion failed: HEATER_0_MAXTEMP (260) is too high for thermistor_332.h with HOTEND_OVERSHOOT=15

You have set #define TEMP_SENSOR_0 332, the highest temperature this thermistor can read is 150c (highest temperature entry in the table) , Subtracting HOTEND_OVERSHOOT = 135. So the highest temperature you can set HEATER_0_MAXTEMP to is 135
Very few thermistor can read that high a temperature, they break down as such high temperatures

For now lower HEATER_0_MAXTEMP to a valid value 135 till you work out what you actually have/want/need

This builds, but I have no idea if it will do anything useful. But it is a starting point.

Here are all the updated files

platformio.ini (no changes to what you supplied)
Configuration.h
Configuration_adv.h (no changes)
HAL.h modified Marlin/src/HAL/TEENSY40_41/HAL.h
HAL.cpp modified Marlin/src/HAL/TEENSY40_41/HAL.cpp
pins_TEENSY41.h (no changes)

Edited 6 time(s). Last edit at 03/10/2025 05:36AM by Dust.
Re: Issues compiling Marlin
March 10, 2025 04:07PM
Hi Dust!

Thank you for your help!

Quote
Dust
Change #define GRID_MAX_POINTS_X to 5

I've changed #define GRID_MAX_POINTS_X to 5 together with #define DGUS_LEVEL_GRID_SIZE from the 100 that I had previously defined in DGUS_Addr.h to 25 now.

Quote
Dust
Add this to your Configuration.h
#define LCD_SERIAL_PORT 5 // (as a guess from the updated pins file)

This one I've set in Conditionals_adv.h

#if LCD_IS_SERIAL_HOST && !defined(LCD_SERIAL_PORT)
  #if MB(MKS_MONSTER8_V1, BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_MINI_E3_V3_0, BTT_SKR_MINI_E3_V3_0_1, BTT_SKR_E3_TURBO, BTT_OCTOPUS_V1_1, BTT_SKR_V3_0, BTT_SKR_V3_0_EZ)
    #define LCD_SERIAL_PORT 1
  #elif MB(CREALITY_V24S1_301, CREALITY_V24S1_301F4, CREALITY_F401RE, CREALITY_V423, MKS_ROBIN)
    #define LCD_SERIAL_PORT 2 // Creality Ender3S1, MKS Robin
  #else
    #define LCD_SERIAL_PORT 5 // Other boards
  #endif
  #ifdef LCD_SERIAL_PORT
    #define AUTO_ASSIGNED_LCD_SERIAL 5
  #endif
#endif

Hopefully I did that one right! Although it still gave me an error when I compiled, now I notice this conditional is indeed grayed out in VSCode. I've added #define LCD_SERIAL_PORT 5 straight in Configuration.h, error seems to be gone now! Thanks!

Quote
Dust
Next problem is a larger one, no one has been crazy enough to add a serial lcd support to teensy41 as of yet.

My printer has an LCD, it's an CR-200B. I think I damaged the control board when I connected a BLTouch sensor, the sensor did not come with the printer, it's an added sensor as I was simply tired of manually levelling the bed. I accidently swapped +5V and GND when crimping/assembling the XH connector to attach to the board and that well known smell of burnt electronics began emanating from inside the printer. Not only that I also flashed Creality's incredibly buggy version of Marlin to support a BLTouch sensor in this printer, and now my printer's display neither works, nor can I use the printer with octoprint since it throws an error just after probing the bed with the sensor, haha. Creality doesn't provide the source code for this printer, which they should, since Marlin is licensed as copy left GPL! So I decided to design my own control board from scratch, I have a lot of parts around I can build the board with plus some extra purchased ones already.

Quote
Dust
You have set #define TEMP_SENSOR_0 332, the highest temperature this thermistor can read is 150c (highest temperature entry in the table) , Subtracting HOTEND_OVERSHOOT = 135. So the highest temperature you can set HEATER_0_MAXTEMP to is 135
Very few thermistor can read that high a temperature, they break down as such high temperatures

I've changed this back to 1 (100kΩ EPCOS) in Configuration.h:

#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_6 0
#define TEMP_SENSOR_7 0
#define TEMP_SENSOR_BED 1
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
#define TEMP_SENSOR_COOLER 0
#define TEMP_SENSOR_BOARD 0
#define TEMP_SENSOR_REDUNDANT 0

The CR-200B nozzle temperature is <= 260 deg. Celcius. I only changed it to 332 because I read in line 461 in Configuration.h the following: 100kΩ Same as #1, but 3.3V scaled for DUE . I thought, since the teensy works with 3.3V then it would be suitable for it, but now that I think about it that doesn't make much sense, since an ADC peripheral from an MCU that operates at 3.3V will read 3.3V as the max value of 1023 if Marlin configures the ADC peripheral as 10bit or 4095 if 12bit.

Is #define TEMP_SENSOR_0 1 and #define TEMP_SENSOR_BED 1 appropriate in this case?

I've also compiled with the changes you suggested with the exception of the thermistor one as I've changed that one back to the default 1, and now Marlin compiles with no errors! Thanks a bunch, Dust!

I will be taking the display off my printer to test it with the teensy, I'll breadboard all the components, teensy, stepper drivers, stepper motors, 100K thermistors, 3.3 to 5V level converters, mosfets + mosfet gate drivers, etc, and do a test run to see whether everything works as expected before moving onto the actual board design in either kicad or Eagle.

Thanks!
Re: Issues compiling Marlin
March 10, 2025 11:38PM
I have created a PR to add LCD_SERIAL_PORT support into bugfix 2.1.x [github.com] for the TEENSY40_41
Re: Issues compiling Marlin
March 12, 2025 11:55PM
The code changes have been merged into marlin bugfix, so bugfix and newer marlins going forward now have the code to support LCD_SERIAL_PORT on TEENSY
Sorry, only registered users may post in this forum.

Click here to login