Skip to content

NRF52 serial fixes #8784

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

Merged
merged 6 commits into from
Nov 22, 2018
Merged

NRF52 serial fixes #8784

merged 6 commits into from
Nov 22, 2018

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Nov 17, 2018

Description

Fix a few serial problems on the NRF52:

  • Fix for dropped bytes when transmitting and receiving at the same time
  • @marcuschangarm's fix for serial writes
  • Fix for receiving data without sending data first

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

c1728p9 and others added 3 commits November 16, 2018 17:30
In nordic_nrf5_uart_event_handler if the events NRF_UARTE_EVENT_ENDRX
and NRF_UARTE_EVENT_RXSTARTED become pending after the check for
NRF_UARTE_EVENT_ENDRX but before the check for
NRF_UARTE_EVENT_RXSTARTED the RX DMA buffers will be setup incorrectly
by nordic_nrf5_uart_event_handler_rxstarted because active_bank hasn't
been updated. This cause dropped and incorrect data.

This patch fixes that problem by adding a second check for
NRF_UARTE_EVENT_ENDRX after checking for NRF_UARTE_EVENT_RXSTARTED
and skipping processing if NRF_UARTE_EVENT_ENDRX is set. The
subsequent interrupt will process both in the correct order. This
ensures that these events cannot be handled out of order and thus fixes
the corruption.
Busy-wait before sending a charecter instead of after. If
serial_writeable has been called first, the busy-wait loop will
be skipped.

Added initialization code to ensure NRF_UARTE_EVENT_TXDRDY is
armed correctly.
When attaching an irq to serial call nordic_nrf5_serial_configure.
This ensures the serial is ready to receive data at the correct
baudrate.
@cmonr cmonr requested review from studavekar, OPpuolitaival and a team November 17, 2018 03:46
@cmonr
Copy link
Contributor

cmonr commented Nov 17, 2018

Interesting. Gonna do a whole bunch of test Test CI runs.

@cmonr
Copy link
Contributor

cmonr commented Nov 17, 2018

/morph build

@cmonr
Copy link
Contributor

cmonr commented Nov 17, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 17, 2018

Build : SUCCESS

Build number : 3660
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8784/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

1 similar comment
@mbed-ci
Copy link

mbed-ci commented Nov 17, 2018

Build : SUCCESS

Build number : 3660
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8784/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 17, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 19, 2018

Info: This PR has been re-bundled into a new rollup PR (#8800).

No further work is needed here, as once that PR is merged, this PR will also be closed and marked as merged.
If any more commits are made in this PR, this PR will remain open and have to go through CI on its own.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 19, 2018

Reworking my rollup, this still needs work as I was told (needs:w ork now here)

Make the following enhancement:
-Support serial port use without flow control
-Prevent dropped bytes by updating flow control handling
-Remove dead code

Serial port use without flow control:
In the prior implementation there was a window of time between
reloading DMA buffers after a timeout where bytes could be dropped.
This is because the uart needed to be turned off in order to flush the
bytes in the DMA buffer.

This change configures the DMA buffer to only receive one byte at a
time so there is no need to disable the uart to flush it. After each
byte is received the DMA transfer will be over so the transfer will
never be partially complete and need flushing. Since the uart is
always on it is safe to use it even without flow control.

Prevent dropped bytes by updating flow control handling:
To prevent dropped bytes due to high latency the flow control handling
of the RTS line was configured to be asserted automatically by
hardware after each byte. Once the CPU has read the byte and setup
the next receive buffer the RTS line is deasserted to the transfer can
continue. This ensure that when flow control is enabled data won't be
lost due to interrupt latency.

Remove dead code:
With the above changes there is a lot of dead code, such as the timer
handling code. This patch removes the code that is no longer used.
When the RX FIFO is nearly full use flow control to stop receiving
data.
@c1728p9
Copy link
Contributor Author

c1728p9 commented Nov 20, 2018

I fixed all the issues I have seen so far. This should be ready for testing. With these new commits the NRF52 should work reliably without flow control if interrupt latency is good, and should work reliably regardless of interrupt latency if flow control is on.

@cmonr cmonr removed the needs: work label Nov 20, 2018
Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Removing the DMA config parameter altogether will be a compatibility glitch, but then anyone who was manually configuring it should be rechecking what parameters they need, if any, after the change - presumably default parameters should be solid now.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 20, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 20, 2018

Build : SUCCESS

Build number : 3682
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8784/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 20, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 20, 2018

No NRF5x issue here, known tracked issues

@mbed-ci
Copy link

mbed-ci commented Nov 20, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 20, 2018

EOFError error in the exporter CI

@marcuschangarm
Copy link
Contributor

Thanks Russ! Look awesome! 😄

@kjbracey
Copy link
Contributor

Kari and Veijo have been making positive noises about this+ESP8266+mbed client. I think it's cleared all our problems (in conjunction with Marcus's other PRs).

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 21, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 21, 2018

Build : FAILURE

Build number : 3702
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8784/

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 21, 2018

restarting

[DEBUG] Output: Fatal error: A1023E: File "/tmp/filesS8062" could not be opened: No such file or directory from IAR

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 21, 2018

Build : ABORTED

Build number : 3703
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8784/

When initializing serial disable all interrupts as some of these may
have been enabled by a bootloader. This ensures that the NRF52
serial driver remains compatible with any bootloader version.
@c1728p9
Copy link
Contributor Author

c1728p9 commented Nov 21, 2018

Add a commit to fix backwards compatibility with older bootloaders

@mbed-ci
Copy link

mbed-ci commented Nov 22, 2018

Test run: SUCCESS

Summary: 4 of 4 test jobs passed
Build number : 1
Build artifacts
Build logs

@0xc0170 0xc0170 merged commit 60b5547 into ARMmbed:master Nov 22, 2018
@c1728p9 c1728p9 deleted the nrf52_serial_fixes branch November 26, 2018 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants