Part facts: the parts snapshot¶
The checks that compare a part's MPNs with what its instance asks for (value, tolerance, dielectric, package, ratings) and the footprint review read part facts from one committed file beside the project, parts.lock.toml, like Cargo.lock. A check run never asks a server: CI runs offline and gives the same result on every PC.
berc parts refresh PROJECT --from parts.toml [--check] [--symbols DIR] [--footprints DIR] [--format text|json]
berc parts refresh writes the snapshot again from a part source. It holds every MPN field (Mpn1, MPN_2, Manufacturer_Part_Number, ...) of the parts fitted in the base design or any variant, and per MPN the facts the checks use: each with its value, the source that stated it, its rank and when. With a board file it also holds, for the review hash of each board footprint's library footprint (berc fp hash, the board copy's where no library file is found; --symbols and --footprints as for berc fp check) and each MPN placed with it, the footprint reviews that cover the pair. An MPN taken off the board leaves the file. The file is sorted and has one line per fact, so its git diff after a refresh shows exactly what changed in the source: a new value, a retracted review.
| key | what |
|---|---|
capacitance, resistance, inductance |
the value, in F, Ω, H |
tolerance |
below and above the value, in % or in its unit |
rated_voltage, power, saturation_current |
ratings, in V, W, A |
dielectric, technology, case_eia |
words: X7R, thick_film, 0402 |
--from FILE takes part data from a file in the snapshot's own shape: hand-filled facts, or another board's snapshot. Without it, a berc built with the mx3 feature asks the mx3 part store: the facts by MPN (params/by_mpn) and the reviews of each pair (fp/review/check). It finds the store as the mx3 command line does: the URL from MX3_URL, else [share] mx3_url in tpm's config.toml (TPM_ROOT, else ~/git/tpm), else http://localhost:3000; the token from MX3_TOKEN, else ~/.config/mx3/token (mx3 token set). The token is sent only in the request header and never printed. --check writes nothing and exits 1 when the snapshot is out of date, for a CI step; exit 2 is a design, source or file error. The project file can put the snapshot elsewhere: [parts] lock = "data/parts.lock.toml".
An MPN on the board that the snapshot lacks is a finding, BOM-20, until the next refresh: a new part cannot reach the BOM unchecked. Without a snapshot the checks that need it report themselves as not run.
Display fields from the snapshot¶
A resistor's or capacitor's display fields state what all its MPNs guarantee, and berc fields sync writes them from parts.lock.toml (BOM-12 and LIB-6 hold them to the same values):
| Field | Value |
|---|---|
Voltage (capacitors), Power (resistors) |
the lowest rating over all MPNs: 25V; a power below 1 W in whole mW (62.5 mW is 63mW) or with more digits where that rounds too far (2.5mW), one of 1 W or more as 1W |
Dielectric (capacitors) |
the worst code of the ceramic MPNs, the one every other code covers (X5R for X5R and X7R) |
Package |
the case every MPN has (0402) |
A Voltage or Power text states a rating when it equals the rating. It also states it when it is a close rounding: the rating rounded half up to the precision of the text. The two may differ by at most drawing.fields.rating_rounding_max percent of the rating. The default is 1; set it with --set or in the project file.
So 63mW states 62.5 mW (1/16 W, 0.8 % apart), while 62mW and 0.1W do not. A fraction such as 1/16W is not rounded. A field that already states the rating keeps its text.
A field equal to the board default (for a rating: a default that states it), the text variables DEFAULT_C_PACKAGE, DEFAULT_C_VOLTAGE, DEFAULT_C_DIELECTRIC, DEFAULT_R_PACKAGE and DEFAULT_R_POWER, is removed from the part. A part without the field that is off the default gets one, shown and placed as place-fields places fields (--set takes its drawing.* settings). Only these four fields change; nothing else is removed. An MPN missing the fact (no rated voltage, no case_eia), a dielectric code that is not read, or MPNs that differ in case leave the field as it is and are listed with the reason. A part with no MPN in the snapshot is not touched.
The default is a dry run: one line per field, then the totals. --write edits the .kicad_sch files in place and keeps every other byte. Close the schematic in KiCad first, and run berc parts refresh before, since the fields follow the snapshot. A run after --write finds nothing to do, and the BOM-12 findings on these fields are gone. Exit code 2: a design or file error, or no snapshot.
mx3: Datasheet links¶
A part symbol's Datasheet can be an mx3: link, mx3:${Mpn1} ${Mpn2}: KiCad's Show Datasheet then opens the library's document of the symbol's part numbers. KiCad has no wildcard over fields, so the link names each MPN field. LIB-30 warns when a placed symbol's link references an MPN field the symbol lacks (KiCad shows ${Mpn5} unresolved), or misses one it has (a field added later). An empty field counts as had; a vendor URL or an empty Datasheet is never looked at.
berc fix datasheet-links rewrites each such link to mx3: and a reference to each of the symbol's MPN fields, in field order. Each copy in the schematic's lib_symbols whose Datasheet is an mx3: link takes the library symbol's text, found through the project's and KiCad's sym-lib-table or --symbols. Only the Datasheet text changes. A dry run by default; --write refuses while KiCad holds the project or a sheet (its ~NAME.kicad_pro.lck or ~NAME.kicad_sch.lck), since KiCad's next save would overwrite the fix.