stm32l4xx-hal icon indicating copy to clipboard operation
stm32l4xx-hal copied to clipboard

Does this actually compile with current rust version?

Open planck-length opened this issue 1 year ago • 1 comments

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!!

planck-length avatar Oct 10 '24 17:10 planck-length

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

BillKills974 avatar Oct 30 '24 09:10 BillKills974