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

stm32: Improve dualcore safety #3687

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Write the flag sooner with a known value
  • Loading branch information
diondokter committed Dec 25, 2024
commit 595ce48eb2be88a42ceb33865c337020a328a4dd
5 changes: 5 additions & 0 deletions embassy-stm32/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ mod dual_core {
pub fn init_primary(config: Config, shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {
let shared_data = unsafe { shared_data.assume_init_ref() };

// Write the flag as soon as possible. Reading this flag uninitialized in the `init_secondary`
// is maybe unsound? Unclear. If it is indeed unsound, writing it sooner doesn't fix it all,
// but improves the odds of it going right
shared_data.init_flag.store(0, Ordering::SeqCst);

rcc::set_freqs_ptr(shared_data.clocks.get());
let p = init_hw(config);

Expand Down
Loading