{"record":{"id":"eac6bdcdf0bee483","repo":"embassy-rs/embassy","slug":"embassy-is-configured-as-single-bank-but-the-hard","errorCode":null,"errorMessage":"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the db1m 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 db1m 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/f4.rs","lineNumber":377,"sourceCode":"            assert_sector(0x10, FlashBank::Bank2, 0, 0x0808_0000, SMALL_SECTOR_SIZE, 0x0808_3FFF);\n            assert_sector(0x13, FlashBank::Bank2, 3, 0x0808_C000, SMALL_SECTOR_SIZE, 0x0808_C000);\n            assert_sector(0x13, FlashBank::Bank2, 3, 0x0808_C000, SMALL_SECTOR_SIZE, 0x0808_FFFF);\n\n            assert_sector(0x14, FlashBank::Bank2, 4, 0x0809_0000, MEDIUM_SECTOR_SIZE, 0x0809_0000);\n            assert_sector(0x14, FlashBank::Bank2, 4, 0x0809_0000, MEDIUM_SECTOR_SIZE, 0x0809_FFFF);\n\n            assert_sector(0x15, FlashBank::Bank2, 5, 0x080A_0000, LARGE_SECTOR_SIZE, 0x080A_0000);\n            assert_sector(0x15, FlashBank::Bank2, 5, 0x080A_0000, LARGE_SECTOR_SIZE, 0x080B_FFFF);\n            assert_sector(0x17, FlashBank::Bank2, 7, 0x080E_0000, LARGE_SECTOR_SIZE, 0x080E_0000);\n            assert_sector(0x17, FlashBank::Bank2, 7, 0x080E_0000, LARGE_SECTOR_SIZE, 0x080F_FFFF);\n        }\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().db1m() {\n        panic!(\n            \"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the db1m 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().db1m() {\n        panic!(\n            \"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use single-bank config\"\n        );\n    }\n}\n","sourceCodeStart":359,"sourceCodeEnd":387,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/flash/f4.rs#L359-L387","documentation":"check_bank_setup() validates that the compile-time 'single-bank' feature matches the actual hardware bank configuration stored in the FLASH.optcr DB1M option bit. If Embassy was built with single-bank layout (one contiguous bank) but the chip's option bytes say dual-bank, all flash addresses/sector math would be wrong, so it panics at init instead of corrupting flash.","triggerScenarios":"Building embassy-stm32 for an F4 part with the 'single-bank' feature while the device's user option bytes have DB1M=1 (dual-bank), then initializing flash.","commonSituations":"Cargo feature set incorrectly for the board's shipped option-byte configuration; boards factory-programmed with dual-bank; developer changed features without updating option bytes (or vice versa); option bytes modified by a bootloader.","solutions":["Align the Embassy cargo feature with hardware: either enable the 'dual-bank' feature or reconfigure the chip's DB1M option byte to 0 (single-bank) and apply the option-byte change (requires a power cycle).","Inspect/modify option bytes with STM32CubeProgrammer: read FLASH optcr DB1M, set as needed, and flash the option bytes.","Confirm which variant your chip is (1MB parts are the configurable ones) and set the matching embassy-stm32 feature flag in Cargo.toml."],"exampleFix":"// before (Cargo.toml, hardware is dual-bank)\nembassy-stm32 = { version = \"...\", features = [\"stm32f429zi\", \"single-bank\"] }\n// after\nembassy-stm32 = { version = \"...\", features = [\"stm32f429zi\", \"dual-bank\"] }","handlingStrategy":"validation","validationCode":"// check with STM32CubeProgrammer or at boot:\n// read FLASH.optcr.DB1M and compare with the cargo feature\nfn bank_config_matches(single_bank_feature: bool, db1m: bool) -> bool {\n    single_bank_feature != db1m // single-bank feature requires DB1M=0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a per-board mapping of option bytes to required embassy features","After flashing option bytes, always power cycle and re-verify","Set embassy-stm32 bank features deliberately in Cargo.toml, not by copying templates"],"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"}