Skip to content

arch/sim: don't block on the wrapped RX segment of the simulated UART - #20028

Open
raiden00pl wants to merge 2 commits into
apache:masterfrom
raiden00pl:fix-sim-uart-rx-wrap-block
Open

arch/sim: don't block on the wrapped RX segment of the simulated UART#20028
raiden00pl wants to merge 2 commits into
apache:masterfrom
raiden00pl:fix-sim-uart-rx-wrap-block

Conversation

@raiden00pl

Copy link
Copy Markdown
Member

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

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>
fix nxstyle errors

Signed-off-by: raiden00pl <raiden00@railab.me>
@github-actions github-actions Bot added Arch: simulator Issues related to the SIMulator Size: XS The size of the change in this PR is very small labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

xfer->nbytes = ret;

if (ret == xfer->length && xfer->nlength > 0)
/* The console fd is blocking, so only continue into the wrapped

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we change fd to the non-blocking mode

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

Labels

Arch: simulator Issues related to the SIMulator Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants