Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange compilation error while migrating to RTIC v1 #634

Closed
TeXitoi opened this issue Apr 14, 2022 · 2 comments · Fixed by #641
Closed

Strange compilation error while migrating to RTIC v1 #634

TeXitoi opened this issue Apr 14, 2022 · 2 comments · Fixed by #641

Comments

@TeXitoi
Copy link
Collaborator

TeXitoi commented Apr 14, 2022

I've tried to migrate to rtic v1 here: https://github.com/TeXitoi/keyseebee/tree/rtic1 but I have a strange error:

$ cargo build --release 
   Compiling keyseebee v0.1.0 (.../keyseebee/firmware)
error[E0080]: evaluation of constant value failed
  --> src/main.rs:42:1
   |
42 | #[app(device = crate::hal::pac, peripherals = true, dispatchers = [CEC_CAN])]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `4_usize - 5_usize`, which would overflow
   |
   = note: this error originates in the attribute macro `app` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0080`.
error: could not compile `keyseebee` due to previous error

I've tried to force using the v1.0.0 version, but I have the same error:

$ git diff Cargo.toml
diff --git a/firmware/Cargo.toml b/firmware/Cargo.toml
index 8026e51..c3b6091 100644
--- a/firmware/Cargo.toml
+++ b/firmware/Cargo.toml
@@ -10,11 +10,15 @@ cortex-m = "0.7"
 cortex-m-rt = { version = "0.7.1", features = ["device"] }
 panic-halt = "0.2.0"
 keyberon = { git = "https://github.com/TeXitoi/keyberon", branch = "master" }
-cortex-m-rtic = "1.1.1"
+cortex-m-rtic = "=1.0.0"
+cortex-m-rtic-macros = "=1.0.0"
 embedded-hal = "0.2"
 usb-device = "0.2.0"
 nb = "1.0.0"
 
+[dev-dependencies]
+rtic-syntax = "=1.0.0"
+
 [profile.release]
 lto = true
 incremental = false
$ cargo outdated
    Updating git repository `https://github.com/TeXitoi/keyberon`
Name                                 Project  Compat  Latest  Kind         Platform
----                                 -------  ------  ------  ----         --------
cortex-m-rtic                        1.0.0    ---     1.1.1   Normal       ---
cortex-m-rtic->cortex-m-rtic-macros  1.0.0    ---     1.1.0   Normal       ---
cortex-m-rtic-macros                 1.0.0    ---     1.1.0   Normal       ---
cortex-m-rtic-macros->rtic-syntax    1.0.0    ---     1.0.1   Normal       ---
rtic-syntax                          1.0.0    ---     1.0.1   Development  ---
@TeXitoi
Copy link
Collaborator Author

TeXitoi commented Apr 14, 2022

For Cortex-M, tasks can have priorities in the range 1..=(1 << NVIC_PRIO_BITS) where NVIC_PRIO_BITS is a constant defined in the device crate.

OK, I have NVIC_PRIO_BITS = 2, so 4 is the maximum priority, and I had a priority of 5.

Could be great if the error was more readable.

@TeXitoi TeXitoi closed this as completed Apr 14, 2022
@AfoHT
Copy link
Contributor

AfoHT commented Apr 19, 2022

Let's reopen this to track that we need to improve the error message, thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants