{"record":{"id":"28d1553bde66792d","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-dual-bank-but-the-hardwa-28d155","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"embassy-stm32/src/flash/l.rs","lineNumber":424,"sourceCode":"                if nssr.nspgserr() {\n                    return Err(Error::Seq);\n                }\n\n                return Ok(());\n            }\n        }\n    }\n}\n\n#[cfg(all(bank_setup_configurable, flash_l5))]\npub(crate) fn check_bank_setup() {\n    if cfg!(feature = \"single-bank\") && pac::FLASH.optr().read().dbank() {\n        panic!(\n            \"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}","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/l.rs#L406-L442","documentation":"This panic comes from check_bank_setup in embassy-stm32's flash driver for STM32L5 devices. The 'dual-bank' cargo feature was enabled, but the OPTR register's DBANK bit indicates single-bank mode. Embassy panics at init because a dual-bank driver layout would address flash incorrectly on single-bank L5 hardware.","triggerScenarios":"Building with feature = \"dual-bank\" for an STM32L5 target whose user option bytes have DBANK=0; panic fires at flash init when check_bank_setup evaluates !pac::FLASH.optr().read().dbank().","commonSituations":"Option bytes erased/reset to defaults (DBANK cleared) after a mass erase while the build kept dual-bank features; features copied from an L5 project with different option-byte settings; board swap without updating config.","solutions":["Change your embassy-stm32 feature from \"dual-bank\" to \"single-bank\" in Cargo.toml to match DBANK=0 hardware","Set the DBANK option bit to 1 in the user option bytes (STM32CubeProgrammer or probe-rs) if dual-bank is required; back up flash first as this re-partitions the flash layout","Power-cycle and verify OPTR.DBANK via debugger before reflashing firmware"],"exampleFix":"// before (Cargo.toml)\nembassy-stm32 = { version = \"...\", features = [\"stm32l552xx\", \"dual-bank\"] }\n// after\nembassy-stm32 = { version = \"...\", features = [\"stm32l552xx\", \"single-bank\"] }","handlingStrategy":"validation","validationCode":"// Rust, before initializing the flash driver\nlet optr = unsafe { pac::FLASH.optr().read() };\nassert_eq!(optr.dbank(), cfg!(feature = \"dual-bank\"),\n    \"embassy flash bank feature must match OPTR.DBANK\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-check option bytes after mass erase or option-byte reset, which can clear DBANK","Keep option-byte configuration and Cargo features in sync in the same board bring-up doc","Verify OPTR.DBANK via debugger before flashing firmware built with dual-bank features"],"tags":["embedded","stm32","flash","build-configuration","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"}