embassy-rs/embassy · error
Embassy is configured as single-bank, but the hardware is…
Error message
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
What it means
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.
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.
Example fix
// before (Cargo.toml, hardware is dual-bank)
embassy-stm32 = { version = "...", features = ["stm32f429zi", "single-bank"] }
// after
embassy-stm32 = { version = "...", features = ["stm32f429zi", "dual-bank"] } Defensive patterns
Strategy: validation
Validate before calling
// check with STM32CubeProgrammer or at boot:
// read FLASH.optcr.DB1M and compare with the cargo feature
fn bank_config_matches(single_bank_feature: bool, db1m: bool) -> bool {
single_bank_feature != db1m // single-bank feature requires DB1M=0
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Embassy is configured as dual-bank, but the hardware is…
- Embassy is configured as single-bank, but the hardware is…
- Embassy is configured as dual-bank, but the hardware is…
- Embassy is configured as single-bank, but the hardware is…
- Embassy is configured as dual-bank, but the hardware is…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/eac6bdcdf0bee483.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/flash/f4.rs:377
assert_sector(0x10, FlashBank::Bank2, 0, 0x0808_0000, SMALL_SECTOR_SIZE, 0x0808_3FFF);
assert_sector(0x13, FlashBank::Bank2, 3, 0x0808_C000, SMALL_SECTOR_SIZE, 0x0808_C000);
assert_sector(0x13, FlashBank::Bank2, 3, 0x0808_C000, SMALL_SECTOR_SIZE, 0x0808_FFFF);
assert_sector(0x14, FlashBank::Bank2, 4, 0x0809_0000, MEDIUM_SECTOR_SIZE, 0x0809_0000);
assert_sector(0x14, FlashBank::Bank2, 4, 0x0809_0000, MEDIUM_SECTOR_SIZE, 0x0809_FFFF);
assert_sector(0x15, FlashBank::Bank2, 5, 0x080A_0000, LARGE_SECTOR_SIZE, 0x080A_0000);
assert_sector(0x15, FlashBank::Bank2, 5, 0x080A_0000, LARGE_SECTOR_SIZE, 0x080B_FFFF);
assert_sector(0x17, FlashBank::Bank2, 7, 0x080E_0000, LARGE_SECTOR_SIZE, 0x080E_0000);
assert_sector(0x17, FlashBank::Bank2, 7, 0x080E_0000, LARGE_SECTOR_SIZE, 0x080F_FFFF);
}
}
}
#[cfg(all(bank_setup_configurable))]
pub(crate) fn check_bank_setup() {
if cfg!(feature = "single-bank") && pac::FLASH.optcr().read().db1m() {
panic!(
"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"
);
}
if cfg!(feature = "dual-bank") && !pac::FLASH.optcr().read().db1m() {
panic!(
"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"
);
}
}
View on GitHub (pinned to 463a07b963)