Skip to content
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

drivers: serial: nrf uarte: The application receives one more byte that was received over UART #33280

Closed
tomchy opened this issue Mar 12, 2021 · 2 comments · Fixed by #33971
Closed
Assignees
Labels
area: UART Universal Asynchronous Receiver-Transmitter bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: low Low impact/importance bug
Milestone

Comments

@tomchy
Copy link
Contributor

tomchy commented Mar 12, 2021

Describe the bug
The application receives one more byte that was received, due to RX counter alignment upon ENDRX event.
In case of the following sequence of UART events:

  • UART_ENDRX
  • UART_RXRDY
  • TIMER_RXTIMEOUT

The application receives one more byte that was received, due to RX counter alignment upon ENDRX event.

Expected behavior
The application should receive the exact amount of bytes that was received by the UART peripheral.

Impact
This issue may break data transfers, that require at least two UART transmissions, with the delay between them.

Environment:

  • OS: Linux
  • Toolchain: NCS SDK
  • NCS v1.3.0

Additional context
The issue was found during Zigbee NCP serial transport development. It was mitigated by switching from UART_ASYNC_API to the UART_INTERRUPT_DRIVEN mode (nrfconnect/sdk-nrf#2835).
After switching, a new way of reproducing the issue was not developed.

@tomchy tomchy added the bug The issue is a bug, or the PR is fixing a bug label Mar 12, 2021
@galak galak added area: UART Universal Asynchronous Receiver-Transmitter platform: nRF Nordic nRFx has-pr labels Mar 16, 2021
@galak galak added the priority: low Low impact/importance bug label Mar 16, 2021
@XavierChapron
Copy link
Contributor

@tomchy @anangl I'm seeing a similar behavior:

I'm using sequences that looks like:

  • mdm_receiver_wake()
  • mdm_receiver_send()
  • mdm_receiver_recv()
  • mdm_receiver_sleep()

When using UARTE driver, there is an extra char received by the modem_receiver through mdm_receiver_isr() 0.5msec after the call to mdm_receiver_sleep().
This extra char always correspond to the last received char.

This doesn't happen when using UART driver.

However I'm not familiar enough with UART and NRF UARTE implementation to give you the exact event sequence.

I've blindly tried your proposed patch #25975 but it didn't work on my use case.

We were able to implement our driver by detecting and ignoring theses extra bytes, but we are still really interested in a real fix!

@tomchy
Copy link
Contributor Author

tomchy commented Apr 2, 2021

Hi @XavierChapron!
I've rebased the branch and made a draft PR here: #33971

What is your UART driver configuration in the problematic scenario?
Have you tried the timer-based RX byte counting?

CONFIG_UART_0_ASYNC=y
CONFIG_UART_0_NRF_HW_ASYNC=y
CONFIG_NRFX_TIMER1=y
CONFIG_UART_0_NRF_HW_ASYNC_TIMER=1

When it comes to debugging - I was using the logic probe and toggling GPIO pins on the UART events. Could you grab some traces?
The UART event dispatcher is implemented in the uarte_nrfx_isr_async static function and the timer triggers rx_timeout function in the same file. Keep in mind that it is called from an interrupt context, so the pin toggling routine must not use mutexes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UART Universal Asynchronous Receiver-Transmitter bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: low Low impact/importance bug
Projects
None yet
4 participants