arch/sim: don't block on the wrapped RX segment of the simulated UART - #20028
Open
raiden00pl wants to merge 2 commits into
Open
arch/sim: don't block on the wrapped RX segment of the simulated UART#20028raiden00pl wants to merge 2 commits into
raiden00pl wants to merge 2 commits into
Conversation
The console fd is blocking (host_uart_start() never sets O_NONBLOCK), so when a burst of input ends exactly at the wrap boundary of the RX circular buffer, the second host_uart_gets() in tty_dmareceive() blocks inside the timer callback and freezes the whole simulator until the host sends another byte. Poll the fd first so the wrapped segment is only read when data is really available. Assisted-by: Claude Code Signed-off-by: raiden00pl <raiden00@railab.me>
raiden00pl
requested review from
Donny9,
GUIDINGLI and
xiaoxiang781216
as code owners
September 1, 2026 08:01
fix nxstyle errors Signed-off-by: raiden00pl <raiden00@railab.me>
jerpelea
approved these changes
Sep 1, 2026
| xfer->nbytes = ret; | ||
|
|
||
| if (ret == xfer->length && xfer->nlength > 0) | ||
| /* The console fd is blocking, so only continue into the wrapped |
Contributor
There was a problem hiding this comment.
should we change fd to the non-blocking mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The console fd is blocking (host_uart_start() never sets O_NONBLOCK), so when a burst of input ends exactly at the wrap boundary of the RX circular buffer, the second host_uart_gets() in tty_dmareceive() blocks inside the timer callback and freezes the whole simulator until the host sends another byte. Poll the fd first so the wrapped segment is only read when data is really available.
Impact
we can remove workaround in NTFC for sim:
https://github.com/apache/nuttx-ntfc/blob/f68efe4e6080c0fa7018664cd284789d3314cf55/src/ntfc/device/sim.py#L38-L39
Testing
Simulator works on NTFC without workaround from above