Skip to content

Commit

Permalink
src/riot-rs-rt: use proper semihosting exit codes
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Nov 14, 2023
1 parent 219704e commit 817ff14
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/riot-rs-rt/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ mod backend {

#[cfg(all(feature = "debug-console", feature = "rtt-target"))]
mod backend {
const SYS_EXIT: u32 = 0x18;
pub const EXIT_SUCCESS: Result<(), ()> = Ok(());
pub const EXIT_FAILURE: Result<(), ()> = Err(());
pub fn exit(_code: Result<(), ()>) {
pub fn exit(code: Result<(), ()>) {
let semihosting_exit_code = match code {
EXIT_FAILURE => 1,
EXIT_SUCCESS => 0x20026,
};

loop {
cortex_m::asm::bkpt();
unsafe { cortex_m::asm::semihosting_syscall(SYS_EXIT, semihosting_exit_code) };
}
}
pub use rtt_target::rprint as print;
Expand Down

0 comments on commit 817ff14

Please sign in to comment.