MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.05k stars 19.16k forks source link

[FR] MKS TFT32 support #9633

Closed tofifee closed 6 years ago

tofifee commented 6 years ago

It looks like some have managed to use the MKS TFT as a way to control their printers. How did you manage it exactly? Would you please detail how you got it to work. Especially interested in the combination with the MKS SBase 1.3.

Also is it planned to include the MKS TFT in the LCD controller list?

MagoKimbra commented 6 years ago

This display has its own firmware that emulates the host, it must not be managed directly from the card and from the marlin firmware. It connects on serial 0 on the mainboard and manages everything via gcode. So there's nothing to add to Marlin.

tofifee commented 6 years ago

Pinmapping - for I believe it is AUX1 to Serial 0 - would be a worthwhile addition imo.

So if you uncomment #define MKSTFT-AUX1 it would assign the AUX1 pins of the defined board.

Spawn32 commented 6 years ago

Only thing you need to do is:

define SERIAL_PORT -1 // is the USB port

define SERIAL_PORT_2 0 // is the serialport for the TFT

define BAUDRATE 115200 // for the serialport

and make sure that the firmware on you TFT 3.2 is sett to 115200 and Marlin.. :)

MagoKimbra commented 6 years ago

Correct @Spawn32!

Spawn32 commented 6 years ago

@MagoKimbra I just ordered a 5.0" Nextion Enhanced NX8048K050 HMI after seeing it on you MK4duo facebook page, they look brilliant :)

https://www.ebay.com/itm/5-0-Nextion-Enhanced-NX8048K050-HMI-Intelligent-USART-LCD-Touch-Display-Module/272330675280?epid=869644116&hash=item3f682c5450:g:ehgAAOSwimdXo2Vj

Will it work with Marlin the same way it works with your software or does it need some modification ? And do you have a link for the firmware it uses ? :)

MagoKimbra commented 6 years ago

I do not like talking about MK here, it's not right ... I only say no, because it needs a completely different management from normal lcd. Excuse me, but it seems fair to me ...

Spawn32 commented 6 years ago

You are absolutely correct, slipped my mind, sorry dev's :)

tofifee commented 6 years ago

@Spawn32

First of all thank you for pointing me in the right direction!

When I try to compile I run into these two errors:

Marlin/src/module/configuration_store.cpp: In static member function 'static void MarlinSettings::report(bool)': Marlin/src/module/configuration_store.cpp:1866:69: error: 'port' was not declared in this scope

Marlin/src/module/configuration_store.cpp:1881:5: note: in expansion of macro 'CONFIG_ECHO_START' CONFIG_ECHO_START; ^~~~~~~~~~~~~~~~~ Marlin/src/module/configuration_store.cpp:1892:26: error: 'port' was not declared in this scope SERIAL_ECHOLNPGM_P(port, " G21 ; Units in mm"); ^

Have you run into this before? Did I misconfigure something?

tofifee commented 6 years ago

Had to define SERIAL_PORT as 0 and leave SERIAL_PORT_2 commented out for it to compile.

Thanks again!

Spawn32 commented 6 years ago

Huh ? that shouldn't be possible, are you sure you are not using an old release of bugfix-2.0x ? Multihost (2 ports) has been in there for a while now...

Peca006 commented 6 years ago

@Spawm32: Today I've build Marlin for MKS-SBASE too with the same issue as @tofifee . I'm pretty sure I have fresh pulled 2.0.x branch.

tofifee commented 6 years ago

Clone and check-out just before compiling.

Spawn32 commented 6 years ago

downloaded a fresh copy now, no compile errors, strange..... How do you guy's compile it ? i use the command line option: "platformio run -e LPC1768"

@tcm0116 any ideer what's going on here ? 😄

tofifee commented 6 years ago

Same command as you in the platform.io terminal window.

tofifee commented 6 years ago

OT - slightly ;)

Has anybody tried yet to flash an ESP8266 with the MKS Wifi firmware to get serial over Wifi?

Peca006 commented 6 years ago

@Spawn32: The same command at mine console... I tried checked src code and I think that it should be ok. Now I'm quite confused :( @tofifee: I didn't have a wifi module, sorry.

tofifee commented 6 years ago

Was just a shot in the dark :)

Peca006 commented 6 years ago

Here are compiler messages:

C:\Data\gitrepo\marlin>platformio run -v -e LPC1768

[02/14/18 20:48:11] Processing LPC1768 (build_unflags: -Wall; build_flags: !python Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py, -fmax-errors=5, -DU8G_HAL_LINKS; src_build_flags: -Wall; lib_deps: CMSIS-LPC1768, U8glib-HAL, TMC2130Stepper@>=2.1.1; extra_scripts: Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py; board_f_cpu: 100000000L; platform: nxplpc; board: lpc1768; lib_extra_dirs: frameworks; lib_ldf_mode: off; src_filter: +<src/*> -<src/config>)
--------------------------------------------------------------------------
Library Storage: C:\Data\gitrepo\marlin\.piolibdeps
Looking for CMSIS-LPC1768 library in registry
Warning! Library `{'requirements': None, 'name': 'CMSIS-LPC1768'}` has not been found in PlatformIO Registry.
You can ignore this message, if `{'requirements': None, 'name': 'CMSIS-LPC1768'}` is a built-in library (included in framework, SDK). E.g., SPI, Wire, etc.
LibraryManager: Installing id=1932
U8glib-HAL @ 0.4 is already installed
LibraryManager: Installing id=1493 @ >=2.1.1
TMC2130Stepper @ 2.1.4 is already installed
Collected 9 compatible libraries
Scanning dependencies...
Library Dependency Graph ( http://bit.ly/configure-pio-ldf )
|-- <CMSIS-LPC1768> v0.0.0 (C:\Data\gitrepo\marlin\frameworks\CMSIS)
|-- <U8glib-HAL> v0.4 (C:\Data\gitrepo\marlin\.piolibdeps\U8glib-HAL_ID1932)
|-- <TMC2130Stepper> v2.1.4 (C:\Data\gitrepo\marlin\.piolibdeps\TMC2130Stepper_ID1493)
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\module\configuration_store.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\module\configuration_store.cpp
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\module\stepper.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\module\stepper.cpp
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\module\stepper_indirection.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\module\stepper_indirection.cpp
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\module\temperature.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\module\temperature.cpp
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\module\tool_change.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\module\tool_change.cpp
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\sd\Sd2Card.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\sd\Sd2Card.cpp
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\sd\SdBaseFile.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\sd\SdBaseFile.cpp
arm-none-eabi-g++ -o .pioenvs\LPC1768\src\src\sd\SdFatUtil.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fabi-version=0 -fno-use-cxa-atexit -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -Wall -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin\src\HAL -IMarlin\src\HAL\HAL_LPC1768\include -IMarlin -Iframeworks\CMSIS\LPC1768\include -Iframeworks\CMSIS\LPC1768\lib -Iframeworks\CMSIS -I.piolibdeps\U8glib-HAL_ID1932\src -I.piolibdeps\TMC2130Stepper_ID1493\src Marlin\src\sd\SdFatUtil.cpp
In file included from Marlin\src\module\../inc/MarlinConfig.h:41:0,
from Marlin\src\module\configuration_store.h:26,
from Marlin\src\module\configuration_store.cpp:47:
Marlin\src\module\configuration_store.cpp: In static member function 'static void MarlinSettings::report(bool)':
Marlin\src\module\configuration_store.cpp:1866:69: error: 'port' was not declared in this scope
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0)
^
Marlin\src\module\../inc/../core/serial.h:107:64: note: in definition of macro 'SERIAL_ECHO_START_P'
#define SERIAL_ECHO_START_P(p)             (serialprintPGM_P(p,echomagic))
^
Marlin\src\module\configuration_store.cpp:1881:5: note: in expansion of macro 'CONFIG_ECHO_START'
CONFIG_ECHO_START;
^~~~~~~~~~~~~~~~~
Marlin\src\module\configuration_store.cpp:1892:26: error: 'port' was not declared in this scope
SERIAL_ECHOLNPGM_P(port, "  G21    ; Units in mm");
^
Marlin\src\module\../inc/../core/serial.h:103:69: note: in definition of macro 'SERIAL_PROTOCOLLNPGM_P'
#define SERIAL_PROTOCOLLNPGM_P(p,x)             (serialprintPGM_P(p,PSTR(x "\n")))
^
Marlin\src\module\configuration_store.cpp:1892:7: note: in expansion of macro 'SERIAL_ECHOLNPGM_P'
SERIAL_ECHOLNPGM_P(port, "  G21    ; Units in mm");
^~~~~~~~~~~~~~~~~~
*** [.pioenvs\LPC1768\src\src\module\configuration_store.o] Error 1
======================= [ERROR] Took 8.13 seconds =======================

=============================== [SUMMARY] ===============================
Environment megaatmega2560              [SKIP]
Environment megaatmega1280              [SKIP]
Environment melzi                       [SKIP]
Environment melzi_optiboot              [SKIP]
Environment DUE                         [SKIP]
Environment LPC1768                     [ERROR]
Environment LPC1768_debug_and_upload    [SKIP]
Environment rambo                       [SKIP]
Environment sanguino_atmega644p         [SKIP]
Environment STM32F1                     [SKIP]
Environment teensy20                    [SKIP]
Environment teensy35                    [SKIP]
======================= [ERROR] Took 8.17 seconds =======================

Here are config files: configs.zip

Spawn32 commented 6 years ago

Just for the fun of it, test my config's but dont move any steppers if it compiles, it's for a corexy :) config.zip

Peca006 commented 6 years ago

@Spawn32: Same error. Hmm - Might be it a PlatformIO issue? Today I hit one already: #9623 Would you mind to send your platfdomio version and platformio.ini? However platformio.ini should be the same as it is commited into 2.0.x branch. My PlatfomIO version is 3.5.1. After update: toolchain-gccarmnoneeabi @ 1.60301.0 was updated to 1.70201.0.

Spawn32 commented 6 years ago

PlatformIO, version 3.5.1

and i use the platformio.ini that's included if you downloaded the latest bugfix branch , strange....

only other thing we haven't tested is where you locate your bugfix branch, i have mine on my desktop...

C:\Users\Familien\Desktop\Mks Sbase X5S\Marlin-bugfix-2.0.x140218>

Peca006 commented 6 years ago

Update does not solved it. Still the same issue :/

tofifee commented 6 years ago

I had several updates today. One was xonxerning the LPC.

Can you try to comment out the SERIAL_PORT_2 and assign 0 to SERIAL_PORT?

Maybe something is out of whack and only this combination gets through in certain configs.

tofifee commented 6 years ago

Also make double sure you hit save while in Configuration.h after changing something.

I was tearing my almost non-existing hair out at some point because nothing changed after uploading. But maybe that‘s only me ;)

Spawn32 commented 6 years ago

your like me then :) I always delete the .pioenvs and .piolibdeps directory's if i change something major to make sure it re compiles everything.

That's something i started with after using the arduino compiler, it dosent always recompile files it should have done :)

Peca006 commented 6 years ago

@tofifee: I already made a successful build with just one serial port and it succeed again. I try delete directories that mentioned @Spawn32 and "let's see"... Deleting directories not helped.

Peca006 commented 6 years ago

After another round of code inspection ( - I've been looking for various serial port dependencies ) I've uncomment #define EEPROM_CHITCHAT and now it builds! It was commented in sample config for MKS SBASE - so I do not know if it will work. I'm n00b and my printer is fresh new and is not tested yet. I'll continue tomorrow by testing steppers and then I'll continue by calibrating printer - if it will works. 👍 @tofifee: Try it please - #define EEPROM_CHITCHAT is on line 1140 or so in configuration.h file.


A #define ADD_PORT_ARG ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1 at line 28 in file Marlin\src\module\configuration_store.h leads me to try this. I'm not sure where, but I think that I spot place where port variable is used and its definition is blocked by (not sure - as I'm not familiar with C/C++):

#if ADD_PORT_ARG
  const int8_t port/*=-1*/
#endif
tofifee commented 6 years ago

Good!

My problem was solved by my above mentioned steps :) As I don‘t want to run a Computer as host and the SBase 1.3 goes into flash mode as soon as it detects a firmware.bin file on the SD Card.

Let‘s see what tomorrow brings. Night, folks!

Spawn32 commented 6 years ago

Nice that it worked out for you guy's But this is still some kind of bug, i have EEPROM_CHITCHAT defined and it compiles just fine..

@thinkyhead any ider what this is about ? :)

tofifee commented 6 years ago

@Spawn32

Was commented out in my config. Did uncomment it and it did compile. So it might be something else.

Hm. Just decided to try two serial port definitions again.

SERIAL_PORT as -1

SERIAL_PORT_2 as 0

And it compiled as well.

BUT

After commenting EEPROM_CHITCHAT out again it threw the previous error again and didn't compile.

So went back and enabled it again ... Surprise! ... didn't compile.

Decided to try your hair-pulling-prevention-technique and deleted the .pio directories:

Compiles!

My take is that there is a problem with platform.io not cleaning up properly before compiling and reusing something it shouldn't.

One solution work-around could be a little batch file like this:

#!/bin/bash
# CleanUpAndCompile script for platform.io to prevent zombies in the .pioenvs and .piolibdeps directories from introducing errors

echo "Deleting .pio directories in current folder ..."
rm -rf .pio*

echo "Compiling ..."
platformio run -e LPC1768

# Display contents of .pioenvs/LPC1768 sorted by date/time stamp in descending order
ls -thal .pioenvs/LPC1768/
Pentelfrost commented 6 years ago

I was/am seeing the same issue. From a fresh git clone and just copying the example config files from the Mks/Sbase directory I can't compile with the same errors from above. There are no platformIO files at that point so it doesn't seem to be just a clean up issue. Enabling EEPROM_CHITCHAT gives a successful compile as suggested.

thinkyhead commented 6 years ago

It is now patched:

  #if ADD_PORT_ARG
    #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0)
  #else
    #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START(); }while(0)
  #endif
GhassanYusuf commented 4 years ago

I have got the answer, in order to make the mks TFT work for me

`/**

/**

/**

keep in mind I choose the 115200 baud rate because I configured the TFT screen software to use 115200

it was exactly opposite of what was mentioned before @Spawn32

T-Risely commented 4 years ago

@GhassanYusuf

I have got the answer, in order to make the mks TFT work for me

`/**

  • Select the serial port on the board to use for communication with the host.
  • This allows the connection of wireless adapters (for instance) to non-default port pins.
  • Note: The first serial port (-1 or 0) will always be used by the Arduino bootloader.
  • :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */

    define SERIAL_PORT 0

/**

  • Select a secondary serial port on the board to use for communication with the host.
  • This allows the connection of wireless adapters (for instance) to non-default port pins.
  • Serial port -1 is the USB emulated serial port, if available.
  • :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */

    define SERIAL_PORT_2 -1

/**

  • This setting determines the communication speed of the printer.
  • 250000 works in most cases, but you might try a lower speed if
  • you commonly experience drop-outs during host printing.
  • You may try up to 1000000 to speed up SD file transfer.
  • :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] */

    define BAUDRATE 115200`

keep in mind I choose the 115200 baud rate because I configured the TFT screen software to use 115200

it was exactly opposite of what was mentioned before @Spawn32

When I compile with #define SERIAL_PORT_2 set to -1 I get a massive error ending with: "expected initializer before '-' token"

It only compiles with SERIAL_PORT_2 commented out and still my MKS FT32 doesn't communicate :( Any ideas?

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.