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 dual_bank 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 STM32G0x1 devices. The embassy 'single-bank' cargo feature was enabled, but the FLASH option register (OPTR) DUAL_BANK bit read at startup shows the chip is actually running in dual-bank mode. Embassy panics immediately because a single-bank driver would corrupt flash if used against dual-bank hardware.
Solutions
- Set the dual_bank option bit to 0 in the user option bytes (via STM32CubeProgrammer, probe-rs, or an option-byte erase/program at your own risk) so hardware runs single-bank
- Change your embassy-stm32 feature from "single-bank" to "dual-bank" in Cargo.toml so the driver matches the hardware
- Read back and verify option bytes with the debugger after changing them, then rebuild and flash
Example fix
// before (Cargo.toml)
embassy-stm32 = { version = "...", features = ["stm32g071xx", "single-bank"] }
// after
embassy-stm32 = { version = "...", features = ["stm32g071xx", "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.dual_bank(), cfg!(feature = "dual-bank"),
"embassy flash bank feature must match OPTR.DUAL_BANK"); Prevention
- Keep the bank feature in a per-board Cargo feature and derive it from the target chip documentation
- Read back option bytes with probe-rs or STM32CubeProgrammer after any debugger/programmer session that touches them
- Document the required option-byte setting next to the flash driver setup in your firmware
- Add a CI check that the same board always builds with the same bank feature
When it happens
Trigger: Building with feature = "single-bank" for an STM32G0x1 target whose user option bytes have DUAL_BANK=1; the panic fires at flash-driver init when check_bank_setup reads pac::FLASH.optr().read().dual_bank().
Common situations: Reusing Cargo features copied from another board's project; a previous firmware/STM32CubeProgrammer run left DUAL_BANK set in option bytes; switching chips on the same board without re-flashing option bytes; cargo feature not updated after changing hardware revision.
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 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 single-bank, but the hardware is…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/5d28eac75ed4b9fc.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/flash/g.rs:270
#[cfg(all(bank_setup_configurable, any(flash_g4c2, flash_g4c3, flash_g4c4)))]
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_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)