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

Does this actually compile with current rust version? #346

Open
planck-length opened this issue Oct 10, 2024 · 1 comment
Open

Does this actually compile with current rust version? #346

planck-length opened this issue Oct 10, 2024 · 1 comment

Comments

@planck-length
Copy link

I tried to fork and run cargo build --features stm32l476 but got like 5 similar errors

error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
   --> src/spi.rs:271:34
    |
271 |                           unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut u8, byte) }
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'm new to embedded rust so maybe I'm missing some steps before building. Any help appreciated thank you!!

@BillKills974
Copy link

BillKills974 commented Oct 30, 2024

Hi,
Rust 1.73 rules made this cast "illegal".
Use instead in spi.rs, qspi.rs and serial.rs
unsafe { ptr::write_volatile(UnsafeCell::raw_get(&self.spi.dr as *const _ as *mut _), byte) }
don't forget to import core::cell::UnsafeCell

the same will apply to read_volatile.

Feel free to check my fork here

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

No branches or pull requests

2 participants