I am trying to cross compile for thumbv6m-none-eabi for raspberry pico. When I load rppal for the gpio, it loads lazy_static, which uses spin. Compile fails before reaching my code with "'compare_exchange_weak' not found for struct ' AtomicBool' in the current scope".
Spin is v0.9.8
Cortex-m-rt is v0.6.15
Lazy_static is 1.5.0 with feature spin_no_std
Any ideas where to go? This is my first Rust cross compile so please forgive my naivety.
TIA
ARM targets with thumbv6m only provide load and store operations, and do not support Compare and Swap (CAS) operations, such as swap, fetch_add, etc.
compare_exchange_weak is one of those CAS operations. The crate would need to implement its algorithm in some other way in order to support those platforms.
I don't think you can really do something about this, except ask the libraray maintainer if they can change their code or not use the library.
I searched the code of the crates you listed and compare_exchange_weak is being used by spin.
I would expect a library that's written for the raspberry to not use instructions that aren't available on it, that wouldn't really make sense.
So i don't think you need to change your raspberry IO library.
Thanks for the reply luca3s. I am not directly using those features. They are brought in by the rppal library, which implements the Raspberry gpio functions.
The rppal crate doesn't support Raspberry Pi Pico (rp2040 or rp2350 microcontroller). It supports the line of Raspberry Pi single board computers which run Linux.
You probably want to use the rp-pac crate, or even better, embassy.
Thanks! My Google search for pi gpio in Rust didn't turn up either of those. I am putting in sysfs_gpio now for testing, but will definitely try those as well. Let you know how it goes....
The wrinkle is "no_std" methinks.
no_std is alright. Just a bit of a different mindset. When you need String or collections (Vec, HashMap, etc.) there are crates like heapless for those kinds of data structures.
The initial problem I had with Pico specifically is that I was stubborn and didn't want to use the debug probe. It already has USB, why not use that? I don't know of any open-source projects that encapsulate all of the work required for it, but postcard-rpc comes pretty close! Their examples already use embassy. It's a good starting point.