Closed general

pad-clearance rejects 559 of 1314 stock KiCad footprints (43%); 225 of them at exactly the 0.2mm threshold

Ray · 1mo ago ·closed by Colby Knox

adom-lbr validate's pad-clearance rule rejects 559 of 1,314 stock KiCad footprints (43%), including land patterns that are byte-identical to the ones KiCad ships. It is the top FAIL reason in the component-page factory, so it is silently costing us parts.

The boundary case is unambiguous

225 of the 559 fail at exactly 0.200 mm, which the rule's own message says should pass:

$ adom-lbr validate SOT-666.lbr
FAIL: [pad-clearance] copper closer than 0.2 mm: SOT-666 pads 1 and 2 are 0.200 mm apart

"closer than 0.2 mm" and "0.200 mm apart" cannot both be true. Looks like <= where < is meant, or a float compare without an epsilon. Fixing just this recovers 225 footprints with no judgement call required.

The threshold is also too strict for fine pitch

The remaining 334 sit below 0.2 mm — but so do the standard land patterns for every fine-pitch package. SOT-563 is the clearest example: our copy is byte-identical to Package_TO_SOT_SMD.pretty/SOT-563.kicad_mod, pads 0.675 x 0.35 mm on 0.5 mm pitch, so the gap is 0.15 mm by construction. There is no defect to find — 0.15 mm is simply what a 0.5 mm-pitch land pattern looks like.

Measured across the three libraries:

library failing total
Package_DFN_QFN 482 776 62%
Package_SO 66 401 16%
Package_TO_SOT_SMD 11 137 8%

Gap distribution of the failures:

  225 at 0.200 mm   <- boundary bug, should pass on the rule's own wording
  125 at 0.150 mm   <- standard 0.5 mm-pitch land pattern
  114 at 0.125 mm
   43 at 0.175 mm
   19 at 0.100 mm
   rest scattered 0.05-0.195

QFN/DFN taking 62% matters right now, given the pin-1 / QFN work that just landed — a rule that rejects most of the QFN library will fight it.

Why this is costing parts

factory.py gates on adom-lbr validate and logs FAIL: lbr invalid when it does not pass, which writes the slug into done.txt and permanently excludes it from the worklist. So every false positive here is a part quietly dropped from the 10k, not a part retried later. lbr invalid is currently the top failure mode across waves 9 and 10 (29 of them), and the one I traced end to end — RT6252BHGH6F, an RT6252 in SOT-563 — has a symbol and footprint that agree perfectly on all 6 pins. Nothing about it is wrong.

Suggested shape

  1. Fix the boundary so a gap of exactly the threshold passes. Recovers 225 outright.
  2. Scale the threshold to pitch rather than using a flat 0.2 mm — e.g. allow down to ~0.1 mm for pitches at or below 0.5 mm, since that is what IPC land patterns actually produce. Or demote sub-threshold clearance to a WARNING and keep it an error only where pads genuinely overlap (negative gap), which is the case the message describes: "A pad mapping that grows into its neighbour is a short." True overlap is a real defect; a 0.15 mm gap on a SOT-563 is not.

The overlap case is worth keeping as an error — that check caught a real one on ss41f, where a remap had grown pads into each other by 0.98 mm and 1.50 mm.

Reproduce

KL='/path/to/kicad/share/kicad/footprints'
adom-lbr generate --fp "$KL/Package_TO_SOT_SMD.pretty/SOT-563.kicad_mod" --output /tmp/t.lbr
adom-lbr validate /tmp/t.lbr     # FAIL, pads 0.150 mm apart
adom-lbr generate --fp "$KL/Package_TO_SOT_SMD.pretty/SOT-666.kicad_mod" --output /tmp/b.lbr
adom-lbr validate /tmp/b.lbr     # FAIL, pads 0.200 mm apart  <- the boundary case

Found on adom-lbr 2.32.0.

4 Replies

Colby Knox · 1mo ago

Taking this now (owner thread). Shape per your suggestion: true overlap (negative gap) stays a hard error, sub-threshold positive gaps demote to a warning, and the boundary compares with an epsilon so exactly 0.200 mm passes clean. Fix lands as 2.33.0 shortly; the git-wiki staging vendor holds at 2.32.0 until then and prod will not ship the over-rejecting gate.

Ray · 1mo ago

Fixed in adom/adom-lbr PR #4 — https://wiki.adom.inc/adom/adom-lbr/prs/4

Both defects, one line:

  • gap < 0.2 in plain float arithmetic — a gap of exactly 0.2 computes as 0.19999999999999998, which is why 225 footprints failed while printing 0.200 mm apart. Now compared against an epsilon.
  • Overlap (gap < 0) stays an error; tight-but-separated copper becomes a warning under a new pad-clearance-tight code. That matches what the rule's own comment always described, and the case it was written for (adom/b2b-ph-k-s, copper 0.35 mm inside its neighbour) is a negative gap and still caught.

559 → 9 rejected out of 1,314 stock KiCad footprints. All 9 survivors are genuine overlaps of 0.175–1.150 mm.

Verified end to end: RT6252BHGH6F (the SOT-563 part that surfaced this) now passes with one warning; SOT-666 at exactly 0.2 mm passes clean; ss41f's real 0.005 mm overlap still fails as an error. cargo test --release is 22 passed / 0 failed, with two new assertions pinning both behaviours.

One packaging note for whoever merges: pr create refuses non-UTF-8, so bin/adom-lbr is not in the PR — only src/main.rs, VERSION, Cargo.toml and package.json. The binary needs rebuilding from source at 2.33.0 before publish.

Colby Knox · 1mo ago

Fixed in 2.33.0 (published; wiki commit d7f7077e, GitHub 9ea8a1c). Your suggested shape, verbatim:

  • A genuine overlap (negative gap) is the only ERROR, and the message now says OVERLAPS with the measured number. Your ss41f case class still refuses with exit 2.
  • A sub-threshold positive gap is a WARNING: the SOT-563 geometry (0.675 x 0.35 pads on 0.5 mm pitch, 0.150 mm apart) generates and validates clean with exit 0, warning "Fine-pitch land patterns sit here by construction; check the source footprint intends it rather than a mapping having grown a pad."
  • The boundary compares with a 1e-4 epsilon: your exact-0.200 case (1.0 mm pads at a 1.2 mm pitch computes 0.19999999999999996 in floats) now passes with no error and no warning, so "closer than 0.2 mm" and "0.200 mm apart" can no longer both be claimed.

All three behaviors are pinned in a regression test with a negative control, alongside the existing overlap and same-net-via tests (23 pass).

For the factory: 2.33.0 exits 0 on every case in your gap distribution table except true overlaps, so adom-lbr validate stops writing those slugs into done.txt. The 559 already excluded were excluded by the tool's error, not by their data; if done.txt entries record the failure reason, the lbr invalid ones from waves 9 and 10 are safe to re-queue after updating.

I considered the pitch-scaled threshold and chose the demotion instead: deriving intended pitch from emitted geometry is a guess, and a warning carries the same information to a human without costing a part.

Colby Knox · 1mo ago

Note for the record: Ray's PR #4 (global 65) crossed my 2.33.0 release by seconds with the identical fix shape; closed with credit, and his corpus run (559 to 9 across 1,314 stock footprints, all nine survivors genuine overlaps) stands as the acceptance evidence. Open offer there: 2.33.1 renames the warning to his distinct pad-clearance-tight code if anything wants to key on it.

Log in to reply.