{"record":{"id":"efca0dc11d32ccc3","repo":"embassy-rs/embassy","slug":"could-not-find-nrst-pin-to-cfg-gate","errorCode":null,"errorMessage":"Could not find NRST pin to cfg gate","messagePattern":"Could not find NRST pin to cfg gate","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-mspm0/build.rs","lineNumber":519,"sourceCode":"                singleton.cfg = Some(quote! { #[cfg(not(feature = #feature))] });\n            }\n        }\n    }\n}\n\nfn pin_features(singletons: &mut Vec<Singleton>) {\n    let sysctl = METADATA\n        .peripherals\n        .iter()\n        .find(|p| p.name == \"SYSCTL\")\n        .expect(\"no SYSCTL peripheral\");\n\n    // Some packages make NRST share a physical pin with a GPIO.\n    if let Some(pin) = sysctl.pins.iter().find(|p| p.signal == \"NRST\" && p.pin != \"NRST\") {\n        let pin = singletons\n            .iter_mut()\n            .find(|s| s.name == pin.pin)\n            .expect(\"Could not find NRST pin to cfg gate\");\n\n        pin.cfg = Some(quote! { #[cfg(feature = \"nrst-pin-as-gpio\")] });\n    }\n\n    let debugss = METADATA\n        .peripherals\n        .iter()\n        .find(|p| p.name == \"DEBUGSS\")\n        .expect(\"Could not find DEBUGSS peripheral\");\n\n    for pin in debugss.pins.iter() {\n        let pin = singletons\n            .iter_mut()\n            .find(|s| s.name == pin.pin)\n            .expect(\"Could not find SWD pin to cfg gate\");\n\n        pin.cfg = Some(quote! { #[cfg(feature = \"swd-pins-as-gpio\")] });\n    }","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-mspm0/build.rs#L501-L537","documentation":"After locating the SYSCTL NRST signal, the build script searches the generated singleton list for the GPIO pin that physically shares the NRST pad and panics if no singleton matches. This indicates an internal inconsistency: SYSCTL says NRST is muxed with a GPIO pin, but that pin was not created as a singleton.","triggerScenarios":"Building embassy-mspm0 when the chip metadata declares SYSCTL.pins containing signal == \"NRST\" with pin != \"NRST\" (a shared GPIO pad), but the corresponding GPIO singleton name is not present in the singletons vector generated for the package.","commonSituations":"Chip metadata listing the shared NRST/GPIO pad with a name that differs from the GPIO singleton naming scheme (e.g. wrong pin number in the YAML); a package where that GPIO is excluded from the singleton list; stale or hand-edited metadata.","solutions":["Check that the pin name in SYSCTL.pins for the NRST signal exactly matches the GPIO singleton name generated for the package (e.g. \"PA31\").","Correct the chip metadata so the NRST shared pin name matches the GPIO naming convention and rebuild.","Regenerate metadata from the vendor source so the pin name is consistent with the GPIO list."],"exampleFix":"// before (metadata) signal: NRST, pin: PA30 (no PA30 singleton)\n// after\nsignal: NRST, pin: PA31  // matches generated PA31 singleton","handlingStrategy":"validation","validationCode":"// cross-check NRST shared pin against singletons\nif let Some(nr) = sysctl.pins.iter().find(|p| p.signal == \"NRST\" && p.pin != \"NRST\") {\n    assert!(singletons.iter().any(|s| s.name == nr.pin), \"NRST shares {} but no singleton\", nr.pin);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep SYSCTL.pins pin names in the exact GPIO naming scheme (PAxx/PBxx).","After metadata edits, diff pin names against the generated singleton list.","Validate metadata with a script that checks every peripheral pin maps to a GPIO singleton."],"tags":["build-script","embedded","gpio","panic","rust"],"backgroundTag":"resource-not-found","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}