embassy-rs/embassy · error

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 dbank value in the user option bytes or configure embassy to use single-bank config

What it means

Inverse of 208 for G-series: Embassy compiled with the 'dual-bank' feature while the hardware DBANK bit shows single-bank mode. The dual-bank sector map would not match the physical flash, so check_bank_setup() panics before any flash operation can misaddress memory.

Solutions

  1. Rebuild with the 'single-bank' feature, or set the DBANK option bit to 1 (dual-bank) and power cycle.
  2. Confirm which layout your application/bootloader expects and align both firmware features and option bytes to it.
  3. Add option-byte checks to your flashing/production procedure to catch drift early.

Example fix

// before (Cargo.toml, G4 hardware single-bank)
features = ["stm32g474re", "dual-bank"]
// after
features = ["stm32g474re", "single-bank"]
Defensive patterns

Strategy: validation

Validate before calling

fn g4_bank_ok(dual_bank_feature: bool, dbank: bool) -> bool {
    dual_bank_feature == dbank
}

Prevention

When it happens

Trigger: Flash init on a configurable G4/G0 part built with feature = "dual-bank" while FLASH.optr.DBANK == 0 (single bank).

Common situations: Option bytes configured single-bank (e.g. for a large contiguous partition) while the firmware keeps dual-bank features; reusing a Cargo.toml from a dual-bank board.

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


AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10). Data as JSON: /api/errors/44cf4c63cda27e53. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/src/flash/g.rs:261

    }
}

// 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() {
        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)