-
Notifications
You must be signed in to change notification settings - Fork 344
sdio: initial SDIO HAL implementation #3503
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
base: main
Are you sure you want to change the base?
Conversation
b7eeb4c
to
2142d4d
Compare
dddf388
to
c3a7b0d
Compare
Running the As I get closer to a full implementation, I may need to bring in the What's strange is that running I'll keep debugging. |
It would be best to not block this PR on embedded-hal, as it'll likely take months to stabilize a new set of traits. You should instead demonstrate new functionality in a new crate, like That way you wouldn't have to patch around the dependency issues with multiple embedded-hal versions in the same project. |
To expand on @bugadani's comment, we can't merge this with git dependencies, so I would take the suggestion to split this into a separate crate and then work on upstreaming to eh proper. Feel free to iterate here in the mean time, but if you want this merged it won't be with a fork of embedded-hal. |
This sounds like a good plan. I'll bring it up in next week's meeting, and see what the rest of the HAL team thinks.
Right, I had no intention of trying to get this PR merged with the git dependency. My original thought process was to prove the implementation here and in However, the solution discussed above sounds like a better plan. We could do a Without trying to bikeshed too much, we would probably need to call it |
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
I added the remaining functions needed for the SDIO Not sure about the best way to approach SOC-specific methods (i.e. the One design I though of was to add a @Dominaezzz @MabezDev @bugadani thoughts? |
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
6ce6b2f
to
69ec4b9
Compare
Regarding the low level stuff, see #1282 . Whilst esp-idf serves as a (mostly reliable) working reference, its design decisions (which were made for a C library) shouldn't be copied directly (into a Rust hal). Check out what the stable(izing) drivers (SPI, I2C, UART, GPIO) are doing to get an idea of what to do. Also the dev guidelines is another place to check. imo, for chip-based differences, |
Agreed, I kept the relative structure of the code the same. It should hopefully make reviewing the code easier, since the mapping from the Rust back to the
This is the approach I ended up going with, which can hopefully be extended pretty easily as more SDIO-having SOCs are added. |
f075cd5
to
bc0c396
Compare
Adds DMA descriptor types based on the main DMA engine descriptors. The main difference is the bitfield layout used in the descriptor flags.
Adds the `DescriptorFlagFields` trait to generalize field accessor functions for descriptor flag types. Enables using a generic parameter for `DmaDescriptor`.
Implements the `DescriptorFlagFields` trait for the relevant types. Small refactors to handle function naming differences.
Adds some methods to the `Owner` type for better ergonomics.
Refactors the `DmaDescriptor` type to `DmaDescriptorGeneric` taking a generic parameter for the flags field. Creates convenience aliases for the concrete types used in the general + SDIO dedicated DMA descriptors.
Makes the `Preparation` type generic over the `DescriptorFlagFields` trait.
Maks `DmaLoopBuf` generic over the `DescriptorFlagFields` trait.
Makes the `DmaRxStreamingBuf` type generic over the `DescriptorFieldFlags` trait.
Makes the `DescriptorSet` type generic over the `DescriptorFlagFields` trait.
Makes the `DmaTxBuf` generic over the `DescriptorFlagFields` trait.
Makes the `DmaRxBuf` generic over the `DescriptorFlagFields` trait.
Makes the `DmaRxTxBuf` type generic over the `DescriptorFlagFields` trait.
Makes the `ChannelTx` struct generic over the `DescriptorFlagFields` trait.
Use the `EnumSetType` derive macro, and `EnumSet` type for the `HostInterrupt` and `DeviceInterrupt` types to match current development conventions.
Removes `Generic` suffix from generic DMA types. Replaces default type aliases with a default concrete type in the generic parameter declaration. Authored-by: rmsyn <[email protected]> Co-authored-by: Dominic Fischer <[email protected]>
Adds a generic paramter for the descriptor flags for the `ChannelRx` type.
Makes the `DmaTxBuffer` generic over the `DescriptorFlagFields` trait.
Makes the `DmaRxBuffer` trait generic over the `DescriptorFlagFields` trait.
Uses consistent naming + formatting for descriptor flag generic parameters.
To avoid a semver bump, re-add the `set_length` methods to `DmaDescriptorFlags` and `DmaDescriptor`.
Adds the `AtomicDmaDescriptor` type to enable safely storing DMA descriptors in static variables.
Adds the `AtomicBuffer` type to allow storing byte buffers safely in static variables.
Adds the `bitfielder` library as a more performant and ergonomic bitfield library.
Adds SDIO commands supported by ESP SDIO controllers.
Adds the SD and SPI mode `R5` response types, and the corresponding field types.
Adds `Sdio::read_command_raw` + `Sdio::write_response_raw` functions to read and write raw data on the `CMD` line. TODO: add SDIO mode implementations NOTE: these functions may be unecessary, the controller seems to handle command/response in hardware (at least in SPI mode).
Adds a split `qa-test` SPI-mode SDIO integration test. The tests are split with the intention to flash each half of the test to separate devices, allowing for concurrent execution.
ec263a8
to
e5c9931
Compare
Apologies for stalling on this, I was waiting on 10kOhm resistors to arrive, and they did last week. I added them to the bench circuit, but they didn't help. The device still returns garbage to the host using SDIO in SPI-mode. I'm honestly at a loss for what else to even try. The communication at this phase of the SDIO protocol is all happening in hardware in the SPI and SDIO DMA engines, so it feels like even hooking something like Edit: there does appear to be a GPIO IRQ firing on the SDIO device side, so maybe I need to setup a handler? From our discussions before, I thought that the low-level SDIO protocol was handled in hardware because any software would be too slow (including an IRQ handler). Am I missing something? |
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
Provides the initial skeleton for the
embedded_hal::mmc::MmcOps
implementation for the SDIO peripherals on the ESP32C6 microcontroller.Testing
Doc tests for now.
Integration tests via
examples
program is WIP.