embassy-rs/embassy · critical
Embassy is configured as dual-bank, but the hardware is…
Error message
Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use single-bank config
What it means
This panic comes from check_bank_setup in embassy-stm32's flash driver for STM32G0x1 devices. The 'dual-bank' cargo feature was enabled, but the OPTR register's DUAL_BANK bit indicates the chip is running in single-bank mode. Embassy panics because a dual-bank driver layout would address flash incorrectly on single-bank hardware.
Solutions
- Change your embassy-stm32 feature from "dual-bank" to "single-bank" in Cargo.toml to match the default single-bank hardware
- Set the DUAL_BANK option bit to 1 in the user option bytes (STM32CubeProgrammer or probe-rs) if you truly need dual-bank operation
- After changing option bytes, power-cycle the chip and verify OPTR via debugger before reflashing
Example fix
// before (Cargo.toml)
embassy-stm32 = { version = "...", features = ["stm32g071xx", "dual-bank"] }
// after
embassy-stm32 = { version = "...", features = ["stm32g071xx", "single-bank"] } Defensive patterns
Strategy: validation
Validate before calling
// Rust, before initializing the flash driver
let optr = unsafe { pac::FLASH.optr().read() };
assert_eq!(optr.dual_bank(), cfg!(feature = "dual-bank"),
"embassy flash bank feature must match OPTR.DUAL_BANK"); Prevention
- Verify option bytes after factory reset or mass erase, since defaults may be single-bank
- Pin per-board cargo features and never copy them between board variants unchecked
- Check OPTR via debugger when bringing up a new board revision
When it happens
Trigger: Building with feature = "dual-bank" for an STM32G0x1 target whose user option bytes have DUAL_BANK=0; the panic fires at flash init when check_bank_setup evaluates !pac::FLASH.optr().read().dual_bank().
Common situations: Enabling dual-bank features copied from an L4/G4 project; factory-default G0 option bytes (single-bank) with a dual-bank-configured build; cargo feature set for a different board variant sharing the same codebase.
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 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 single-bank, but the hardware is…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/7c960beee835dc9a.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/flash/g.rs:275
"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_g0x1))]
pub(crate) fn check_bank_setup() {
if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dual_bank() {
panic!(
"Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use dual-bank config"
);
}
if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dual_bank() {
panic!(
"Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use single-bank config"
);
}
}
View on GitHub (pinned to 463a07b963)