Skip to content

Conversation

nordic-krch
Copy link
Contributor

Extend uart_nrfx_uarte driver to support a mode of operation that is using bounce buffers and TIMER to count bytes (only applies to Asynchronous API). UARTE may lose or get a corrupted byte if new data appears on the line when RX timeout expired. In that case receiver is restarted and if there is a byte on the line when that restart happens then that byte will be lost or corrupted. This is relevant only to reception without HWFC.

Mode is using a TIMER instance and DPPI to count bytes using UARTE RXDRDY event. There is already a similar mode that is enabled using CONFIG_UART_x_NRF_HW_ASYNC for legacy platforms but it cannot be used on newer SoCs due to different DMA behavior.

New mode is enabled by specifying a timer property which points to the TIMER instance (e.g.. timer = <&timer21>). Timer node that is used for that should be reserved.

Overlay example:

&timer21 {
  status = "reserved";
};
&uart21 {
  timer = <&timer21>;
};

PR extends uart_async_dual stress test with a case which validates that the receiver is able to received chopped data (data sent in chunks with random gaps between).

@github-actions github-actions bot added platform: nRF Nordic nRFx area: UART Universal Asynchronous Receiver-Transmitter labels Jul 7, 2025
@github-actions
Copy link

github-actions bot commented Jul 7, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_nordic DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Jul 7, 2025
@nordic-krch nordic-krch force-pushed the uart_byte_count branch 8 times, most recently from c4cd989 to 50c48b9 Compare July 11, 2025 10:47
@dcpleung dcpleung assigned anangl and masz-nordic and unassigned dcpleung Jul 15, 2025
@nordic-krch nordic-krch force-pushed the uart_byte_count branch 3 times, most recently from e877845 to c0d6975 Compare July 18, 2025 12:50
@github-actions github-actions bot removed manifest manifest-hal_nordic DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Jul 18, 2025
@kl-cruz kl-cruz force-pushed the uart_byte_count branch 4 times, most recently from 064a6dc to ce928ac Compare July 28, 2025 07:09
@sonarqubecloud
Copy link

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Sep 27, 2025
@carlescufi
Copy link
Member

@nordic-krch still relevant? needs a rebase

@github-actions github-actions bot removed the Stale label Oct 3, 2025
Timer property indicates which TIMER instance should be used for
byte counting. If timer property is present then given instance
is using TIMER to count received bytes.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Rearrange code to prepare for upcoming extension that adds special
receive mode.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Add mode to be used on UARTE with frame timeout which is using a bounce
buffers and TIMER to count bytes. This mode shall be used to reliably
receive data without HWFC as frame timeout approach is not 100% reliable
because it can loose or corrupt a byte when new byte arrives after
frame timeout is detected but before it is fully handled. This mode is
similar to the one enabled with CONFIG_UART_x_NRF_HW_ASYNC but
additional bounce buffers are used and UARTE is receiving data to
internal buffers and copies data to the user buffer. Legacy apporach
cannot be used because in new SoC DMA attempts to copy data in words
so when byte is received it stays in the DMA internal buffer until
4 bytes are received or end of transfer happens then internal DMA
buffer is flushed.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Add reporting about the test progress. Test lasts few seconds and
progress report helps to see if test stuck or how it is progressing.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Extend test with a mode where HWFC is off and receiver is providing
buffers on time. In that case receiver should be able to continuously
receive data without losing any byte (even without HWFC). Additionally,
TX data is chopped to verify that receiver does not loose bytes when
new TX data collides with detected RX timeout.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Add timer property to the uart device under test.
Add zephyr,pm-device-runtime-auto to the uart device under test.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Add workaround timer to instances that are used for reception in the
test.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Stress test is executed on CPUs with slow clock (16MHz). Handling of test
data in UART_RX_RDY event is optimized to reduce time spent in the
interrupt context. Since payload is always a decrementing sequence, fixed
array is used to compare memory which allows to use standard memcmp
instead of byte by byte comparison.

Signed-off-by: Krzysztof Chruściński <[email protected]>
@zephyrbot zephyrbot added area: Devicetree Bindings area: Tests Issues related to a particular existing or missing test area: Boards/SoCs labels Oct 3, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards/SoCs area: Devicetree Bindings area: Tests Issues related to a particular existing or missing test area: UART Universal Asynchronous Receiver-Transmitter platform: nRF Nordic nRFx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants