aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt
diff options
context:
space:
mode:
Diffstat (limited to 'cortex-m-rt')
-rw-r--r--cortex-m-rt/examples/qemu.rs30
-rw-r--r--cortex-m-rt/link.x.in2
-rw-r--r--cortex-m-rt/src/lib.rs2
3 files changed, 16 insertions, 18 deletions
diff --git a/cortex-m-rt/examples/qemu.rs b/cortex-m-rt/examples/qemu.rs
index e903404..a8ffd20 100644
--- a/cortex-m-rt/examples/qemu.rs
+++ b/cortex-m-rt/examples/qemu.rs
@@ -1,28 +1,24 @@
-// #![feature(stdsimd)]
#![no_main]
#![no_std]
-extern crate cortex_m;
-extern crate cortex_m_rt as rt;
-extern crate cortex_m_semihosting as semihosting;
+use core::fmt::Write;
-extern crate panic_halt;
-
-use cortex_m::asm;
-use rt::entry;
-
-#[entry]
+#[cortex_m_rt::entry]
fn main() -> ! {
- use core::fmt::Write;
let x = 42;
loop {
- asm::nop();
-
- // write something through semihosting interface
- let mut hstdout = semihosting::hio::hstdout().unwrap();
+ let mut hstdout = cortex_m_semihosting::hio::hstdout().unwrap();
write!(hstdout, "x = {}\n", x).unwrap();
- // exit from qemu
- semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS);
+ cortex_m_semihosting::debug::exit(cortex_m_semihosting::debug::EXIT_SUCCESS);
+ }
+}
+
+// Define a panic handler that uses semihosting to exit immediately,
+// so that any panics cause qemu to quit instead of hang.
+#[panic_handler]
+fn panic(_: &core::panic::PanicInfo) -> ! {
+ loop {
+ cortex_m_semihosting::debug::exit(cortex_m_semihosting::debug::EXIT_FAILURE);
}
}
diff --git a/cortex-m-rt/link.x.in b/cortex-m-rt/link.x.in
index 92004b7..deff376 100644
--- a/cortex-m-rt/link.x.in
+++ b/cortex-m-rt/link.x.in
@@ -66,6 +66,8 @@ SECTIONS
/* ### Vector table */
.vector_table ORIGIN(FLASH) :
{
+ __vector_table = .;
+
/* Initial Stack Pointer (SP) value */
LONG(_stack_start);
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index 793b928..1e977c6 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/src/lib.rs
@@ -439,9 +439,9 @@
extern crate cortex_m_rt_macros as macros;
-use core::fmt;
#[cfg(cortex_m)]
use core::arch::global_asm;
+use core::fmt;
// HardFault exceptions are bounced through this trampoline which grabs the stack pointer at
// the time of the exception and passes it to th euser's HardFault handler in r0.