{"record":{"id":"f6041c0aafb9d11d","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-single-bank-but-the-hard-f6041c","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"embassy-stm32/src/flash/l.rs","lineNumber":419,"sourceCode":"\n                if nssr.nssizerr() {\n                    return Err(Error::Size);\n                }\n\n                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() {","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/l.rs#L401-L437","documentation":"This panic comes from check_bank_setup in embassy-stm32's flash driver for STM32L5 devices. The 'single-bank' cargo feature was enabled, but the FLASH OPTR register's DBANK bit shows the chip is running in dual-bank mode. Embassy panics at init since a single-bank driver would corrupt flash on dual-bank L5 hardware.","triggerScenarios":"Building with feature = \"single-bank\" for an STM32L5 target whose user option bytes have DBANK=1; panic fires at flash init when check_bank_setup reads pac::FLASH.optr().read().dbank().","commonSituations":"STM32L5 factory option bytes often leave DBANK set while the developer's Cargo features assume single-bank; option bytes changed by a previous STM32CubeIDE/Programmer project; features copied from a single-bank L4 sibling chip.","solutions":["Change your embassy-stm32 feature from \"single-bank\" to \"dual-bank\" in Cargo.toml to match the DBANK=1 hardware","Clear the DBANK option bit to 0 in the user option bytes (STM32CubeProgrammer or probe-rs) if single-bank operation is desired; note this changes page size/bank layout and mass-erases flash","Verify the new option bytes via debugger after flashing them, then rebuild"],"exampleFix":"// before (Cargo.toml)\nembassy-stm32 = { version = \"...\", features = [\"stm32l552xx\", \"single-bank\"] }\n// after\nembassy-stm32 = { version = \"...\", features = [\"stm32l552xx\", \"dual-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":["Remember STM32L5 defaults often have DBANK set; align Cargo features with actual option bytes","Back up flash contents before changing DBANK, since it re-partitions flash and erases data","Validate option bytes after any STM32CubeIDE/Programmer project that reprograms them"],"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"}