{"record":{"id":"c017e7a1869820c7","repo":"embassy-rs/embassy","slug":"multiple-stm32xx-cargo-features-enabled","errorCode":null,"errorMessage":"Multiple stm32xx Cargo features enabled","messagePattern":"Multiple stm32xx Cargo features enabled","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32-wpan/build.rs","lineNumber":12,"sourceCode":"use std::path::PathBuf;\nuse std::{env, fs};\n\nfn main() {\n    match env::vars()\n        .map(|(a, _)| a)\n        .filter(|x| x.starts_with(\"CARGO_FEATURE_STM32\"))\n        .get_one()\n    {\n        Ok(_) => {}\n        Err(GetOneError::None) => panic!(\"No stm32xx Cargo feature enabled\"),\n        Err(GetOneError::Multiple) => panic!(\"Multiple stm32xx Cargo features enabled\"),\n    }\n\n    let out_dir = &PathBuf::from(env::var_os(\"OUT_DIR\").unwrap());\n\n    // ========\n    // stm32wb tl_mbox link sections\n\n    let out_file = out_dir.join(\"tl_mbox.x\").to_string_lossy().to_string();\n    let in_file;\n    if env::var_os(\"CARGO_FEATURE_EXTENDED\").is_some() {\n        if env::vars()\n            .map(|(a, _)| a)\n            .any(|x| x.starts_with(\"CARGO_FEATURE_STM32WB1\"))\n        {\n            in_file = \"tl_mbox_extended_wb1.x.in\";\n        } else {\n            in_file = \"tl_mbox_extended_wbx5.x.in\";\n        }","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32-wpan/build.rs#L1-L30","documentation":"embassy-stm32-wpan's build script compiles chip-specific link sections and register definitions, so exactly one stm32xx chip feature must be enabled at compile time. When Cargo's CARGO_FEATURE_STM32* env vars resolve to more than one chip, the build script cannot pick a target and panics with this message during build script execution.","triggerScenarios":"Cargo.toml (or a dependency's feature unification) enables two or more features like stm32wb15cc and stm32wb55xx on embassy-stm32-wpan simultaneously.","commonSituations":"Workspace Cargo.toml turns on multiple chip features via feature unification (e.g. two binaries each requiring a different chip in the same package); copy-pasting examples for different chips into one dependency entry; a third-party crate enabling a second embassy-stm32 chip feature.","solutions":["Enable exactly one stm32xx chip feature on embassy-stm32 (which propagates to embassy-stm32-wpan) in Cargo.toml","Check `cargo tree -f '{p} {f}'` for what enables extra chip features and remove or gate them","Split projects for different chips into separate packages/workspaces so feature unification cannot merge two chips"],"exampleFix":"# before\nembassy-stm32-wpan = { version = \"0.1\", features = [\"stm32wb15cc\", \"stm32wb55xx\"] }\n# after\nembassy-stm32-wpan = { version = \"0.1\", features = [\"stm32wb15cc\"] }","handlingStrategy":"validation","validationCode":"// build-time: ensure exactly one chip feature; cannot be caught at runtime (build script panic)\n// In CI: cargo metadata --format-version 1 | jq to assert single CARGO_FEATURE_STM32 feature\ncargo tree -f '{p} {f}' | grep embassy-stm32-wpan","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable exactly one stm32xx chip feature per package","Use a workspace with one package per board/chip","Run cargo tree in CI to detect feature unification of chip features"],"tags":["build-script","cargo-features","embedded","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"}