Repository navigation
Small fixes found by testing against a 16550A model - #84
Merged
Merged
Conversation
The constructors initialize the device fields in several places. Route them through new_with_backend(), so new fields only need to be set in one place.
An invalid baud rate made init() return with DLAB set. Offsets 0 and 1 then address the divisor latch instead of the data registers and IER, so the device is unusable until the next successful init().
The denominator 16 * (psd + 1) * divisor overflows u32 for large inputs, e.g., when calc_divisor() gets a very high baud rate. Calculate in u64.
Without FIFO, the FCR reset bits have no effect, so a byte received before init() stayed in RBR and was returned as new data. Read it out right after configuring the FIFOs, before signaling readiness via DTR and RTS, and also read IIR at the end, as Linux does.
On errors, test_loopback() returned early and left the device in loopback mode, which disconnects it from the outside. Restore MCR on all paths.
flush() returned immediately, although up to a FIFO of data was still being sent. The embedded-io contract requires that all buffered data reaches its destination, e.g., before a reset or a baud rate change.
The presence check overwrote the scratch register, which firmware or other software may use. Linux restores it in its scratch test, too.
It described the meaning of ISR bit 0 inverted.
phip1611
commented
Oct 10, 2026
| /// This blocks as long as the transmitter is stalled, e.g., by hardware | ||
| /// flow control. | ||
| fn flush(&mut self) -> Result<(), Self::Error> { | ||
| // Wait until the transmitter sent everything, like Linux' tcdrain(). |
Member
Author
There was a problem hiding this comment.
FYI @mkroening - there is an upcoming bugfix (relevant on real hardware)
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.
Small, non-breaking fixes for bugs found by testing the driver against a 16550A model that follows the Linux 8250 driver (#83):
init()no longer leaves DLAB set on an invalid baud rate, and discards stale data also without FIFO.test_loopback()leaves loopback mode also when it fails.embedded_io::Write::flush()waits for the transmitter.calc_baud_rate()no longer overflows;check_present()restores the scratch register; a doc fix.More fixes follow in separate PRs.
🤖 Generated with Claude Code