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 dualbank 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 STM32L4 devices. The 'single-bank' cargo feature was enabled, but the FLASH OPTR register's DUALBANK bit shows the chip is running in dual-bank mode (the L4 register field is named dualbank, unlike G0/L5). Embassy panics at init since a single-bank driver would corrupt flash on dual-bank L4 hardware.
Solutions
- Change your embassy-stm32 feature from "single-bank" to "dual-bank" in Cargo.toml to match DUALBANK=1 hardware
- Clear the DUALBANK option bit to 0 in the user option bytes (STM32CubeProgrammer or probe-rs) if single-bank operation is desired; this alters page size and erases flash content
- Verify the option bytes via debugger after programming, then rebuild and reflash
Example fix
// before (Cargo.toml)
embassy-stm32 = { version = "...", features = ["stm32l475vg", "single-bank"] }
// after
embassy-stm32 = { version = "...", features = ["stm32l475vg", "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.dualbank(), cfg!(feature = "dual-bank"),
"embassy flash bank feature must match OPTR.DUALBANK"); Prevention
- Note that on L4 the option bit is DUALBANK (not dual_bank/dbank); use the correct register field when checking
- Large L4 devices (>1MB) commonly ship with DUALBANK set; pick features accordingly
- Reprogram and verify option bytes whenever switching programmers or bootloaders
When it happens
Trigger: Building with feature = "single-bank" for an STM32L4 target whose user option bytes have DUALBANK=1; panic fires at flash init when check_bank_setup reads pac::FLASH.optr().read().dualbank().
Common situations: L4 devices with >1MB flash default to dual-bank option bytes while Cargo features assume single-bank; option bytes changed by STM32CubeProgrammer or a bootloader; reusing feature sets from single-bank L4 variants.
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 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…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/2bd5080fdd5aa0de.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/flash/l.rs:433
#[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() {
panic!(
"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use single-bank config"
);
}
}
View on GitHub (pinned to 463a07b963)