{"record":{"id":"7c960beee835dc9a","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-dual-bank-but-the-hardwa-7c960b","errorCode":null,"errorMessage":"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dual_bank 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 dual_bank 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/g.rs","lineNumber":275,"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_g0x1))]\npub(crate) fn check_bank_setup() {\n    if cfg!(feature = \"single-bank\") && pac::FLASH.optr().read().dual_bank() {\n        panic!(\n            \"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dual_bank 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().dual_bank() {\n        panic!(\n            \"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use single-bank config\"\n        );\n    }\n}\n","sourceCodeStart":257,"sourceCodeEnd":280,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/g.rs#L257-L280","documentation":"This panic comes from check_bank_setup in embassy-stm32's flash driver for STM32G0x1 devices. The 'dual-bank' cargo feature was enabled, but the OPTR register's DUAL_BANK bit indicates the chip is running in single-bank mode. Embassy panics because a dual-bank driver layout would address flash incorrectly on single-bank hardware.","triggerScenarios":"Building with feature = \"dual-bank\" for an STM32G0x1 target whose user option bytes have DUAL_BANK=0; the panic fires at flash init when check_bank_setup evaluates !pac::FLASH.optr().read().dual_bank().","commonSituations":"Enabling dual-bank features copied from an L4/G4 project; factory-default G0 option bytes (single-bank) with a dual-bank-configured build; cargo feature set for a different board variant sharing the same codebase.","solutions":["Change your embassy-stm32 feature from \"dual-bank\" to \"single-bank\" in Cargo.toml to match the default single-bank hardware","Set the DUAL_BANK option bit to 1 in the user option bytes (STM32CubeProgrammer or probe-rs) if you truly need dual-bank operation","After changing option bytes, power-cycle the chip and verify OPTR via debugger before reflashing"],"exampleFix":"// before (Cargo.toml)\nembassy-stm32 = { version = \"...\", features = [\"stm32g071xx\", \"dual-bank\"] }\n// after\nembassy-stm32 = { version = \"...\", features = [\"stm32g071xx\", \"single-bank\"] }","handlingStrategy":"validation","validationCode":"// Rust, before initializing the flash driver\nlet optr = unsafe { pac::FLASH.optr().read() };\nassert_eq!(optr.dual_bank(), cfg!(feature = \"dual-bank\"),\n    \"embassy flash bank feature must match OPTR.DUAL_BANK\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify option bytes after factory reset or mass erase, since defaults may be single-bank","Pin per-board cargo features and never copy them between board variants unchecked","Check OPTR via debugger when bringing up a new board revision"],"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"}