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 dbank value in the user option bytes or configure embassy to use dual-bank config
What it means
On STM32G4 (and configurable G0) parts, the DBANK option bit selects dual-bank mode. Embassy built with 'single-bank' but with hardware DBANK=1 (dual) would compute wrong flash addresses, so check_bank_setup() panics at initialization. The panic names the exact option byte (dbank) to fix.
Solutions
- Rebuild with the 'dual-bank' feature, or clear the DBANK option bit (STM32CubeProgrammer, then power cycle) to put the chip in single-bank mode.
- Match the feature flag to the bank count your flash layout (partitions/bootloader) assumes.
- Verify after any option-byte erase/reset that firmware features still match.
Example fix
// before (Cargo.toml, G4 hardware dual-bank) features = ["stm32g474re", "single-bank"] // after features = ["stm32g474re", "dual-bank"] // or clear DBANK option byte and power cycle
Defensive patterns
Strategy: validation
Validate before calling
fn g4_bank_ok(single_bank_feature: bool, dbank: bool) -> bool {
single_bank_feature == !dbank // DBANK=1 means dual bank
} Prevention
- Check DBANK option bit on G4 boards before choosing flash features
- Avoid resetting option bytes to defaults if firmware expects single-bank
- Match DBANK with your partition/bootloader layout requirements
When it happens
Trigger: Flash init on G4 (c2/c3/c4 variants) built with feature = "single-bank" while FLASH.optr.DBANK == 1.
Common situations: G4 boards shipped with dual-bank option bytes while firmware built single-bank for simpler sector sizes; after factory reset of option bytes; feature flag toggled for a different board and reused.
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 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 dual-bank, but the hardware is…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/c4bc501db180046c.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/flash/g.rs:256
if DATA_CACHE_WAS_ENABLED.load(Ordering::Relaxed) {
// Reset data cache before re-enabling
pac::FLASH.acr().modify(|w| w.set_dcrst(true));
pac::FLASH.acr().modify(|w| w.set_dcrst(false));
pac::FLASH.acr().modify(|w| w.set_dcen(true));
}
}
// G0 doesn't have data cache, use no-op functions
#[cfg(any(flash_g0x0, flash_g0x1))]
fn save_data_cache_state() {}
#[cfg(any(flash_g0x0, flash_g0x1))]
fn restore_data_cache_state() {}
#[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() {View on GitHub (pinned to 463a07b963)