{"record":{"id":"44cf4c63cda27e53","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-dual-bank-but-the-hardwa-44cf4c","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":"error","filePath":"embassy-stm32/src/flash/g.rs","lineNumber":261,"sourceCode":"    }\n}\n\n// G0 doesn't have data cache, use no-op functions\n#[cfg(any(flash_g0x0, flash_g0x1))]\nfn save_data_cache_state() {}\n\n#[cfg(any(flash_g0x0, flash_g0x1))]\nfn restore_data_cache_state() {}\n\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}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/g.rs#L243-L279","documentation":"Inverse of 208 for G-series: Embassy compiled with the 'dual-bank' feature while the hardware DBANK bit shows single-bank mode. The dual-bank sector map would not match the physical flash, so check_bank_setup() panics before any flash operation can misaddress memory.","triggerScenarios":"Flash init on a configurable G4/G0 part built with feature = \"dual-bank\" while FLASH.optr.DBANK == 0 (single bank).","commonSituations":"Option bytes configured single-bank (e.g. for a large contiguous partition) while the firmware keeps dual-bank features; reusing a Cargo.toml from a dual-bank board.","solutions":["Rebuild with the 'single-bank' feature, or set the DBANK option bit to 1 (dual-bank) and power cycle.","Confirm which layout your application/bootloader expects and align both firmware features and option bytes to it.","Add option-byte checks to your flashing/production procedure to catch drift early."],"exampleFix":"// before (Cargo.toml, G4 hardware single-bank)\nfeatures = [\"stm32g474re\", \"dual-bank\"]\n// after\nfeatures = [\"stm32g474re\", \"single-bank\"]","handlingStrategy":"validation","validationCode":"fn g4_bank_ok(dual_bank_feature: bool, dbank: bool) -> bool {\n    dual_bank_feature == dbank\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set DBANK=1 if firmware is built dual-bank, and power cycle","Keep cargo features and option bytes documented together per board","Verify option bytes in production flashing scripts"],"tags":["rust","embassy","embedded","stm32","flash","build-configuration"],"backgroundTag":"invalid-config-value","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"}