stm32-rs / stm32l1xx-hal

[WIP] Peripheral access API for STM32L1 series microcontrollers
Apache License 2.0
9 stars 12 forks source link

trait `core::marker::Copy` is not implemented for `Interrupt` #12

Open pdgilbert opened 2 years ago

pdgilbert commented 2 years ago

With recent changes in rtic examples using stm32lxx_hal are now giving

Compiling rust-integration-testing-of-examples v0.1.0 (/home/paul/githubClones/rust-integration-testing/dev-testing)
error[E0277]: the trait bound `Interrupt: core::marker::Copy` is not satisfied
  --> examples/driver-examples/iaq-core-c-gas-voc-usart-logger.rs:41:48
   |
41 | #[cfg_attr(feature = "stm32l1xx", app(device = stm32l1xx_hal::stm32, dispatchers = [TIM2, TIM3]))] 
   |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `core::marker::Copy` is not implemented for `Interrupt`
   | 
  ::: /home/paul/.cargo/git/checkouts/cortex-m-rtic-da08f71f062e5e7b/ca9088a/src/lib.rs:54:8
   |
54 |     I: InterruptNumber,
   |        --------------- required by this bound in `pend`
   |
   = note: required because of the requirements on the impl of `InterruptNumber` for `Interrupt`
adamgreig commented 2 years ago

Huh, this is potentially a bit troublesome for a lot of crates. What versions of stm32l1, stm32l1xx_hal, cortex-m, and cortex-m-rtic are in use (try cargo tree)? It's weird because stm32l1's Interrupt definitely impls Copy for both 0.13.0 and 0.14.0.

pdgilbert commented 2 years ago

I'm using recent git versions. My Cargo.lock has

[[package]]
name = "stm32l1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edda4346740d0f01082c353dca33b320e84f9fb51765fdcac7a624017c5a8ff4"
dependencies = [
 "bare-metal 0.2.5",
 "cortex-m 0.5.11",
 "cortex-m-rt",
 "vcell",
]

[[package]]
name = "stm32l1xx-hal"
version = "0.1.0"
source = "git+https://github.com/stm32-rs/stm32l1xx-hal#b5bfb4ff069889233baf5bfda75eea4cbb5ce5f8"
dependencies = [
 "bare-metal 0.2.5",
 "cast",
 "cortex-m 0.5.11",
 "embedded-hal 0.2.6",
 "nb 0.1.3",
 "stm32l1",
 "void",
]

stm32l1 version = "0.5.0" seems to be specified in https://github.com/stm32-rs/stm32l1xx-hal/blob/master/Cargo.toml#L23-26. Could that be the problem?

adamgreig commented 2 years ago

Ah, wow, 0.5 is pretty old. It was released in Dec 2018, but the PR that caused svd2rust to mark the interrupts as Copy (https://github.com/rust-embedded/svd2rust/pull/274) wasn't until Jan 2019, so wouldn't be included. That is most likely the source of the problem, combined with new RTIC using the new InterruptNumber trait from cortex-m 0.7, which is what requires Interrupt to be Copy. The best bet is probably to update the stm32l1 version here...

pdgilbert commented 2 years ago

Ok. I'll look forward to testing when things are updated.