Skip to content

Unable to create a MonoTimer #223

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

Closed
arturjpv opened this issue Jun 7, 2020 · 2 comments
Closed

Unable to create a MonoTimer #223

arturjpv opened this issue Jun 7, 2020 · 2 comments
Labels

Comments

@arturjpv
Copy link

arturjpv commented Jun 7, 2020

Error Description

I'm trying to create a MonoTimer and the code is not compiling.

I'm receiving a message that could point to mixed crates or incompatibility in the dependencies.
Perhaps cortex-m v0.6.2 and cortex-m v0.5.10? I don't understand how is that cargo tree is listing cortex-m v0.6.2 as a dependency of cortex-m v0.5.10 (inside stm32f30x-hal v0.2.0dependency; see cargo tree output below).

Portion of code where I'm creating the MonoTimer:

let bp = stm32f30x::Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().unwrap();

let mut rcc = bp.RCC.constrain();
let mut flash = bp.FLASH.constrain();
let clocks = rcc.cfgr.freeze(&mut flash.acr);

let timer = Delay::new(cp.SYST, clocks);
let chrono = MonoTimer::new(cp.DWT, clocks);

Error message:

error[E0308]: mismatched types
  --> src/core/mod.rs:27:37
   |
27 |         let chrono = MonoTimer::new(cp.DWT, clocks);
   |                                     ^^^^^^ expected struct `cortex_m::peripheral::DWT`, found a different struct `cortex_m::peripheral::DWT`
   |
   = note: perhaps two different versions of crate `cortex_m` are being used?

Dependencies

The important parts of my Cargo.toml look like this:

[dependencies]
cortex-m = "0.6.2"
cortex-m-rt = "0.6.12"
panic-halt = "0.2.0"

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

Output of cargo tree:

chip8stm v0.1.0 (/home/artur/Documents/Code/chip8/chip8stm)
├── chip8vm v0.8.2 (/home/artur/Documents/Code/chip8/chip8vm)
├── cortex-m v0.6.2
│   ├── aligned v0.3.2
│   │   └── as-slice v0.1.3
│   │       ├── generic-array v0.12.3
│   │       │   └── typenum v1.12.0
│   │       ├── generic-array v0.13.2
│   │       │   └── typenum v1.12.0
│   │       └── stable_deref_trait v1.1.1
│   ├── bare-metal v0.2.5
│   │   [build-dependencies]
│   │   └── rustc_version v0.2.3
│   │       └── semver v0.9.0
│   │           └── semver-parser v0.7.0
│   └── volatile-register v0.2.0
│       └── vcell v0.1.2
├── cortex-m-rt v0.6.12
│   ├── cortex-m-rt-macros v0.1.8
│   │   ├── proc-macro2 v1.0.18
│   │   │   └── unicode-xid v0.2.0
│   │   ├── quote v1.0.6
│   │   │   └── proc-macro2 v1.0.18 (*)
│   │   └── syn v1.0.30
│   │       ├── proc-macro2 v1.0.18 (*)
│   │       ├── quote v1.0.6 (*)
│   │       └── unicode-xid v0.2.0
│   └── r0 v0.2.2
├── f3 v0.6.1
│   ├── l3gd20 v0.2.0
│   │   ├── embedded-hal v0.2.3
│   │   │   ├── nb v0.1.2
│   │   │   └── void v1.0.2
│   │   └── generic-array v0.11.1
│   │       └── typenum v1.12.0
│   ├── lsm303dlhc v0.2.0
│   │   ├── cast v0.2.3
│   │   │   [build-dependencies]
│   │   │   └── rustc_version v0.2.3 (*)
│   │   ├── embedded-hal v0.2.3 (*)
│   │   └── generic-array v0.11.1 (*)
│   └── stm32f30x-hal v0.2.0
│       ├── cast v0.2.3 (*)
│       ├── cortex-m v0.5.10
│       │   ├── aligned v0.2.0
│       │   ├── bare-metal v0.2.5 (*)
│       │   ├── cortex-m v0.6.2 (*)
│       │   └── volatile-register v0.2.0 (*)
│       ├── embedded-hal v0.2.3 (*)
│       ├── nb v0.1.2
│       ├── stm32f30x v0.7.1
│       │   ├── bare-metal v0.2.5 (*)
│       │   ├── cortex-m v0.5.10 (*)
│       │   ├── cortex-m-rt v0.6.12 (*)
│       │   └── vcell v0.1.2
│       └── void v1.0.2
└── panic-halt v0.2.0

Additional information

  • Compiling on stable channel of rust 1.44.0.
  • I'm developing for the stm32f3Discovery board (stm32f303).
  • Target system is thumbv7em-none-eabihf.
@arturjpv
Copy link
Author

arturjpv commented Jun 8, 2020

I finally could create the MonoTimer using:

f3::hal::stm32f30x::CorePeripherals

instead of

cortex_m::Peripherals

But now I don't understand the difference between 'CorePeripherals' and 'CortexPeripherals'.

@jonas-schievink
Copy link
Contributor

stm32f30x-hal pulls in cortex-m version 0.5.x, while you were trying to use 0.6.x, as suggested by the error message

adamgreig pushed a commit that referenced this issue Jan 12, 2022
228: Added so attributes and cfgs are applied on the trampolines as well r=jonas-schievink a=korken89

I made a first go at #223, but maybe this implementation takes things we do not want to propagate.
If you come up with something that should not propagate, please comment here.

Closes  #223
Closes rust-embedded/cortex-m-rt#213

Co-authored-by: Emil Fresk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants