Open Tschrock opened 2 months ago
I guess the most straight forward solution to fix this regression would be to add a feature-flag for AtomicDevice
. We did the same thing back in shared-bus
to cater for platforms without the necessary atomics support.
Another solution would be to allow using AtomicDevice
on single-core microcontrollers by use of critical sections instead of real atomics. Not sure how best to expose this API-wise, though.
Also, maybe a lesson learned from this regression could be that we need to set up CI infrastructure in embedded-hal
to check builds on all relevant targets? There may be more subtle incompatibilities between platforms that could hit in this way, I think.
I have stumbled upon this issue right now. Is there any workaround for the time being?
Because AtomicDevice uses the portable-atomic crate, you can enable support for CAS on targets that don't normally have it with either the critical-section or unsafe-assume-single-core features: https://crates.io/crates/portable-atomic#optional-features-critical-section
Having to add an explicit dependency on portable-atomic and enable the feature just to get this crate to build isn't great, but it should work as a workaround now.
We discussed this in today's meeting and the plan is:
Added
embedded-hal-bus = "0.2.0"
to my project and it failed to build. Using targetthumbv7m-none-eabi
works, using targetthumbv6m-none-eabi
fails. Version 0.1.0 works.Trying to build the latest
master
branch:Seems to be caused by #593
https://github.com/rust-embedded/embedded-hal/blob/a0ccb6579669804e9be723912ed645a16362c8a6/embedded-hal-bus/src/spi/atomic.rs#L125-L133
https://github.com/rust-embedded/embedded-hal/blob/a0ccb6579669804e9be723912ed645a16362c8a6/embedded-hal-bus/src/i2c/atomic.rs#L120-L128
ARMv6-M does not have atomic CAS, so
portable_atomic
does not implementAtomicBool::compare_exchange
on this target.