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

[STM32H7A3] Can't compile #100

Open
cracksalad opened this issue Apr 9, 2024 · 4 comments · May be fixed by #106
Open

[STM32H7A3] Can't compile #100

cracksalad opened this issue Apr 9, 2024 · 4 comments · May be fixed by #106

Comments

@cracksalad
Copy link

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?

@David-OConnor
Copy link
Owner

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.

@cracksalad
Copy link
Author

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

@cracksalad
Copy link
Author

@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 {

@David-OConnor
Copy link
Owner

Nice!

@cracksalad cracksalad linked a pull request Jul 4, 2024 that will close this issue
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