Note: rust-lld: error: duplicate symbol: DEVICE_PERIPHERALS

Hello, I am pretty new to Embedded Rust. I am using a STM32 Discovery board for my learning platform and have been able to run/debug all of the samples, etc.

I am now working on a application that is leveraging these main crates:

cortex-m = "0.7.2"
cortex-m-rt = "0.6.13"
embedded-time = "0.10.1"
stm32f3xx-hal (getting from github repo)
stm32f3 (getting nightlies from github repo)

The application compiles fine, but it fails at the link stage with this error:

= note: rust-lld: error: duplicate symbol: DEVICE_PERIPHERALS
>>> defined at (/Users/mvanbergen/.cargo/registry/src/
>>> stm32f3-5fc64c156b17d2b8.stm32f3.4yidbzxb-cgu.12.rcgu.o:(DEVICE_PERIPHERALS) in archive /Users/mvanbergen/RustProjects/hanger_buddy/target/thumbv7em-none-eabihf/debug/deps/libstm32f3-5fc64c156b17d2b8.rlib
>>> defined at (/Users/mvanbergen/.cargo/git/checkouts/stm32-rs-nightlies-36f3a7b0991d6fd5/166b130/stm32f3/src/stm32f303/
>>> stm32f3-c9cb3273ca7ed48d.stm32f3.5zc4bc5

I'm at wits end trying to figure out what's happening here. I would not say I am a veteran embedded developer as I have not done much for some time (I did C way back when). I would love to get this running! Any thoughts as to how I can debug this issue?


The stm32f303 crate is included twice I think. Can you post the Cargo.toml and Cargo.lock?

I think @bjorn3 is correct. stm32f3xx-hal includes stm32f3 version 0.13, and you're adding a different version (latest from repository) on your own. Those can't coexist (at least not safely), as they both expect to be the single interface to the hardware.

stm32f3xx-hal re-exports stm32f3 as stm32f3xx_hal::pac. If using version 0.13 is okay for you, just use that, and remove your own dependency.

If you need the latest Git version of stm32f3, you can try to override the dependency. That might not work for various reason, so you might need to fork stm32f3xx-hal and override the version there.

1 Like

Thank you @bjorn3 and @hannobraun! I’ll try this today and I will report back my result.

@bjorn3 and @hannobraun: That was the issue. Thank you very much!