David-OConnor / stm32-hal

This library provides access to STM32 peripherals in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[STM32H7A3] Can't compile

cracksalad opened this issue · comments

I am new to Rust for STM32, so please excuse any stupid mistakes.

When I cloned the quickstart and configured it, the following errors show up during compilation:

   Compiling stm32-hal2 v1.8.2
error[E0433]: failed to resolve: could not find `ADC3_COMMON` in `pac`
    --> ~\.cargo\registry\src\index.crates.io-6f17d22bba15001f\stm32-hal2-1.8.2\src\adc.rs:1236:20
     |
1236 |         hal!(ADC3, ADC3_COMMON, adc3, 3);
     |                    ^^^^^^^^^^^
     |                    |
     |                    could not find `ADC3_COMMON` in `pac`
     |                    help: a struct with a similar name exists: `ADC12_COMMON`

error[E0412]: cannot find type `ADC3` in module `pac`
    --> ~\.cargo\registry\src\index.crates.io-6f17d22bba15001f\stm32-hal2-1.8.2\src\adc.rs:1236:14
     |
1236 |         hal!(ADC3, ADC3_COMMON, adc3, 3);
     |              ^^^^ help: a struct with a similar name exists: `ADC1`
     |
    ::: ~\.cargo\registry\src\index.crates.io-6f17d22bba15001f\stm32h7-0.15.1\src\stm32h7b3\mod.rs:684:1
     |
684  | pub struct ADC1 {
     | --------------- similarly named struct `ADC1` defined here

error[E0412]: cannot find type `SAI3` in module `pac`
    --> ~\.cargo\registry\src\index.crates.io-6f17d22bba15001f\stm32-hal2-1.8.2\src\util.rs:593:25
     |
593  | impl RccPeriph for pac::SAI3 {
     |                         ^^^^ help: a struct with a similar name exists: `SAI1`
     |
    ::: ~\.cargo\registry\src\index.crates.io-6f17d22bba15001f\stm32h7-0.15.1\src\stm32h7b3\mod.rs:2896:1
     |
2896 | pub struct SAI1 {
     | --------------- similarly named struct `SAI1` defined here

error[E0412]: cannot find type `SAI4` in module `pac`
    --> ~\.cargo\registry\src\index.crates.io-6f17d22bba15001f\stm32-hal2-1.8.2\src\util.rs:620:25
     |
620  | impl RccPeriph for pac::SAI4 {
     |                         ^^^^ help: a struct with a similar name exists: `SAI1`
     |
    ::: ~\.cargo\registry\src\index.crates.io-6f17d22bba15001f\stm32h7-0.15.1\src\stm32h7b3\mod.rs:2896:1
     |
2896 | pub struct SAI1 {
     | --------------- similarly named struct `SAI1` defined here

Refering to the device coverage of stm32-rs there is no ADC3, SAI3 and SAI4.

My quickstart config looks like this:

  • Cargo.toml: hal = { package = "stm32-hal2", version = "^1.6.4", features = ["h7b3", "h7rt"]}
  • .cargo/config.toml: runner = "probe-rs run --chip git STM32H7A3ZITxQ" and target = "thumbv7em-none-eabihf"
  • memory.x: FLASH : ORIGIN = 0x08000000, LENGTH = 1953K and RAM : ORIGIN = 0x20000000, LENGTH = 1367K (really not sure if this is correct, but should not be the problem here)

There seems to be a mismatch between the target chip and the code somehow. Any hints?

Yep, that's exactly what it is. The examples are general, while this lib supports many STM32 variants. So, you'll have to modify the peripherals used as required based on which you have, and which are wired up.

@David-OConnor thanks for confirming! Do you have any documentation about how to configure this?

@David-OConnor is it as easy as adding a not(feature = "h7b3") to those snippets:

stm32-hal/src/adc.rs

Lines 1231 to 1238 in b9a7421

// todo Implement ADC3 on H7. The issue is the enable / reset being on ahb4.
cfg_if! {
if #[cfg(feature = "h7")] {
hal!(ADC1, ADC12_COMMON, adc1, 12);
hal!(ADC2, ADC12_COMMON, adc2, 12);
hal!(ADC3, ADC3_COMMON, adc3, 3);
}
}

stm32-hal/src/util.rs

Lines 592 to 593 in b9a7421

#[cfg(all(feature = "h7", not(feature = "h735")))]
impl RccPeriph for pac::SAI3 {

stm32-hal/src/util.rs

Lines 619 to 620 in b9a7421

#[cfg(feature = "h7")]
impl RccPeriph for pac::SAI4 {