embassy-rs/embassy · error

Both 'single-bank' and 'dual-bank' features enabled

Error message

Both 'single-bank' and 'dual-bank' features enabled

What it means

Some STM32 chips can be configured in either single-bank or dual-bank flash mode, and embassy-stm32 expresses that choice as Cargo features 'single-bank'/'dual-bank'. The build script generates flash/option-byte code based on the selection, and both features being enabled is contradictory, so it panics.

Solutions

  1. Enable exactly one of 'single-bank' or 'dual-bank' on embassy-stm32, matching the chip's actual option-byte (FLASH OPTCR/BANK) configuration
  2. Check your chip's current flash bank layout (e.g. via STM32CubeProgrammer) and pick the matching feature
  3. Verify with `cargo tree -f '{p} {f}'` that no other crate enables the opposite feature

Example fix

# before
embassy-stm32 = { version = "0.1", features = ["stm32h743zi", "single-bank", "dual-bank"] }
# after
embassy-stm32 = { version = "0.1", features = ["stm32h743zi", "single-bank"] }
Defensive patterns

Strategy: validation

Validate before calling

# exactly one bank feature
features=$(cargo tree -f '{f}' -p embassy-stm32); echo "$features" | grep -cE 'single-bank|dual-bank'  # expect 1

Prevention

When it happens

Trigger: Enabling both 'single-bank' and 'dual-bank' features on embassy-stm32 for a chip that supports the bank_setup_configurable option (e.g. H7 series).

Common situations: Adding 'dual-bank' to an existing config that already had 'single-bank' (or vice versa); feature unification from another crate enabling the opposite bank feature; template Cargo.toml containing both with one commented incorrectly.

Related errors


AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10). Data as JSON: /api/errors/fe0548c3be6bb81c. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/build.rs:112

        let single_bank_selected = env::var("CARGO_FEATURE_SINGLE_BANK").is_ok();

        let single_bank_memory = METADATA.memory.iter().find(|mem| {
            mem.iter().any(|region| region.name.contains("BANK_1"))
                && !mem.iter().any(|region| region.name.contains("BANK_2"))
        });

        let dual_bank_memory = METADATA.memory.iter().find(|mem| {
            mem.iter().any(|region| region.name.contains("BANK_1"))
                && mem.iter().any(|region| region.name.contains("BANK_2"))
        });

        cfgs.set(
            "bank_setup_configurable",
            single_bank_memory.is_some() && dual_bank_memory.is_some(),
        );

        match (single_bank_selected, dual_bank_selected) {
            (true, true) => panic!("Both 'single-bank' and 'dual-bank' features enabled"),
            (true, false) => {
                single_bank_memory.expect("The 'single-bank' feature is not supported on this dual bank chip")
            }
            (false, true) => {
                dual_bank_memory.expect("The 'dual-bank' feature is not supported on this single bank chip")
            }
            (false, false) => {
                if METADATA.memory.len() != 1 {
                    panic!(
                        "Chip supports single and dual bank configuration. No Cargo feature to select one is enabled. Use the 'single-bank' or 'dual-bank' feature to make your selection"
                    )
                }
                METADATA.memory[0]
            }
        }
    };

    let has_bkpsram = memory.iter().any(|m| m.name == "BKPSRAM");

View on GitHub (pinned to 463a07b963)