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

PR: Fix MKS H43 hard crashes on (at least) STM32 platforms #24025

Closed
wants to merge 14 commits into from

Conversation

gruvin
Copy link
Contributor

@gruvin gruvin commented Apr 11, 2022

Description

Fixes MKS H43 (DWIN/DGUS) code from crashing STM32 mcus.

Requirements

Makerbase MKS H43 touch display and a 32-bit controller board it can connect to.

I suspect this same problem exists for all the DGUS displays on 32-bit boards (like DGUS Reloaded etc) but I have only addressed the MKS code in this PR.

Benefits

The MKS H43 display now works under STM32 builds instead of hard crashing Marlin when a user attempts most any interaction.

Note that as far as I can tell from reading about, the existing code (prior to this PR) works on 8-bit systems but is nevertheless in violation of ISO C11/C99 pointer casting rules, leading specifically in this case to the aforementioned hard crashes for SMT32 builds under GCC code optimization.

Configurations

Configurations.zip is attached.

My test platform is a BigTreeTech SKR mini E3 V3.0. The included platformio.ini is for that particular board.

Note that this v3.0 board has changed from the infamous STM32F103RCT6 to the newer (and actually available) STM32G0B1RET6 MCU. Older versions of PlatformIO do not include this newer chip so upgrading may be required.

Any STM32 family MCU board should suffice for testing however. I know the issue exists on the BTT SKR mini E3 V2.0 and the STM32F407ZGT6 based BTT SKR Pro 1.1.

Oh -- I actually upgraded my SKR mini E2 V2.0 board's MCU to the RET6 version in order to run Marlin 2 with all the features I have enabled. The stock RCT6 version should be OK here though, since most of those features are disabled by default. YMMV

The H43 requires merely GND, +5V, RX & TX on any available serial port, such as EXP1, AUX1 or TFT labelled ports on various boards. I'm using the EXP1 port on the SKR mini E3 v3.0, pins 1, 2, 6 & 8 respectively.

Related Issues

I have not raised an issue concerning this bug and cannot find any directly related open issues at present. Pretty sure I have seen them before and there's definitely some scattered forum and Reddit posts. Either way, the current bugfix-2.0.x code is broken in this context as described. (Also broken in 2.0.9.3, which I was actually working with when debugging the issue. There are quite a few other differences in the DGUS code there too, compared to bugfix-2.0.x. So I re-applied the fix manually for this PR, rather than stomping on the other changes.)

Makerbase themselves appear have ignored the problem, most likely because they are working with the MKS Robin controller and that apparently works just fine.

I have owned this MKS H43 screen for well over a year now and it has never worked for me — even with Makerbase's old Marlin fork they released that works fine on the MKS Robin, at least. (I only have 32-bit platforms.)

There must be a fair few of these display tossed into drawers in disgust. So, I hope people find this and it makes their day or something.

@gruvin
Copy link
Contributor Author

gruvin commented Apr 11, 2022

Confusion: I just looked at MKS's own "latest" firmware for their Robin nano STM32 boards. The "nano" series boards also use STM32 chips, yet they are advertising the H43 plugged into one of these boards and apparently working.

Sure, the home screen shows up but I swear it does NOT actually work and for reasons well understood to me, after hours of debugging to find the cause and fix it.

Stuffed if I know. Are they falsely advertising just to clear old stock or something? :/ Or is something nonsensically amiss in my own little universe? Wouldn't be the first time.

Your call. I've done all I can.

@thinkyhead
Copy link
Member

I wish I could test, but the H43 I got from MKS was DOA.

@thinkyhead thinkyhead force-pushed the PR_MKS-H43_STM32 branch 3 times, most recently from 73a96b8 to 25dd374 Compare April 13, 2022 04:32
Copy link
Contributor Author

@gruvin gruvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jolly good.

@thinkyhead thinkyhead added Needs: Testing Testing is needed for this change labels Apr 18, 2022
@thisiskeithb
Copy link
Member

I wish I could test, but the H43 I got from MKS was DOA.

I have a working H43 that I can test with.

I can't say I remember having crashing issues when I first got this screen and I'm pretty sure it was with a 32-bit board, but that was quite some time ago.

Once I resolve the build errors with my current board/config (stock bugfix/outside of this PR), I can test these changes.

@thinkyhead thinkyhead changed the base branch from bugfix-2.0.x to bugfix-2.1.x June 4, 2022 06:07
@thinkyhead
Copy link
Member

I have a working H43 that I can test with.

Maybe I do too…. There are different adapters, and I don't know that I tried them all.

@thinkyhead thinkyhead force-pushed the bugfix-2.1.x branch 2 times, most recently from a059328 to c9a9b25 Compare June 6, 2022 05:09
@thinkyhead thinkyhead force-pushed the bugfix-2.1.x branch 2 times, most recently from 627f8ef to 20dea22 Compare June 11, 2022 04:59
@thisiskeithb
Copy link
Member

thisiskeithb commented Jun 21, 2022

I couldn’t even get H43 support to compile, but ellensp has opened PR #24378 after Issue #24376 was opened, so it should get support compiling again.

@thinkyhead thinkyhead force-pushed the bugfix-2.1.x branch 2 times, most recently from 97117d0 to 5979aab Compare July 7, 2022 02:15
@thinkyhead
Copy link
Member

Seems to build now after some corrections. But will it work?

@thinkyhead
Copy link
Member

Merged the latest code, so is this still needed?

@gruvin
Copy link
Contributor Author

gruvin commented Jul 12, 2022

The PR was needed and worked perfectly at the time it was submitted but it seems core development accelerated faster than we could keep up. :/

I am not able to test due to, well, life changes, sorry.

What to do? The crash was real and the original PR at the time corrected the problem without issue. Core development went faster than we could keep up, I think? No one else came forward with the same display who could run tests. So I guess, even though the work was put in to fix it in good faith, perhaps we now have to drop this fix? I don't know what else to suggest. I feel bad about it. Apologies.

@thisiskeithb
Copy link
Member

I still can't get mine to work correctly and from what I've seen, this is a common issue.

Maybe it only works with older versions of Marlin?

It's a bummer since the panel & UI looks pretty good.

@thinkyhead
Copy link
Member

I've merged these changes into the newer PR #24600. If that PR is in good shape then it can be merged today.

@thinkyhead thinkyhead closed this Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: STM32 C: LCD & Controllers Needs: Testing Testing is needed for this change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants