-
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
Implement DMA to/from psram on esp32s3 #1827
Conversation
Currently running the example results with garbage in the receive buffer. :-( I'm not getting errors reported in the interrupt raw registers and from the other registers all of the dma descriptors were processed. Is it possible that we don't have the psram configured correctly for this to work? |
I'm not aware there is something special to do for DMA - haven't seen anything related in esp-idf |
I haven't looked at the code yet but make sure to flush the cache before triggering DMA to read from PSRAM. EDIT: |
I found this in esp-idf, note that ESP_ROM_HAS_CACHE_WRITEBACK_BUG is defined for esp32s3 |
Currently using psram as the source works (!) however using psram as the destination does not, nothing was written to psram. |
So now transfers work both directions.
|
I have questions about the soundness of the fix used in esp-idf. The fix is all about transfers whose start and/or end are a "partial cache line". Meaning that some memory in the cache line subject to the writeback is not owned by the caller. From my understanding there is still a short period of time after the writeback was completed where the other core, or an interrupt handler could write to that adjacent memory. The only safe way I see to implement this is to only allow DMA to/from psram where the start and size are both aligned to the size of the cache line. |
I was wondering about this before you commented but it might be best to leave to flushing/invalidating to the caller. I imagine some folks might not even be using the cache and might only access PSRAM via DMA.
Do you happen to know how big this is? |
Not off-hand but for esp32 its 32 bytes and I think there is a rom function for it on the esp32s3. (https://esp32.com/viewtopic.php?t=33059) Also DMA to psram already requires a block size alignment of 16/32/64 bytes (selectable). So requiring cachline alignment may not be an additional burden. Maybe and the cache line can be set to 16/32/64 bytes (from the TRM)
|
This (#954) is related. In this PR I've enforced that the buffers and sizes be cacheline (block) aligned. |
87c07ec
to
5fea03e
Compare
Code looks good to me and the example is working fine! Maybe the alignment restrictions need some documentation - I guess it's hard to figure them out as a user otherwise |
1195c9b
to
e2b1b28
Compare
Added a note |
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, I left a few nitpick typo suggestions in docs.
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.
Thanks, 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
Implement DMA access to psram on the esp32s3 (TRM says its supported)
TODO:
implement errata forcache_writeback_addr()
Testing
Run dma_extmem2mem example