embassy-rs/embassy · error
Could not find SWD pin to cfg gate
Error message
Could not find SWD pin to cfg gate
What it means
For each pin exposed by DEBUGSS, the build script searches the singletons for the corresponding GPIO and panics if the SWD pin cannot be matched to a generated singleton. This is an internal consistency check between the DEBUGSS pin list and the GPIO singletons of the package.
Solutions
- Verify the pin names in DEBUGSS.pins exactly match the GPIO singleton names generated for the package.
- Fix the chip metadata (SWCLK/SWDIO pin assignments) and rebuild.
- Regenerate metadata from vendor sources to restore consistent pin naming.
Example fix
// before (metadata)
- { signal: SWDIO, pin: PA18 } // no PA18 singleton
// after
- { signal: SWDIO, pin: PA19 } // matches generated PA19 singleton Defensive patterns
Strategy: validation
Validate before calling
for pin in &debugss.pins {
assert!(singletons.iter().any(|s| s.name == pin.pin), "DEBUGSS pin {} missing singleton", pin.pin);
} Prevention
- Verify SWCLK/SWDIO pin numbers against the datasheet for each package variant.
- Keep one naming convention (PAxx) across all metadata pin references.
- Add a metadata consistency test comparing DEBUGSS pins to GPIO singletons.
When it happens
Trigger: Building embassy-mspm0 when DEBUGSS.pins references a pin (e.g. PA19/PA20 for SWDIO/SWCLK) whose name does not match any entry in the generated singletons vector, inside generate_code -> pin_features.
Common situations: Pin-name mismatch between the DEBUGSS metadata and GPIO singleton naming (wrong pin number/letter case); a package variant where the SWD pad is named differently; edited metadata introducing a typo.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not find NRST pin to cfg gate
- Could not find any timer
- no SYSCTL peripheral
- Could not find DEBUGSS peripheral
- Timer does not exist
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/3940309ee7e5808e.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-mspm0/build.rs:534
let pin = singletons
.iter_mut()
.find(|s| s.name == pin.pin)
.expect("Could not find NRST pin to cfg gate");
pin.cfg = Some(quote! { #[cfg(feature = "nrst-pin-as-gpio")] });
}
let debugss = METADATA
.peripherals
.iter()
.find(|p| p.name == "DEBUGSS")
.expect("Could not find DEBUGSS peripheral");
for pin in debugss.pins.iter() {
let pin = singletons
.iter_mut()
.find(|s| s.name == pin.pin)
.expect("Could not find SWD pin to cfg gate");
pin.cfg = Some(quote! { #[cfg(feature = "swd-pins-as-gpio")] });
}
}
fn generate_singletons(singletons: &[Singleton]) -> TokenStream {
let singletons_peripherals_struct = singletons
.iter()
.map(|s| {
let cfg = s.cfg.clone().unwrap_or_default();
let ident = format_ident!("{}", s.name);
quote! {
#cfg
#ident
}
})View on GitHub (pinned to 463a07b963)