-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
UART IRQ Priority + Error Handling for Overrun, Framing and Parity #19301
UART IRQ Priority + Error Handling for Overrun, Framing and Parity #19301
Conversation
I think this looks promising. The ISR changes should prevent the hang when an overruns is encountered without data (as described in the STM32 manual). The priority change should hopefully prevent overruns. At 250kbaud we will have to service the interrupt every 40 microseconds to keep up with a constant stream of data. We're only competing with SysTick and the Servo ISR, so that is probably ok as long as interrupts are never disabled too long elsewhere. |
I did some testing with this on my SKR Mini E3 1.0. Prior to this change, I can reproduce a hang in about 5 seconds using the following technique:
After this change, I can repeat the same process as long as I want, with no problems. While it would previously fail in a few seconds, I can now send the entire file (1MB each time) three times and never saw a failure. That is about 2 minutes with no issues. |
@rhapsodyv pointed out to me that a lot of STM32F1 boards are using external serial-USB chips, which makes this change even more important. I originally thought this mainly impacted users with serial-connected displays, but on those boards all serial communication was vulnerable to this hang. |
Do you think worth adding some error logging when one of those errors happens? |
It will be good to have another interrupt-priority-related issue fixed. These are some of the most tricky we've seen. I can see why developers prefer an RTOS for complex projects instead of getting intimate with the hardware. I'll do another point release soon so this patch gets out to the world quickly. |
@thinkyhead an RTOS just replaces interrupt priority with task priority. |
I think it's more than confirmed: #19204 (comment) This user never was able to do long prints using serial!! 🚀 🥳 The first test he did:
The last test:
|
I was having this exact problem on 2.0.6.1. I was printing from octoprint and my 36 hour print kept failing 1-3 hours in, serial communication would just die, the printer would stop moving, and the heaters would be left on. I switched to bugfix (and lowered my baud rate from 250,000 to 115200), and the problem went away. Now I am 25 hours in with zero problems. I'll try my next print at 250,000. Attached is my config, just in case someone thinks it might help them. Ender 5 Plus, Mini SKR E3 V2, TFT35, Smart Filament Sensor: |
…9301) (Error handling for Overrun, Framing and Parity.)
…9301) (Error handling for Overrun, Framing and Parity.)
Description
There's this issue, with a patch to handle uart overrun: #18358 . With the Emergency Parser development for STM32F1, we have the code to better handle UART directly in Marlin. We don't edit the maple framework anymore.
So, I was taking a look to apply the patch in #18358. But, talking with @sjasonsmith , he told that we can try first a better approach: increase the UART IRQ priority.
This PR does it: increase UART IRQ priority. It's hardcoded now, but we can tune it.
I will ask for the author of #18358 test.
Benefits
Try fix UART overrun.
Related Issues
#18358