Skip to content
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

Update embedded hal to 1.0.0 #106

Conversation

AnyTimeTraveler
Copy link
Contributor

@AnyTimeTraveler AnyTimeTraveler commented Oct 22, 2023

This is based on thejpster's Pull Request #103.

The changes are suprisingly trivial.
Except for one occasion, only where-clauses needed to be adjusted.

I need to work with an ESP32C6, which has already updated to this version in a feature gate.

@thejpster
Copy link
Member

@AnyTimeTraveler would you mind looking at the pipeline failures?

@fu5ha
Copy link
Contributor

fu5ha commented Oct 29, 2023

According to the docs of SpiDevice, the SpiDevice impl itself is meant to take ownership of the CS pin, and that the implementations must first assert CS pin, then perform transaction, then deassert CS pin for every call to transaction (and all other methods just defer to that implementation). This is incompatible with the current signature of SdCard in that it also expects the CS pin separately, in order to meet the requirement to clock with CS deasserted in order to get the SDMMC device to actually let go of the Spi bus, as mentioned in the SdCard docs and SD/MMC physical layer spi spec.

There's a couple possible ways to solve this. The one that would mean the least required changes to this library and I think should work well would be to encourage the use of DummyCsPin in the creation of the SpiDevice impl that gets passed to creation of SdCard such that the real CS pin is owned by SdCard and can be managed manually separately, as we desire.

@AnyTimeTraveler
Copy link
Contributor Author

@AnyTimeTraveler would you mind looking at the pipeline failures?

Yes, I will. I'm currently still planning on testing this with my ESP32C6 to make sure that the update didn't break anything.

@AnyTimeTraveler
Copy link
Contributor Author

@fu5ha I looked at complying with this new way of doing transactions and have found them incompatible with how the crate uses the SPI CS pin at the moment.
I agree with your approach.
I have not looked into the SD Card SPI protocol in enough depth to determine, wether the CS pin actualy needs to be held active for as long as the crate is holding it.
Maybe there is a way to handle this differently?
I will most likely move forward eith the current implementation and just use a Dummy CS Pin.

@fu5ha
Copy link
Contributor

fu5ha commented Oct 30, 2023

I've opened AnyTimeTraveler#1 which makes a public DummyCsPin and documents its use but you could also just cherry-pick 4d3aa31 into this branch.

@AnyTimeTraveler
Copy link
Contributor Author

Thank you very much! I will try to find time to work on this tonight.

# Conflicts:
#	examples/readme_test.rs
#	src/sdcard/mod.rs
@thejpster
Copy link
Member

Another solution is to require two SpiDevice objects. One which actually selects the SD card, and one which does not. You would just send out dummy bytes to the second one to get the SD card into SPI mode.

@thejpster
Copy link
Member

Talking on the matrix channel, I'm told the correct solution is to take exclusive ownership of the SpiBus whilst we want to clock out the init sequence. How that works in practice I'm not sure.

@AnyTimeTraveler
Copy link
Contributor Author

@thejpster I have a pretty good idea how to implement the proper solution.
It'll probably take a week or so. I don't have much free time right now.

What matrix channel were you talking about? That sounds useful to join.

@thejpster
Copy link
Member

@thejpster
Copy link
Member

Also it has been suggested that once we've worked out how to do this, the Embedded-HAL v1.0 docs will be updated to point here as an example.

@thejpster
Copy link
Member

Have you had a chance to look at this? I think we're expecting Embedded HAL 1.0 to drop on 2023-12-28, with Rust 1.75.

@thejpster thejpster mentioned this pull request Dec 17, 2023
@AnyTimeTraveler
Copy link
Contributor Author

Sorry, I wish I had more time at the moment, but I had to put this on hold.
I expect to have more time at the start of February.
I do want to finish this, so I might squeeze it in before Christmas, but I can't promise anything.

@luojia65
Copy link

luojia65 commented Jan 10, 2024

Any further works on this pull request? embedded-hal 1.0.0 (no -rc.1!) is released. If you don't feel like having enough time working on this, I can take forward (by sending PRs to your repo, or other methods); our team will test it on RustSBI and RISC-V firmware ecosystem when moving on. @AnyTimeTraveler

Signed-off-by: jakezhu9 <zjx1319@hust.edu.cn>
@jakezhu9
Copy link
Contributor

@luojia65 and me have followed your work to update embedded-hal dependency to version 1.0.0. We sent a pull request to your repository: AnyTimeTraveler#2. Please have a look, hope this helps :)

@AnyTimeTraveler
Copy link
Contributor Author

Any further works on this pull request?

Not from me, but I see your PR and will check it out tonight.
If it turns out that more work is required, I would not mind at all @luojia65 taking over :)

@AnyTimeTraveler AnyTimeTraveler changed the title Update embedded hal to 1.0.0-rc.1 Update embedded hal to 1.0.0 Jan 11, 2024
@AnyTimeTraveler
Copy link
Contributor Author

Just tested locally and this should be ready to merge.
All tests are passing :)

src/lib.rs Outdated Show resolved Hide resolved
@AnyTimeTraveler
Copy link
Contributor Author

This PR should be good to go now.
Please poke me, if I have missed something :)

If we put it in a function we need much less boiler plate to make it compile.
@jonathanpallant jonathanpallant added this pull request to the merge queue Jan 12, 2024
@jonathanpallant
Copy link
Collaborator

Thank you!

Merged via the queue into rust-embedded-community:develop with commit e7ef46f Jan 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants