-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
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
[FR] Serial reading via DMA to improve serial communication reliability #26322
Comments
You have to write this in STM32 HAL (starting with MarlinSerial::begin i guess) and make it completely transparent for all other codebase. While some small arch-dependent branching is ok in main code, it should be kept to absolute minimum. |
I have a bare metal implementation starting at "nothing" and handling the channel/stream selection depending on the USART used, ending with Serial_Get and Serial_Put. Using STM32 HAL would be very easy. |
It'd be really cool if you can replace another piece of junk arduino code. |
I see what needs to happen, basically a HardwareSerial class (HardwareSerial.cpp/h, uart.c/h) needs to be made. Lots of things in there are not even needed. One odd thing I noticed, when I have data corruption (dropped character) there is a call to HAL_UART_ErrorCallback in uart.c, but ErrorCode is 0, no error flags are set, HAL_UART_GetError(huart) reports a 0. What's going on? |
I managed to isolate Class HardwareSerial out of Arduino so I can modify things. Changed methods: Then it works already... and the best thing is, it solves my data corruption issue. I think the issue is actually in the Arduino platform, but it only shows under stress. Now 250K baud is stable. I'm going to test faster serial speeds now. |
Yep, just open draft PR. We can clean it up and integrate properly later. Better name it same HardwareSerial and wrap in #if ENABLED(SERIAL_DMA), something like that. |
It'd be good to get |
Yep, EMERGENCY_PARSER is pretty much obligatory by now, waaaaay too many things rely on it |
Are F1/F7/H7 series DMA different? or you didn't look at it? |
F1 is a little bit different, some register names are different (see below). F1: F2/F4: |
PR is up! BTW: Adding DMA serial writing is also possible, but doesn't bring much in my view. Interrupt writing is fine, but interrupt serial reading (at least Arduino's version) is not. |
@EvilGremlin Now it's there... #26328 Update: I replaced Note: This code works for multiple serial ports, but does not affect the USB Serial port emulation. |
I can wrap the code with "#if ENABLED(SERIAL_DMA)", no problem. How important is F7 and H7 support? There are only a few boards like this around. A key problem I currently have is that a lot of build test get cancelled, and a few fail because "SERIAL_PORT 0", if I change that to 1 then they also build correctly. Anybody know how to deal with this? |
Wrong topic. I guess CI can't pull configs, again. You can only wait for github to fix their shit, or Scott to fix settings, i don't know really. |
Closing since you’ve opened a PR. |
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. |
Is your feature request related to a problem? Please describe.
This feature requests is related to unreliable serial data communication I found when putting load on the motherboard by printing faster. I use a TFT (BTT TFT35 V3.0) with serial interface to print. I found that under high loads the motherboard (MKS Monster8 V1.0) sometimes drops a character, but no error codes or flags are raised. I managed to get DMA reading enabled in Marlin which completely solved this issue. By default Marlin uses the Arduino platform to read serial data, at 250K baud this is unstable, with DMA serial reading enabled 1M is rock solid. There must be something wrong in the Arduino platform.
The current implementation (#26328) supports the STM32F1/F2/F4 platform. F0 and F7 are still very experimental, and have not been tested on actual hardware, but are likely to work because F0 and F1 are about the same, and F4 and F7 are also almost the same.
The used DMA reading strategy writes data to a circular buffer, and doesn't need an interrupt service routine, which makes is very efficient. The key benefit is reliable serial communication at higher speeds.
Are you looking for hardware support?
No
Describe the feature you want
DMA serial reading to improve serial reading reliability and allow for higher serial baud rates.
The text was updated successfully, but these errors were encountered: