mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-01-24 14:58:09 +00:00
add a compiler fence before exiting
the rtt-target implementation is light on compiler fences so the compiler could be doing unwanted reordering of memory operations. At least patch up a place where these orderings may result in an observable change of behavior
This commit is contained in:
parent
9c1e496ef5
commit
80cb2caa09
1 changed files with 3 additions and 1 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
ops,
|
ops,
|
||||||
sync::atomic::{AtomicU32, Ordering},
|
sync::atomic::{self, AtomicU32, Ordering},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -302,6 +302,8 @@ fn RTC0() {
|
||||||
/// Cargo runner
|
/// Cargo runner
|
||||||
pub fn exit() -> ! {
|
pub fn exit() -> ! {
|
||||||
log::info!("`dk::exit() called; exiting ...`");
|
log::info!("`dk::exit() called; exiting ...`");
|
||||||
|
// force any pending memory operation to complete before the BKPT instruction that follows
|
||||||
|
atomic::compiler_fence(Ordering::SeqCst);
|
||||||
loop {
|
loop {
|
||||||
asm::bkpt()
|
asm::bkpt()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue