Code Monkey home page Code Monkey logo

Comments (7)

japaric avatar japaric commented on July 21, 2024 1

Sorry for the trouble and the delay. #86 has updated the whole book to work with the latest version of the cortex-m crates as well as with recent nightlies.

from discovery.

dholth avatar dholth commented on July 21, 2024

Which nightly should we install so that it still works?

from discovery.

MaxStrange avatar MaxStrange commented on July 21, 2024

I've been using nightly-2018-05-20, but I'd guess most nightlies that are around the latest code commits in this repo would work.

from discovery.

dholth avatar dholth commented on July 21, 2024

2018-06-01 works too. rustup default nightly-2018-06-01

from discovery.

AJAnderson avatar AJAnderson commented on July 21, 2024

How do we fix this? part of the problem is that the cargo.toml specifies an older version of cortex-m-rt, which you can fix naively by going to the source and adding #![feature(panic_implementation)], but looking at more recent versions of cortex-m-rt it looks totally different.

from discovery.

droogmic avatar droogmic commented on July 21, 2024

Rolling back versions is a short term solution which I would rather not do. Seeing as new versions of cortex-m-rt have removed the abort-on-panic feature, I thought I would try removing it, adding the panic-abort crate, and bumping all the versions (all in 05/auxiliary/Cargo.toml). It still doesn't build though, so not sure how to fix it:

error: language item required, but not found: `panic_impl`
[package]
authors = ["Jorge Aparicio <[email protected]>"]
name = "aux5"
version = "0.2.0"

[dependencies]
cortex-m = "~0.5.2"
cortex-m-rt = "~0.5.1"
panic-abort = "~0.2"

[dependencies.f3]
features = ["rt"]
version = "~0.6.1"

from discovery.

eldruin avatar eldruin commented on July 21, 2024

This just bit me on chapter 16 as well.
I was able to get it to compile by adapting the panic implementation (see diff)

diff --git a/src/16-punch-o-meter/auxiliary/src/lib.rs b/src/16-punch-o-meter/auxiliary/src/lib.rs
index 5484cd7..e268ec8 100644
--- a/src/16-punch-o-meter/auxiliary/src/lib.rs
+++ b/src/16-punch-o-meter/auxiliary/src/lib.rs
@@ -2,6 +2,7 @@
 
 #![feature(lang_items)]
 #![feature(use_extern_macros)]
+#![feature(panic_implementation)]
 #![no_std]
 
 extern crate cortex_m;
@@ -49,20 +50,17 @@ pub fn init() -> (Lsm303dlhc, Delay, MonoTimer, ITM) {
     (lsm303dlhc, delay, mono_timer, cp.ITM)
 }
 
-#[lang = "panic_fmt"]
-unsafe extern "C" fn panic_fmt(
-    args: ::core::fmt::Arguments,
-    file: &'static str,
-    line: u32,
-    col: u32,
-) -> ! {
-    let itm = &mut *ITM::ptr();
-
-    itm::write_str(&mut itm.stim[0], "PANIC at '");
-    itm::write_fmt(&mut itm.stim[0], args);
-    iprintln!(&mut itm.stim[0], "', {}:{}:{}", file, line, col);
-
+use core::panic::PanicInfo;
+#[panic_implementation]
+fn panic(_info: &PanicInfo) -> ! {
+    unsafe {
+        let itm = &mut *ITM::ptr();
+
+        let location = _info.location().unwrap();
+        itm::write_str(&mut itm.stim[0], "PANIC at '");
+        itm::write_str(&mut itm.stim[0], _info.payload().downcast_ref::<&str>().unwrap());
+        iprintln!(&mut itm.stim[0], "', {}:{}:{}", location.file(), location.line(), location.column());
+    }
     cortex_m::asm::bkpt();
-
     loop {}
 }

@japaric If this changes are good, I can also prepare a PR adding this changes to all aux libraries in this repo.

from discovery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.