embassy-rs/embassy · error

No mimxrt/lpc Cargo feature enabled

Error message

No mimxrt/lpc Cargo feature enabled

What it means

embassy-nxp's build script generates chip-specific code (singletons, registers, pins) based on which Cargo feature selects the target chip family. It expects exactly one `CARGO_FEATURE_MIMXRT*` or `CARGO_FEATURE_LPC*` environment variable set by Cargo. If none is present, no chip can be selected and the build script panics with this message.

Solutions

  1. Enable exactly one chip feature in Cargo.toml, e.g. `embassy-nxp = { version = "...", features = ["mimxrt1062"] }`.
  2. Check `cargo tree -e features` / `cargo metadata` to confirm another dependency isn't disabling your features (`default-features = false` downstream).
  3. Run `cargo build -vv` and inspect `CARGO_FEATURE_*` env vars if unsure which features are visible to build scripts.

Example fix

// before (Cargo.toml)
embassy-nxp = { version = "0.1", default-features = false }
// after
embassy-nxp = { version = "0.1", features = ["mimxrt1062"] }
Defensive patterns

Strategy: validation

Validate before calling

# In CI before building:
grep -q 'features = \["mimxrt\|lpc' Cargo.toml || (echo 'No NXP chip feature enabled' && exit 1)

Prevention

When it happens

Trigger: Building embassy-nxp as a dependency without enabling any chip feature (e.g. adding it to Cargo.toml with `default-features = false` and no chip feature), or running `cargo build` in the crate without `--features mimxrt1062` (or equivalent).

Common situations: Manually editing Cargo.toml and dropping feature flags; using `-Z avoid-dev-deps` or vendoring that strips default features; starting a fresh project from the crate skeleton before choosing a board.

Related errors


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

Appendix: source

Thrown at embassy-nxp/build.rs:29

use proc_macro2::{Ident, Literal, Span};
use quote::format_ident;
#[allow(unused)]
use quote::quote;

#[path = "./build_common.rs"]
mod common;

fn main() {
    let mut cfgs = common::CfgSet::new();
    common::set_target_cfgs(&mut cfgs);

    let chip_name = match env::vars()
        .map(|(a, _)| a)
        .filter(|x| x.starts_with("CARGO_FEATURE_MIMXRT") || x.starts_with("CARGO_FEATURE_LPC"))
        .get_one()
    {
        Ok(x) => x,
        Err(GetOneError::None) => panic!("No mimxrt/lpc Cargo feature enabled"),
        Err(GetOneError::Multiple) => panic!("Multiple mimxrt/lpc Cargo features enabled"),
    }
    .strip_prefix("CARGO_FEATURE_")
    .unwrap()
    .to_ascii_lowercase();

    let singletons = singletons(&mut cfgs);

    cfg_aliases! {
        rt1xxx: { any(feature = "mimxrt1011", feature = "mimxrt1062") },
    }

    cfg_aliases! {
        lpc55: { any(feature = "lpc55s16", feature = "lpc55-core0") },
    }

    eprintln!("chip: {chip_name}");

View on GitHub (pinned to 463a07b963)