{"record":{"id":"32c5b6f495a35df8","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-dual-bank-but-the-hardwa-32c5b6","errorCode":null,"errorMessage":"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use single-bank config","messagePattern":"Embassy is configured as dual-bank, but the hardware is running in single-bank mode\\. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use single-bank config","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/flash/l.rs","lineNumber":438,"sourceCode":"            \"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use dual-bank config\"\n        );\n    }\n    if cfg!(feature = \"dual-bank\") && !pac::FLASH.optr().read().dbank() {\n        panic!(\n            \"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use single-bank config\"\n        );\n    }\n}\n\n#[cfg(all(bank_setup_configurable, flash_l4))]\npub(crate) fn check_bank_setup() {\n    if cfg!(feature = \"single-bank\") && pac::FLASH.optr().read().dualbank() {\n        panic!(\n            \"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use dual-bank config\"\n        );\n    }\n    if cfg!(feature = \"dual-bank\") && !pac::FLASH.optr().read().dualbank() {\n        panic!(\n            \"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use single-bank config\"\n        );\n    }\n}\n","sourceCodeStart":420,"sourceCodeEnd":443,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/l.rs#L420-L443","documentation":"This panic fires at flash-driver init time when embassy-stm32 is compiled with the dual-bank cargo feature but the chip's user option bytes say the flash is in single-bank mode. The library checks the hardware's OPTR register against the compile-time configuration because bank layout determines flash sector sizing, erase/write behavior, and memory mapping, and a mismatch would corrupt memory operations silently.","triggerScenarios":"Calling any flash API (or constructing the flash driver) on an STM32 part whose code path runs check_bank_setup when: (1) the crate was built with feature \"dual-bank\", and (2) FLASH.optr().read().dualbank() returns false, meaning the option bytes configure single-bank mode.","commonSituations":"Using an embassy-stm32 feature flag set for a dual-bank variant (e.g. H7/WB) while the board was flashed with option bytes configuring single-bank; reusing a build config from a different board revision; a bootloader or STM32CubeProgrammer session changed the dualbank option byte; switching chip part numbers without updating cargo features.","solutions":["Either change the hardware config: set the dualbank bit (nDBANK on many parts) in the user option bytes via STM32CubeProgrammer, STM32CubeIDE, or a bootloader, then power-cycle the chip","Or change the software config: rebuild embassy-stm32 with the single-bank feature (or without the dual-bank feature) instead of dual-bank","Verify with the reference manual which bank mode your exact part number defaults to and pick the matching cargo feature","Note that changing option bytes may erase flash — back up firmware first"],"exampleFix":"// before (Cargo.toml)\nembassy-stm32 = { version = \"0.2\", features = [\"stm32h743zi\", \"dual-bank\"] }\n// after (if the chip option bytes say single-bank)\nembassy-stm32 = { version = \"0.2\", features = [\"stm32h743zi\", \"single-bank\"] }","handlingStrategy":"validation","validationCode":"// Before enabling flash, read the option bytes yourself and match the cargo feature\nlet dualbank_hw = pac::FLASH.optr().read().dualbank();\n#[cfg(feature = \"dual-bank\")]\nassert!(dualbank_hw, \"hardware is single-bank; build with single-bank feature or set nDBANK=0 in option bytes\");\n#[cfg(feature = \"single-bank\")]\nassert!(!dualbank_hw, \"hardware is dual-bank; build with dual-bank feature or change the dualbank option byte\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the cargo feature flag and the chip's option-byte configuration in the same board documentation/release script","Verify option bytes with STM32CubeProgrammer after any flashing or bootloader session","Read the part number's reference manual to confirm default bank mode before choosing features","Automate the check: read OPTR at startup and log it before initializing the flash driver"],"tags":["embedded","stm32","flash","hardware-config","panic"],"backgroundTag":"conflicting-config-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"}