{"record":{"id":"5d28eac75ed4b9fc","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-single-bank-but-the-hard-5d28ea","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"embassy-stm32/src/flash/g.rs","lineNumber":270,"sourceCode":"\n#[cfg(all(bank_setup_configurable, any(flash_g4c2, flash_g4c3, flash_g4c4)))]\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_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":252,"sourceCodeEnd":280,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/g.rs#L252-L280","documentation":"This panic comes from check_bank_setup in embassy-stm32's flash driver for STM32G0x1 devices. The embassy 'single-bank' cargo feature was enabled, but the FLASH option register (OPTR) DUAL_BANK bit read at startup shows the chip is actually running in dual-bank mode. Embassy panics immediately because a single-bank driver would corrupt flash if used against dual-bank hardware.","triggerScenarios":"Building with feature = \"single-bank\" for an STM32G0x1 target whose user option bytes have DUAL_BANK=1; the panic fires at flash-driver init when check_bank_setup reads pac::FLASH.optr().read().dual_bank().","commonSituations":"Reusing Cargo features copied from another board's project; a previous firmware/STM32CubeProgrammer run left DUAL_BANK set in option bytes; switching chips on the same board without re-flashing option bytes; cargo feature not updated after changing hardware revision.","solutions":["Set the dual_bank option bit to 0 in the user option bytes (via STM32CubeProgrammer, probe-rs, or an option-byte erase/program at your own risk) so hardware runs single-bank","Change your embassy-stm32 feature from \"single-bank\" to \"dual-bank\" in Cargo.toml so the driver matches the hardware","Read back and verify option bytes with the debugger after changing them, then rebuild and flash"],"exampleFix":"// before (Cargo.toml)\nembassy-stm32 = { version = \"...\", features = [\"stm32g071xx\", \"single-bank\"] }\n// after\nembassy-stm32 = { version = \"...\", features = [\"stm32g071xx\", \"dual-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":["Keep the bank feature in a per-board Cargo feature and derive it from the target chip documentation","Read back option bytes with probe-rs or STM32CubeProgrammer after any debugger/programmer session that touches them","Document the required option-byte setting next to the flash driver setup in your firmware","Add a CI check that the same board always builds with the same bank feature"],"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"}