From f156c7c6d1e7832eb75f9e80b1922f7e064f8b0d Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 6 Aug 2017 19:52:11 +0800 Subject: [PATCH] print panic messages on UART --- firmware/Cargo.toml | 2 +- firmware/src/main.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/firmware/Cargo.toml b/firmware/Cargo.toml index ec00b96..2ef1c05 100644 --- a/firmware/Cargo.toml +++ b/firmware/Cargo.toml @@ -5,7 +5,7 @@ authors = ["whitequark "] [dependencies] cortex-m = "0.3.1" -cortex-m-rt = { version = "0.3.5", features = ["abort-on-panic"] } +cortex-m-rt = { version = "0.3.5" } [dependencies.tm4c129x] git = "https://github.com/m-labs/dslite2svd" diff --git a/firmware/src/main.rs b/firmware/src/main.rs index ba0883a..05e9864 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -1,4 +1,4 @@ -#![feature(used, const_fn, core_float, asm)] +#![feature(used, const_fn, core_float, asm, lang_items)] #![no_std] extern crate cortex_m; @@ -30,6 +30,13 @@ macro_rules! println { ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); } +#[no_mangle] +#[lang = "panic_fmt"] +fn panic_fmt(args: core::fmt::Arguments, file: &'static str, line: u32) -> ! { + println!("panic at {}:{}: {}", file, line, args); + loop {} +} + #[macro_use] mod board; mod ethmac;