{"record":{"id":"b0b7a30110f3f75b","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-single-bank-but-the-hard-b0b7a3","errorCode":null,"errorMessage":"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the ndbank 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 ndbank value in the user option bytes or configure embassy to use dual-bank config","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/flash/f7.rs","lineNumber":174,"sourceCode":"        assert_sector(0, 0x0800_0000, SMALL_SECTOR_SIZE, 0x0800_0000);\n        assert_sector(0, 0x0800_0000, SMALL_SECTOR_SIZE, 0x0800_7FFF);\n        assert_sector(3, 0x0801_8000, SMALL_SECTOR_SIZE, 0x0801_8000);\n        assert_sector(3, 0x0801_8000, SMALL_SECTOR_SIZE, 0x0801_FFFF);\n\n        assert_sector(4, 0x0802_0000, MEDIUM_SECTOR_SIZE, 0x0802_0000);\n        assert_sector(4, 0x0802_0000, MEDIUM_SECTOR_SIZE, 0x0803_FFFF);\n\n        assert_sector(5, 0x0804_0000, LARGE_SECTOR_SIZE, 0x0804_0000);\n        assert_sector(5, 0x0804_0000, LARGE_SECTOR_SIZE, 0x0807_FFFF);\n        assert_sector(7, 0x080C_0000, LARGE_SECTOR_SIZE, 0x080C_0000);\n        assert_sector(7, 0x080C_0000, LARGE_SECTOR_SIZE, 0x080F_FFFF);\n    }\n}\n\n#[cfg(all(bank_setup_configurable))]\npub(crate) fn check_bank_setup() {\n    if cfg!(feature = \"single-bank\") && !pac::FLASH.optcr().read().n_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 ndbank value in the user option bytes or configure embassy to use dual-bank config\"\n        );\n    }\n    if cfg!(feature = \"dual-bank\") && pac::FLASH.optcr().read().n_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 ndbank value in the user option bytes or configure embassy to use single-bank config\"\n        );\n    }\n}\n","sourceCodeStart":156,"sourceCodeEnd":184,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/f7.rs#L156-L184","documentation":"On STM32F7, bank configuration is controlled by the N_DBANK bit (0 = dual bank, 1 = single bank). When Embassy is built with the 'single-bank' feature but N_DBANK indicates the hardware is in dual-bank mode, the compile-time flash layout does not match the physical one, so check_bank_setup() panics to prevent incorrect erase/write addressing.","triggerScenarios":"Flash initialization on a bank-setup-configurable F7 part built with feature = \"single-bank\" while FLASH.optcr.N_DBANK == 0 (dual bank).","commonSituations":"Firmware built for single-bank (e.g. to simplify sector layout) running on boards whose option bytes keep dual-bank enabled from factory; feature/option-byte drift after flashing a different firmware variant.","solutions":["Rebuild with the 'dual-bank' feature, or set N_DBANK=1 in the user option bytes (via STM32CubeProgrammer, then power cycle) to make hardware single-bank.","Decide the desired layout first, then keep cargo features and option bytes in lockstep.","Document/CI-check the feature flags that must match each board's option-byte image."],"exampleFix":"// before (Cargo.toml, hardware dual-bank F7)\nfeatures = [\"stm32f767zi\", \"single-bank\"]\n// after\nfeatures = [\"stm32f767zi\", \"dual-bank\"]\n// or set option byte N_DBANK=1 via STM32CubeProgrammer and power cycle","handlingStrategy":"validation","validationCode":"fn f7_bank_ok(single_bank_feature: bool, n_dbank: bool) -> bool {\n    single_bank_feature == n_dbank // N_DBANK=1 means single bank\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember F7 polarity: N_DBANK=1 => single bank, 0 => dual bank","Set option bytes and cargo features together in board bring-up scripts","Power cycle after option-byte changes so they take effect"],"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"}