-
Notifications
You must be signed in to change notification settings - Fork 221
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
Fix reading/writing small buffers #1760
Fix reading/writing small buffers #1760
Conversation
I've been staring at the code for the last 30 minutes and I can't figure out why this PR fixes the linked issue. On a somewhat unrelated note, I spotted something else that could also contribute to the transfer getting stuck. This is the existing code before this PR. reset_dma_before_load_dma_dscr(reg_block);
chain.fill_for_tx(false, ptr, len)?;
unsafe {
tx.prepare_transfer_without_start(self.dma_peripheral(), chain)
.and_then(|_| tx.start_transfer())?;
}
self.clear_dma_interrupts();
reset_dma_before_usr_cmd(reg_block);
if listen {
tx.listen_eof();
}
reg_block.cmd().modify(|_, w| w.usr().set_bit()); There's a race condition in it. In practice this is rare since most people should be doing DMA transfers with large buffers but if the DMA buffer is small enough, the DMA could end up filling the peripheral's FIFO before the peripheral has even been started. Having said that, I now realize it's also incorrect to call (More stuff to exercise in the HIL tests I guess 😄) |
On ESP32 the interrupt triggered before |
f54e029
to
35a2163
Compare
Ahhh I see, okay those are probably fine then. I wish the TRM had more details about how these buffers worked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
The failed test |
The test also fails with |
Since Bjoern is on vacation this week, I will convert this to a draft for the time being. |
35a2163
to
e0de4e0
Compare
Turned out clearing the interrupts earlier (which seemed to make sense) caused problems for ESP32-S3 .... Very glad we have HIL-TESTs in place |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
Fixes #1728
Testing
See #1728 for a minimal repro