{"record":{"id":"2bd5080fdd5aa0de","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-single-bank-but-the-hard-2bd508","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"embassy-stm32/src/flash/l.rs","lineNumber":433,"sourceCode":"\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}\n","sourceCodeStart":415,"sourceCodeEnd":443,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/l.rs#L415-L443","documentation":"This panic comes from check_bank_setup in embassy-stm32's flash driver for STM32L4 devices. The 'single-bank' cargo feature was enabled, but the FLASH OPTR register's DUALBANK bit shows the chip is running in dual-bank mode (the L4 register field is named dualbank, unlike G0/L5). Embassy panics at init since a single-bank driver would corrupt flash on dual-bank L4 hardware.","triggerScenarios":"Building with feature = \"single-bank\" for an STM32L4 target whose user option bytes have DUALBANK=1; panic fires at flash init when check_bank_setup reads pac::FLASH.optr().read().dualbank().","commonSituations":"L4 devices with >1MB flash default to dual-bank option bytes while Cargo features assume single-bank; option bytes changed by STM32CubeProgrammer or a bootloader; reusing feature sets from single-bank L4 variants.","solutions":["Change your embassy-stm32 feature from \"single-bank\" to \"dual-bank\" in Cargo.toml to match DUALBANK=1 hardware","Clear the DUALBANK option bit to 0 in the user option bytes (STM32CubeProgrammer or probe-rs) if single-bank operation is desired; this alters page size and erases flash content","Verify the option bytes via debugger after programming, then rebuild and reflash"],"exampleFix":"// before (Cargo.toml)\nembassy-stm32 = { version = \"...\", features = [\"stm32l475vg\", \"single-bank\"] }\n// after\nembassy-stm32 = { version = \"...\", features = [\"stm32l475vg\", \"dual-bank\"] }","handlingStrategy":"validation","validationCode":"// Rust, before initializing the flash driver\nlet optr = unsafe { pac::FLASH.optr().read() };\nassert_eq!(optr.dualbank(), cfg!(feature = \"dual-bank\"),\n    \"embassy flash bank feature must match OPTR.DUALBANK\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Note that on L4 the option bit is DUALBANK (not dual_bank/dbank); use the correct register field when checking","Large L4 devices (>1MB) commonly ship with DUALBANK set; pick features accordingly","Reprogram and verify option bytes whenever switching programmers or bootloaders"],"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"}