14 Commits
sh ... bt_limit

Author SHA1 Message Date
Emil Fresk
73bae533c4 Added backtrace limit to mitigate infinite backtraces 2019-02-05 20:17:20 +01:00
Emil Fresk
ac344b967f Merge pull request #66 from jacobrosenthal/patch-1
update interrupt usage
2019-01-30 19:54:09 +01:00
Jacob Rosenthal
c6599f3686 update interrupt usage 2019-01-29 15:12:07 -07:00
Adam Greig
3aa5ea9fd3 Merge pull request #64 from sstelfox/fix_breakpoint
Adjust the default breakpoint name to match cortex-m-rt pull #144
2019-01-22 08:38:49 +00:00
Sam Stelfox
26baac1bf3 Adjust the default breakpoint name to match cortex-m-rt pull #144 2019-01-21 23:39:45 -05:00
Emil Fresk
2d7405fc04 Merge pull request #61 from rubberduck203/tests
Add example of writing tests that run on host machine
2019-01-01 11:34:22 +01:00
Christopher J. McClellan
e58549b2ec Add more documentation for testing on host 2018-12-31 07:01:16 -05:00
Emil Fresk
9ee8b84217 Merge pull request #62 from rubberduck203/coc
Fixes code of conduct link.
2018-12-31 11:35:55 +01:00
Christopher J. McClellan
0e2aadf8f2 Make sure we can actually test prod code 2018-12-30 19:55:24 -05:00
Christopher J. McClellan
e7138e0e2a Fixes code of conduct link.
Closes #60
2018-12-30 19:24:24 -05:00
Christopher J. McClellan
c142db6e23 Add example of writing tests that run on host machine 2018-12-30 19:17:58 -05:00
Emil Fresk
207bca35f4 Merge pull request #59 from rust-embedded/loop_crash_fix
Workaround for loop {} until it is fixed
2018-11-20 15:33:23 +01:00
Emil Fresk
f9570c7c65 Workaround for loop {} until it is fixed 2018-11-20 07:58:38 +01:00
Adam Greig
f47d1633af Merge pull request #57 from rust-embedded/sh
use hprint macros and NVIC::pend; fix allocator example
2018-11-10 00:10:46 +00:00
5 changed files with 67 additions and 9 deletions

View File

@@ -125,5 +125,5 @@ Contribution to this crate is organized under the terms of the [Rust Code of
Conduct][CoC], the maintainer of this crate, the [Cortex-M team][team], promises
to intervene to uphold that code of conduct.
[CoC]: CODE_OF_CONDUCT.md
[CoC]: https://www.rust-lang.org/policies/code-of-conduct
[team]: https://github.com/rust-embedded/wg#the-cortex-m-team

View File

@@ -5,9 +5,6 @@
//!
//! [`svd2rust`]: https://crates.io/crates/svd2rust
//!
//! Device crates also provide an `interrupt!` macro (behind the "rt" feature) to register interrupt
//! handlers.
//!
//! This example depends on the [`stm32f103xx`] crate so you'll have to add it to your Cargo.toml.
//!
//! [`stm32f103xx`]: https://crates.io/crates/stm32f103xx
@@ -55,9 +52,7 @@ fn main() -> ! {
}
}
// try commenting out this line: you'll end in `default_handler` instead of in `exti0`
interrupt!(EXTI0, exti0);
fn exti0() {
#[interrupt]
fn EXTI0() {
hprint!(".").unwrap();
}

57
examples/test_on_host.rs Normal file
View File

@@ -0,0 +1,57 @@
//! Conditionally compiling tests with std and our executable with no_std.
//!
//! Rust's built in unit testing framework requires the standard library,
//! but we need to build our final executable with no_std.
//! The testing framework also generates a `main` method, so we need to only use the `#[entry]`
//! annotation when building our final image.
//! For more information on why this example works, see this excellent blog post.
//! https://os.phil-opp.com/unit-testing/
//!
//! Running this example:
//!
//! Ensure there are no targets specified under `[build]` in `.cargo/config`
//! In order to make this work, we lose the convenience of having a default target that isn't the
//! host.
//!
//! cargo build --example test_on_host --target thumbv7m-none-eabi
//! cargo test --example test_on_host
#![cfg_attr(test, allow(unused_imports))]
#![cfg_attr(not(test), no_std)]
#![cfg_attr(not(test), no_main)]
// pick a panicking behavior
#[cfg(not(test))]
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
// extern crate panic_abort; // requires nightly
// extern crate panic_itm; // logs messages over ITM; requires ITM support
// extern crate panic_semihosting; // logs messages to the host stderr; requires a debugger
use cortex_m::asm;
use cortex_m_rt::entry;
#[cfg(not(test))]
#[entry]
fn main() -> ! {
asm::nop(); // To not have main optimize to abort in release mode, remove when you add code
loop {
// your code goes here
}
}
fn add(a: i32, b: i32) -> i32 {
a + b
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn foo() {
println!("tests work!");
assert!(2 == add(1,1));
}
}

View File

@@ -3,9 +3,12 @@ target extended-remote :3333
# print demangled symbols
set print asm-demangle on
# set backtrace limit to not have infinite backtrace loops
set backtrace limit 32
# detect unhandled exceptions, hard faults and panics
break DefaultHandler
break UserHardFault
break HardFault
break rust_begin_unwind
# *try* to stop at the user entry point (it might be gone due to inlining)

View File

@@ -7,10 +7,13 @@ extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to c
// extern crate panic_itm; // logs messages over ITM; requires ITM support
// extern crate panic_semihosting; // logs messages to the host stderr; requires a debugger
use cortex_m::asm;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
asm::nop(); // To not have main optimize to abort in release mode, remove when you add code
loop {
// your code goes here
}