diff --git a/src/start/panicking.md b/src/start/panicking.md index 139d09f..9e7626b 100644 --- a/src/start/panicking.md +++ b/src/start/panicking.md @@ -81,7 +81,7 @@ use cortex_m_rt::entry; fn main() -> ! { let xs = [0, 1, 2]; let i = xs.len() + 1; - let y = xs[i]; // out of bounds access + let _y = xs[i]; // out of bounds access loop {} } diff --git a/src/start/registers.md b/src/start/registers.md index c963154..b909b31 100644 --- a/src/start/registers.md +++ b/src/start/registers.md @@ -26,15 +26,18 @@ use cortex_m::peripheral::{syst, Peripherals}; use cortex_m_rt::entry; #[entry] -fn main() { +fn main() -> ! { let mut peripherals = Peripherals::take().unwrap(); let mut systick = peripherals.SYST; systick.set_clock_source(syst::SystClkSource::Core); + systick.set_reload(1_000); systick.clear_current(); systick.enable_counter(); - while systick.get_current() < 1_000 { + while !systick.has_wrapped() { // Loop } + + loop {} } ``` diff --git a/src/start/semihosting.md b/src/start/semihosting.md index 6ebf25e..3a7d6dd 100644 --- a/src/start/semihosting.md +++ b/src/start/semihosting.md @@ -18,8 +18,6 @@ world!": extern crate panic_halt; -use core::fmt::Write; - use cortex_m_rt::entry; use cortex_m_semihosting::hprintln; @@ -41,6 +39,12 @@ Hello, world! (..) ``` +You do need to enable semihosting in OpenOCD from GDB first: +``` console +(gdb) monitor arm semihosting enable +semihosting is enabled +``` + QEMU understands semihosting operations so the above program will also work with `qemu-system-arm` without having to start a debug session. Note that you'll need to pass the `-semihosting-config` flag to QEMU to enable semihosting