embassy-rs/embassy · critical
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 dbank value in the user option bytes or configure embassy to use dual-bank config
What it means
This panic comes from check_bank_setup in embassy-stm32's flash driver for STM32L5 devices. The 'single-bank' cargo feature was enabled, but the FLASH OPTR register's DBANK bit shows the chip is running in dual-bank mode. Embassy panics at init since a single-bank driver would corrupt flash on dual-bank L5 hardware.
Solutions
- Change your embassy-stm32 feature from "single-bank" to "dual-bank" in Cargo.toml to match the DBANK=1 hardware
- Clear the DBANK option bit to 0 in the user option bytes (STM32CubeProgrammer or probe-rs) if single-bank operation is desired; note this changes page size/bank layout and mass-erases flash
- Verify the new option bytes via debugger after flashing them, then rebuild
Example fix
// before (Cargo.toml)
embassy-stm32 = { version = "...", features = ["stm32l552xx", "single-bank"] }
// after
embassy-stm32 = { version = "...", features = ["stm32l552xx", "dual-bank"] } Defensive patterns
Strategy: validation
Validate before calling
// Rust, before initializing the flash driver
let optr = unsafe { pac::FLASH.optr().read() };
assert_eq!(optr.dbank(), cfg!(feature = "dual-bank"),
"embassy flash bank feature must match OPTR.DBANK"); Prevention
- Remember STM32L5 defaults often have DBANK set; align Cargo features with actual option bytes
- Back up flash contents before changing DBANK, since it re-partitions flash and erases data
- Validate option bytes after any STM32CubeIDE/Programmer project that reprograms them
When it happens
Trigger: Building with feature = "single-bank" for an STM32L5 target whose user option bytes have DBANK=1; panic fires at flash init when check_bank_setup reads pac::FLASH.optr().read().dbank().
Common situations: STM32L5 factory option bytes often leave DBANK set while the developer's Cargo features assume single-bank; option bytes changed by a previous STM32CubeIDE/Programmer project; features copied from a single-bank L4 sibling chip.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Embassy is configured as single-bank, but the hardware is…
- Embassy is configured as dual-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 single-bank, but the hardware is…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/f6041c0aafb9d11d.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/flash/l.rs:419
if nssr.nssizerr() {
return Err(Error::Size);
}
if nssr.nspgserr() {
return Err(Error::Seq);
}
return Ok(());
}
}
}
}
#[cfg(all(bank_setup_configurable, flash_l5))]
pub(crate) fn check_bank_setup() {
if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dbank() {
panic!(
"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"
);
}
if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dbank() {
panic!(
"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"
);
}
}
#[cfg(all(bank_setup_configurable, flash_l4))]
pub(crate) fn check_bank_setup() {
if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dualbank() {
panic!(
"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use dual-bank config"
);
}
if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dualbank() {View on GitHub (pinned to 463a07b963)