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

What it means

Inverse of 206 for F7: Embassy compiled with the 'dual-bank' feature while the N_DBANK option bit shows single-bank hardware. The dual-bank sector map in the build would disagree with the chip, so check_bank_setup() panics before any flash erase/write can target wrong addresses.

Solutions

  1. Rebuild with the 'single-bank' feature, or change N_DBANK to 0 (dual-bank) in the option bytes and power cycle.
  2. Verify the flash layout requirements (partition table, bootloader placement) before switching either side.
  3. Keep one source of truth (e.g. a board config doc) mapping option bytes to required embassy features.

Example fix

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

Strategy: validation

Validate before calling

fn f7_bank_ok(dual_bank_feature: bool, n_dbank: bool) -> bool {
    dual_bank_feature == !n_dbank
}

Prevention

When it happens

Trigger: Flash init on a configurable F7 part built with feature = "dual-bank" while FLASH.optcr.N_DBANK == 1 (single bank).

Common situations: Option bytes set to single-bank to maximize contiguous flash, but firmware still built with dual-bank features; template Cargo.toml not adjusted for the 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/b8d643b56721f01d. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/src/flash/f7.rs:179

        assert_sector(4, 0x0802_0000, MEDIUM_SECTOR_SIZE, 0x0802_0000);
        assert_sector(4, 0x0802_0000, MEDIUM_SECTOR_SIZE, 0x0803_FFFF);

        assert_sector(5, 0x0804_0000, LARGE_SECTOR_SIZE, 0x0804_0000);
        assert_sector(5, 0x0804_0000, LARGE_SECTOR_SIZE, 0x0807_FFFF);
        assert_sector(7, 0x080C_0000, LARGE_SECTOR_SIZE, 0x080C_0000);
        assert_sector(7, 0x080C_0000, LARGE_SECTOR_SIZE, 0x080F_FFFF);
    }
}

#[cfg(all(bank_setup_configurable))]
pub(crate) fn check_bank_setup() {
    if cfg!(feature = "single-bank") && !pac::FLASH.optcr().read().n_dbank() {
        panic!(
            "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the ndbank value in the user option bytes or configure embassy to use dual-bank config"
        );
    }
    if cfg!(feature = "dual-bank") && pac::FLASH.optcr().read().n_dbank() {
        panic!(
            "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the ndbank value in the user option bytes or configure embassy to use single-bank config"
        );
    }
}

View on GitHub (pinned to 463a07b963)