Fix freezing on SKR-E3-mini-v1.2 board #7078
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When attached to a BigTreeTech SKR-E3-mini-v1.2 board, Cura+USB seems to reliably hang the printer; sometimes you'll hear an alarm sound, other times the printer will just freeze entirely.
The leaveISP() function claims that the serial port is still valid, but as far as I can tell this isn't an actually-valid assumption; it was first introduced in b4df277 but I can't quite track context behind that. This might be true for a bunch of devices but I doubt it's true generally.
My hypothesis here is that leaveISP causes the STM32F103RCT6 to reboot, which then wigs out the power-selector circuit (there's now USB power where there wasn't before), and now all of a sudden the chip is in an entirely different state. But that's mostly a guess.
It doesn't look like the programmer is necessary, however; it simply connects, loads a register for a READ/WRITE command to use, checks the availability of a checksum byte, and then returns. Since we don't care for that, we can just open individual serial connections as/when they're needed with the various different baud rates. This stops my personal SKR-E3-mini-v.2 board from failing, and since this looks like the same fix as https://www.reddit.com/r/BIGTREETECH/comments/dp6k6r/skr_mini_e3_v12_and_curausb/fbv808j/ I'm going to guess that it works for everyone with this board, and shouldn't interfere with other printers since, again, all the STK600 communication is mostly noise.
I suspect this also fixes issue #6531.