-
Notifications
You must be signed in to change notification settings - Fork 513
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
[Gen 3] Fixes UART RX DMA transfer size issues #2264
Conversation
…ring buffer than the configured RX DMA transfer
…t compiler/cmake version
d7f0935
to
4b4608a
Compare
Hey @avtolstoy ,how long does the testing example need to reproduce the issue?Still randomly? |
@jack-particle Usually a few minutes is enough, but yes, it's generally an 'undefined' amount of time. Eventually affected releases should showcase this problem. |
@avtolstoy Do you think the time is related to the baud rate? The Zoomo project has a hardFault exception every few hours(actually randomly) that triggers the system panic. I found out before the system panic reset the serial can not provide the data from the gps module.And then the device was reset.The baud rate is |
@jack-particle Baudrate should be irrelevant, but 230400 was showcasing the problem quicker. |
Thanks.You are right.I have used 460800 for testing. And it did not help for reproducing the issue. |
Problem
Originally reported in https://community.particle.io/t/serial1-rx-randomly-dies-on-boron-2-0-1-red-sos-crash-with-second-serial1-begin/58888/10
There is a problem in how we commit received bytes while RX DMA transfer is still ongoing (https://github.com/particle-iot/device-os/blob/develop/hal/src/nRF52840/usart_hal.cpp#L279), causing ring buffer to get into an invalid state and subsequent RX DMA transfers to be configured incorrectly with very large sizes, which causes out of bounds writes.
Solution
Usart::read()
to re-start RX DMA transfer under an RX lock. Just in case.Steps to Test
Use the following application along with a python script writing into Serial1 through an USB-UART adapter. Watch the USB Serial.
Before this PR, the markers will eventually change value from
0xdeadbeef
to something else indicating an out of bounds write.References
Completeness