{"record":{"id":"fe0548c3be6bb81c","repo":"embassy-rs/embassy","slug":"both-single-bank-and-dual-bank-features-enable","errorCode":null,"errorMessage":"Both 'single-bank' and 'dual-bank' features enabled","messagePattern":"Both 'single-bank' and 'dual-bank' features enabled","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/build.rs","lineNumber":112,"sourceCode":"        let single_bank_selected = env::var(\"CARGO_FEATURE_SINGLE_BANK\").is_ok();\n\n        let single_bank_memory = METADATA.memory.iter().find(|mem| {\n            mem.iter().any(|region| region.name.contains(\"BANK_1\"))\n                && !mem.iter().any(|region| region.name.contains(\"BANK_2\"))\n        });\n\n        let dual_bank_memory = METADATA.memory.iter().find(|mem| {\n            mem.iter().any(|region| region.name.contains(\"BANK_1\"))\n                && mem.iter().any(|region| region.name.contains(\"BANK_2\"))\n        });\n\n        cfgs.set(\n            \"bank_setup_configurable\",\n            single_bank_memory.is_some() && dual_bank_memory.is_some(),\n        );\n\n        match (single_bank_selected, dual_bank_selected) {\n            (true, true) => panic!(\"Both 'single-bank' and 'dual-bank' features enabled\"),\n            (true, false) => {\n                single_bank_memory.expect(\"The 'single-bank' feature is not supported on this dual bank chip\")\n            }\n            (false, true) => {\n                dual_bank_memory.expect(\"The 'dual-bank' feature is not supported on this single bank chip\")\n            }\n            (false, false) => {\n                if METADATA.memory.len() != 1 {\n                    panic!(\n                        \"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\"\n                    )\n                }\n                METADATA.memory[0]\n            }\n        }\n    };\n\n    let has_bkpsram = memory.iter().any(|m| m.name == \"BKPSRAM\");","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/build.rs#L94-L130","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Enable exactly one of 'single-bank' or 'dual-bank' on embassy-stm32, matching the chip's actual option-byte (FLASH OPTCR/BANK) configuration","Check your chip's current flash bank layout (e.g. via STM32CubeProgrammer) and pick the matching feature","Verify with `cargo tree -f '{p} {f}'` that no other crate enables the opposite feature"],"exampleFix":"# before\nembassy-stm32 = { version = \"0.1\", features = [\"stm32h743zi\", \"single-bank\", \"dual-bank\"] }\n# after\nembassy-stm32 = { version = \"0.1\", features = [\"stm32h743zi\", \"single-bank\"] }","handlingStrategy":"validation","validationCode":"# exactly one bank feature\nfeatures=$(cargo tree -f '{f}' -p embassy-stm32); echo \"$features\" | grep -cE 'single-bank|dual-bank'  # expect 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick the bank feature matching the chip's flash option bytes","Never combine single-bank and dual-bank","Re-check bank layout after changing flash configuration with STM32CubeProgrammer"],"tags":["build-script","cargo-features","flash","stm32"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}