Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] DWIN_CREALITY_LCD breaks MultiSerial #22299

Open
blazewicz opened this issue Jul 5, 2021 · 24 comments
Open

[BUG] DWIN_CREALITY_LCD breaks MultiSerial #22299

blazewicz opened this issue Jul 5, 2021 · 24 comments

Comments

@blazewicz
Copy link
Contributor

blazewicz commented Jul 5, 2021

Did you test the latest bugfix-2.0.x code?

Yes, and the problem still exists.

Bug Description

Compilation with multiple serial ports while having DWIN_CREALITY_LCD enabled results in a cascade of errors similar to this one:

Marlin/src/HAL/STM32F1/../../inc/../HAL/./STM32F1/../../core/serial_hook.h:225:68: error: request for member 'write' in '((MultiSerial<BaseSerial<MarlinSerial>, int, 0>*)this)->MultiSerial<BaseSerial<MarlinSerial>, int, 0>::serial1', which is of non-class type 'int'

It happens because SERIAL_CATCHALL is set here to an integer:

#define SERIAL_CATCHALL 0

And here it is expected to be a compatible Serial class instance:

#define _SERIAL_LEAF_2 SERIAL_CATCHALL

I guess a simple fix like one below would help (it does compile).

--- a/Marlin/src/core/serial.h
+++ b/Marlin/src/core/serial.h
@@ -90,7 +90,7 @@ extern uint8_t marlin_debug_flags;
   #define SERIAL_ASSERT(P)    if(multiSerial.portMask!=(P)){ debugger(); }
   // If we have a catchall, use that directly
   #ifdef SERIAL_CATCHALL
-    #define _SERIAL_LEAF_2 SERIAL_CATCHALL
+    #define _SERIAL_LEAF_2 MSERIAL(SERIAL_CATCHALL)
   #elif HAS_ETHERNET
     typedef ConditionalSerial<decltype(MYSERIAL2)> SerialLeafT2;  // We need to create an instance here
     extern SerialLeafT2 msSerial2

Yet I'm not sure of the function on SERIAL_CATCHALL and how it should be defined properly.

@thinkyhead it seems you added it in #17719, I can't find any other reference nor documentation.

I think it got broken in #21306, but I'm not sure if it worked before.

Bug Timeline

No response

Expected behavior

No response

Actual behavior

No response

Steps to Reproduce

No response

Version of Marlin Firmware

bugfix-2.0.x

Printer model

No response

Electronics

No response

Add-ons

No response

Your Slicer

No response

Host Software

No response

Additional information & file uploads

No response

@ellensp
Copy link
Contributor

ellensp commented Jul 5, 2021

Please attach your configuration files.

@blazewicz
Copy link
Contributor Author

blazewicz commented Jul 5, 2021

Any configuration with DWIN LCD and MultiSerial fails. It can be easily reproduced using Configurations/config/examples/Creality/Ender-3 V2 with SERIAL_PORT_2 enabled:

--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -123,7 +125,7 @@
  * Currently Ethernet (-2) is only supported on Teensy 4.1 boards.
  * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
  */
-//#define SERIAL_PORT_2 -1
+#define SERIAL_PORT_2 2

@ellensp
Copy link
Contributor

ellensp commented Jul 5, 2021

Yes I can reproduce the original error.. But your diff to fix it, I cant replicate a compile at all.

@blazewicz
Copy link
Contributor Author

With STM32F103RET6_creality env it fails because it can't find MSerial0 symbol, probably because Serial port 0 is not defined for this platform and SERIAL_CATCHAL is declared to be 0.

Marlin/src/HAL/STM32/../../inc/../HAL/./STM32/HAL.h:50:21: error: 'MSerial0' was not declared in this scope; did you mean 'MSerial10'?

It would compile if you changed:

--- a/Marlin/src/inc/Conditionals_LCD.h
+++ b/Marlin/src/inc/Conditionals_LCD.h
@@ -1076,7 +1076,7 @@
 #endif

 #if ENABLED(DWIN_CREALITY_LCD)
-  #define SERIAL_CATCHALL 0
+  #define SERIAL_CATCHALL 2
   #ifndef LCD_SERIAL_PORT
     #define LCD_SERIAL_PORT 3 // Creality 4.x board
   #endif

It is defined for STM32F103RET6_creality_maple's platform, but I don't know which port it represents.

I would suggest a fix, but I don't know what SERIAL_CATCHALL is.

@ellensp
Copy link
Contributor

ellensp commented Jul 24, 2021

Bump... with people using the DWIN_CREALITY_LCD on more and more hardware, this is becoming more of an issue

@Gaiadan
Copy link

Gaiadan commented Jul 24, 2021

Bump

env STM32F103RC_btt_maple

"request for member 'write' in '((MultiSerial<ForwardSerial<USBSerial>, int, 0>*)this)->MultiSerial<ForwardSerial<USBSerial>, int, 0>::serial1', which is of non-class type 'int'",
	"startLineNumber": 225,
	"startColumn": 68,
	"endLineNumber": 225,
	"endColumn": 68
}

if i disable serial port 2 it works but i want the second serial for my raspberry pi

@thinkyhead
Copy link
Member

Let me try to follow the bouncing ball and try to make sense of this.

This concept comes from #21336 by @X-Ryl669 and the value of SERIAL_CATCHALL gets assigned to _SERIAL_LEAF_2 which would otherwise be msSerial2 or MYSERIAL2. The value of _SERIAL_LEAF_2 is used in one of two ways:

// Hook Meatpack if it's enabled on the second leaf
#if ENABLED(MEATPACK_ON_SERIAL_PORT_2)
  typedef MeatpackSerial<decltype(_SERIAL_LEAF_2)> SerialLeafT2;
  extern SerialLeafT2 mpSerial2;
  #define SERIAL_LEAF_2 mpSerial2
#else
  #define SERIAL_LEAF_2 _SERIAL_LEAF_2
#endif

Later, SERIAL_LEAF_2 is used to define the MultiSerial instance.

Should SERIAL_CATCHALL actually be an integer, because it doesn't fit the pattern of other things, or should it be something like MYSERIAL0 or msSerial0 ?

Or, is there some other condition, and the SERIAL_CATCHALL value should be based on the value of SERIAL_PORT or SERIAL_PORT_2, or … ?

It's a lot to review and try to make sense of, but the fix is probably something simple.

@X-Ryl669
Copy link
Contributor

X-Ryl669 commented Jul 30, 2021

What is the expected port to use in those printer ?
If I understand the intend correctly from #17719, SERIAL_CATCHALL should be a serial port that's overwriting all serial configuration when defined.

I think it can be removed and the proper serial port declared and used instead.
So maybe you can just remove the define line from the Conditional file, and define the other serial port you want to use instead, like you did with #define SERIAL_PORT_2 2

@thinkyhead Can you explain what it was used for initially ?

@GhostlyCrowd
Copy link
Contributor

Bumping this, as is still an issue.

@GhostlyCrowd
Copy link
Contributor

GhostlyCrowd commented Sep 9, 2021

SERIAL_CATCHALL

#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) //#define SERIAL_CATCHALL 0 #ifndef LCD_SERIAL_PORT #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO) #define LCD_SERIAL_PORT 1 #else #define LCD_SERIAL_PORT 3 // Creality 4.x board #endif #endif #endif

As you suggested, fixed to compile issue for me, cannot test until i get everything assembled.

@SISLANGER
Copy link

Is there a fix for this yet ? I cant compile without multiSerial errors when enabling a second Serial Port

@SISLANGER
Copy link

Just a quick update it seems like PlatformIO wasn't clearing / updating when re-compiling even when using the clean all function. However after removing and re-installing PlatformIO disabling the SERIAL_CATCHALL 0 has done the trick. Main build 02000902)

@tiagofreire-pt

This comment was marked as off-topic.

@Xlaits
Copy link

Xlaits commented Jul 10, 2022

Solved: bigtreetech/BIGTREETECH-SKR-mini-E3#601 (comment)

How does this even remotely solve this? That uses fairly specific options for a specific board and stepper driver setup.
Where I am using the TMC2208 drivers, those instructions say to use otherwise. I am also using the BTT SKR 1.4 (Non Turbo), so some of those options also are incorrect for my board. On top of that, I'm using an Ender 3, not a v2.

Disabling the second serial port, and setting the first one to -1 seems to allow me to at least compile the firmware, but it refuses to use the LCD on my printer.

EDIT: Well, I found MY issue out. It was that I had the wrong LCD selected.

@rarens
Copy link

rarens commented Oct 12, 2022

Issue still exists

@samiresa
Copy link

Issue still exists as of 3/26/2023 with bugfix build.

@yuuahmad
Copy link

yuuahmad commented Aug 14, 2023

Marlin\src\HAL\shared../../core/serial.h:87:28: error: 'MYSERIAL2' was not declared in this scope

Cuplikan layar 2023-08-14 091144

i am using mks tinybee and since the board is using serial -1 for wifi i always come across this problem

@denis1482
Copy link

Marlin\src\HAL\shared../../core/serial.h:87:28: error: 'MYSERIAL2' was not declared in this scope

Cuplikan layar 2023-08-14 091144

i am using mks tinybee and since the board is using serial -1 for wifi i always come across this problem

In Configuration_adv.h
#define ESP3D_WIFISUPPORT
and it builds just fine

@VectorHasting
Copy link

I'm still having the error compiling using bugfix 2.1.x as of 12/9/2023.

I'm using #define MOTHERBOARD BOARD_BTT_SKR_V2_0_REV_B
(which is the setting required by BigTree_SKR_2_F429)
I've tried compiling with BIGTREE_SKR2_F429 and BIGTREE_SKR2_F429_USB

My error is the same as @yuuahmad:

Marlin\src\HAL\STM32\../../inc/../core/serial.h:87:28: error: 'MYSERIAL2' was not declared in this scope; did you mean 'MYSERIAL1'?

Neither the changes suggested by @denis1482 nor @Xlaits fixes it for me.

My fix was to fall back to 2.1.2.1.

@ellensp
Copy link
Contributor

ellensp commented Feb 10, 2024

This issue is specifically about having #define SERIAL_PORT and #define SERIAL_PORT_2 with any of the UI for Ender-3 v2 OEM display.

If you do not have two serial ports enabled in marlin, you have a different issue
ie your #define SERIAL_PORT or LCD_SERIAL_PORT is wrong for your motherboard

@BIG-BRO-L
Copy link

Issue still exists as of 5/12/2024

(Please help us)

@classicrocker883
Copy link
Contributor

IIRC, try this:
in ini/stm32f4.ini
change to toolchain-gccarmnoneeabi@1.120301.0

@ryan-makes-it
Copy link

Hi folks - I wanted to chime in that I'm still experiencing this issue as well - I added a Big Tree Tech SKR Mini E3 v3 controller board to my Ender 3 v2, which in my case has the TJC version of the DWIN LCD (see this page about the stock Ender 3 v3 displays (link)). My goal was to connect a Raspberry Pi Zero 2 W via UART2 (the TFT port) to the SKR Mini E3 v3 for OctoPrint use.

Using Miguel Risco-Castillo's excellent Ender 3 optimized firmware (link) and a rewired display cable, I can get the TJC / DWIN display working just fine. However, when I uncomment "#define SERIAL_PORT_2" and select any serial port (I've tried -1, 0, 1, 2 and 3), I get the same "Marlin/src/HAL/STM32/../../inc/../core/serial.h:72:26: error: 'MYSERIAL' was not declared in this scope; did you mean 'MYSERIAL2'?" error reported in #23889 (link).

I'm currently running Marlin Bugfix-2.1.x from 12/17/2024 (the current version of Miguel Risco-Castillo's optimized firmware), but I've experienced the error with the nightly Bugfix-2.1.x as well. I went back to Miguel's version to eliminate any potential misconfigurations by me.

Thanks for any help you can provide!

@classicrocker883
Copy link
Contributor

classicrocker883 commented Mar 8, 2025

hey @ryan-makes-it , could you provide your configuration files?
(select Configuration.h/Configuration_adv.h together and archive them in a .zip) and also what default_envs youre using in platformio.ini.

You can try my fork of mriscoc's firmware because I may have solved that issue there.

edit: try this

in Marlin/src/inc/Conditionals-2-LCD.h comment out SERIAL_CATCHALL 0

#if ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, SOVOL_SV06_RTS)
- #define SERIAL_CATCHALL 0

#if ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, SOVOL_SV06_RTS)
+ //#define SERIAL_CATCHALL 0

but if you have BAUD_RATE_GCODE enabled,
Marlin/src/gcode/config/M575.cpp file is different in mriscoc's firmware,
so just copy Marlin's over instead.


however, I tried messing around, and using STM32F401RC_btt for the board/chip, it appears to be searching for .platformio/packages/framework-arduinoststm32@4.20600.231001/variants/MARLIN_F401RC which doesn't exist because it is only STMF4XX or what-have-you, nothing with MARLIN in the name.

in .vscode/c_cpp_properties.json, there is this:

  • "VARIANT_H=\"variant_MARLIN_STM32F401RC.h\"",

and there is that file here:

  • buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h

but I am getting the error that it cannot find this file. so it seems the issue stems from trying to build off a variant in the wrong directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests