From 9c6bcd2ee8fdb7f29ea050dacf882cf742aea7e0 Mon Sep 17 00:00:00 2001 From: Michael Mogenson Date: Thu, 14 Mar 2019 10:37:41 -0400 Subject: [PATCH 1/3] Use panic-halt crate, panic-abort requires nightly toolchain features When trying to follow the Getting Started->Building instructions, the `panic-abort` crate throws the following build error on rust stable version 1.33: ``` Compiling panic-abort v0.3.1 error[E0554]: #![feature] may not be used on the stable release channel --> /home/mike/.cargo/registry/src/github.com-1ecc6299db9ec823/panic-abort-0.3.1/src/lib.rs:22:1 | 22 | #![feature(core_intrinsics)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0554]: #![feature] may not be used on the stable release channel --> /home/mike/.cargo/registry/src/github.com-1ecc6299db9ec823/panic-abort-0.3.1/src/lib.rs:23:1 | 23 | #![feature(panic_handler)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0554`. error: Could not compile `panic-abort`. To learn more, run the command again with --verbose. ``` Switch to the `panic-halt` crate that builds on stable and provides the `#[panic_handler]` function necesary to get a minimal successful build. --- src/getting-started/01.00.BUILD.md | 12 ++++++------ src/getting-started/Cargo.toml | 2 +- src/getting-started/src/main.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/getting-started/01.00.BUILD.md b/src/getting-started/01.00.BUILD.md index 83a6688..c49dc12 100644 --- a/src/getting-started/01.00.BUILD.md +++ b/src/getting-started/01.00.BUILD.md @@ -116,7 +116,7 @@ If you have forgotten how to do this, try looking at [the cargo book][cargo]. ``` rust #![no_std] -extern crate panic_abort; +extern crate panic_halt; fn main() { } @@ -141,8 +141,8 @@ neither the crt0 nor the rust runtime are available, so even implementing `start` would not help us. We need to replace the operating system entry point. -You could for example name a function after the default entry point, -which for linux is `_start`, and start that way. +You could for example name a function after the default entry point, +which for linux is `_start`, and start that way. Note, you would also need to disable [name mangling][nm]: ``` rust @@ -232,11 +232,11 @@ and cargo will automatically add `--target thumbv6m-none-eabi`. ### `src/main.rs` -``` rust +``` rust #![no_std] #![no_main] -extern crate panic_abort; +extern crate panic_halt; use cortex_m_rt::entry; @@ -271,7 +271,7 @@ An easy way to implement this is to use an infinite loop. #![no_std] #![no_main] -extern crate panic_abort; +extern crate panic_halt; use cortex_m_rt::entry; diff --git a/src/getting-started/Cargo.toml b/src/getting-started/Cargo.toml index 186ff92..c62f106 100644 --- a/src/getting-started/Cargo.toml +++ b/src/getting-started/Cargo.toml @@ -3,6 +3,6 @@ name = "start" version = "0.2.0" [dependencies] -panic-abort = "~0.3" +panic-halt = "~0.2" microbit="~0.6" cortex-m-rt="~0.6" diff --git a/src/getting-started/src/main.rs b/src/getting-started/src/main.rs index db8c9ce..9937665 100644 --- a/src/getting-started/src/main.rs +++ b/src/getting-started/src/main.rs @@ -3,7 +3,7 @@ extern crate cortex_m_rt; extern crate microbit; -extern crate panic_abort; +extern crate panic_halt; use cortex_m_rt::entry; From 78bf6ff538aa9fa3cd74221812340c1215fdff36 Mon Sep 17 00:00:00 2001 From: Michael Mogenson Date: Thu, 14 Mar 2019 10:47:26 -0400 Subject: [PATCH 2/3] Remove semicolon after #[entry] Otherwise you get the following build error: ``` error: expected item after attributes --> src/main.rs:8:8 | 8 | #[entry]; | ^ ``` This one confused me for awhile. --- src/getting-started/01.00.BUILD.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getting-started/01.00.BUILD.md b/src/getting-started/01.00.BUILD.md index c49dc12..4ed17e7 100644 --- a/src/getting-started/01.00.BUILD.md +++ b/src/getting-started/01.00.BUILD.md @@ -240,7 +240,7 @@ extern crate panic_halt; use cortex_m_rt::entry; -#[entry]; +#[entry] fn main() { } ``` From feec6bfb2a8cd7230f9ceeffef9b025ca9f46538 Mon Sep 17 00:00:00 2001 From: Michael Mogenson Date: Thu, 14 Mar 2019 10:49:41 -0400 Subject: [PATCH 3/3] Bump microbit crate version to the latest: ~0.7 --- src/getting-started/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getting-started/Cargo.toml b/src/getting-started/Cargo.toml index c62f106..17270b2 100644 --- a/src/getting-started/Cargo.toml +++ b/src/getting-started/Cargo.toml @@ -4,5 +4,5 @@ version = "0.2.0" [dependencies] panic-halt = "~0.2" -microbit="~0.6" +microbit="~0.7" cortex-m-rt="~0.6"