-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix hardware flow control on NRF52 series #8292
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
Conversation
@@ -331,6 +331,20 @@ static void nordic_nrf5_uart_timeout_handler(uint32_t instance) | |||
/* No activity detected, no timeout set. */ | |||
nordic_nrf5_uart_state[instance].ticker_is_running = false; | |||
|
|||
/* Check if hardware flow control is set and signal sender to stop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code is repeated 3 times. Would it make sense to wrap this up in it's own function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's being called twice. It interrupt handler is convoluted as it is, I don't think adding another function will make it easier to read.
Please provide reference to the bug in UARTE (such as errata from Nordic) / a Github issue? It will be useful. |
The bug is an artifact of the UARTE API, because there is no safe way to flush the DMA buffer and swap it for a new one. When you follow the documentation and flush the DMA you'll get a ~6 ms period where the UARTE is not ready to receive. During this period the hardware flow control is inactive because the hardware flow control is only ready when the UARTE is ready to receive. This PR manually toggles the flow control pin during this timeout window. |
Sounds like a dicey problem! Do you have a test that showcases the problem and fix? DMA buffers are just 1 byte - right? |
DMA buffers are at least 5 bytes. You can connect a logic analyzer to any application. You'll notice the RTS line is never set even though it should be. |
Build requested by @marcuschangarm /morph build |
Build : SUCCESSBuild number : 3241 Triggering tests/morph test |
/morph export-build |
Exporter Build : SUCCESSBuild number : 2832 |
Test : FAILUREBuild number : 3049 |
/morph test NRF52_DK timed out. |
@marcuschangarm Is there a chance that the NRF52 timeout could have been caused by this change? |
Test : FAILUREBuild number : 3061 |
failures in tests for NRF52_DK timeouts and sync issues. this doesn't seem incidental. @marcuschangarm please take a look |
/morph test |
Test : FAILUREBuild number : 3091 |
/morph build New commit > new SHA > new Build step needed. |
Build : SUCCESSBuild number : 3292 Triggering tests/morph test |
@marcuschangarm failures in test look PR related, please take a look. |
@studavekar @NirSonnenschein |
@marcuschangarm not sure if Daplink supports flow control from host <-->daplink<---- hw fw ctrl ---> device. We also need to make review the test, we should avoid heavy uart traffic in tests. If we want to stress uart it should part of a separate test. Failure :
|
Thoughts? |
I took a look at the DAPLink code and flow control is enabled for the NRF52 boards. |
@c1728p9 |
@marcuschangarm yep, it is built into the USB CDC protocol and can't be turned off. |
@c1728p9 |
The failing test is for a component that is not supported by the NRF52_DK target. Both the
|
@mprse Can you review ^^ ? |
Due to buggy flow control logic in the UARTE, the stop signal is not being set as it is supposed to when the the module is not ready to receive data. This commit signals the sender to halt transmitting when a DMA buffer is full and only continue again when the atomic FIFO buffer has been emptied. This allows platforms with hardware flow control to minimize all buffers and rely on flow control instead.
Yep |
These tests verifies time conversion functions from the following library which is available for all targets and does not require mbed-os/platform/mbed_rtc_time.cpp Lines 25 to 74 in 140f3e2
I can confirm that the failing test sends lots of data between host and device using uart. So this is a great test for this PR 😅 . Looking at the last results we have failure on |
So, what's the plan?
|
Currently flow control is not supported by the CI and enabling it causes unwanted side effects.
/morph build |
Build : SUCCESSBuild number : 3470 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 3092 |
Eclipse error, but all good there /morph export-build |
Test : SUCCESSBuild number : 3261 |
Exporter Build : SUCCESSBuild number : 3097 |
Description
Due to buggy flow control logic in the UARTE, the stop signal is not being set as it is supposed to when the the module is not ready to receive data.
This commit signals the sender to halt transmitting when a DMA buffer is full and only continue again when the atomic FIFO buffer has been emptied. This allows platforms with hardware flow control to minimize all buffers and rely on flow control instead.
Pull request type