Python · Command-line tool · Apache-2.0

kicad-fab-tools

A Python command-line tool that checks a KiCad board before you order it: design rules, parts list against the board, LCSC stock and price, then JLCPCB files.

View on GitHub

kicad-fab-tools is intended for the step immediately before a board is ordered. At that point, a footprint that is missing from the parts list or a connector that has been placed a quarter-turn wrong can still be corrected at no cost, rather than in a re-spin. The KiCad board and a CSV parts list are read, compared with each other and with live LCSC stock, and the files that JLCPCB requests are then written. Firedance uses the tool for the board orders of FirePod.

Install

Python 3.9 or newer and KiCad 8 or newer are required, and no other dependencies are needed.

pip install git+https://github.com/firedanceio/kicad-fab-tools

kicad-cli is run by the tool and is found on the PATH or inside the KiCad app on macOS. For any other location, KICAD_CLI has to be set.

Example: the whole order in one command

kicad-fab fab board.kicad_pcb --bom bom.csv --fixes rotation-fixes.csv -o fab-out

The fab command begins with the design-rule check of KiCad and stops on any error, unless --allow-drc-errors is passed. The Gerbers for every copper layer are then zipped together with the drill files, the parts list is compared with the board, and a JLCPCB BOM and placement file are written with the rotation fixes applied. Problems in the parts list are printed and end the run with exit status 1. The JLCPCB files are nevertheless written, so that they can still be opened.

When kicad-fab drc is run on its own, the report of KiCad is given in a form that is quick to read. On the open-source DDR4 tester by Antmicro, three errors and 67 warnings are printed and counted by type, and each of the three errors then follows with the parts and layers involved:

Terminal output of kicad-fab drc on Antmicro's DDR4 tester: error and warning counts by type, then three errors with the zones and pads involved

The separate checks

CommandWhat it does
kicad-fab drc board.kicad_pcbCounts are given by type and severity, with each error and open connection listed. The exit status is 1 on errors, and an existing DRC JSON can also be read.
kicad-fab bom-check --board board.kicad_pcb --bom bom.csv --qty 10One parts-list line per footprint and every placed part on the board are checked, together with matching footprint names. Stock is checked for the build quantity plus spares.
kicad-fab bom-cost --bom bom.csv --boards 10The placed parts are priced at the given quantity from the price tiers of LCSC. The extended parts are counted as well.
kicad-fab jlc --board board.kicad_pcb --bom bom.csv --fixes rotation-fixes.csvThe BOM and placement files for JLCPCB are written. Rotation and offset fixes are applied to them.

Spares are set by default to 20 % plus 5 extra per line, and both values can be changed with --spare and --attrition.

The parts list is a CSV file with one line per part. Its columns are Designators, MPN, Footprint, LCSC and Assemble, and their names are matched loosely. Any value in Assemble other than yes or blank, such as DNP or hand, means that the part is left off by the factory. A line without an LCSC number is never sent to JLCPCB. A sample file is provided in examples/bom.csv.

Rotation fixes

KiCad and JLCPCB sometimes disagree on the position of the zero rotation or the origin of a footprint. When a part is shown turned or shifted in the placement viewer of the factory, one line should be added for that footprint:

footprint,rotation,dx,dy
SOT-23,180,0,0

Every instance of the footprint is then corrected by that line. Offsets are given in millimetres in the frame of the footprint itself, which means that they remain correct whichever way the part is placed. Each placed footprint that has no line yet is also listed by both jlc and fab, so that the list can be used as a checklist while the viewer is worked through.

Limits

Stock and price are outside the scope of the fab command, and bom-check and bom-cost are provided for that purpose.

Stock and prices are read from the JSON endpoint behind the public parts search of JLCPCB. This endpoint is an undocumented API and could change. A failed lookup is reported as a failure and is never counted as “in stock”.

The BOM and placement files are written in the format of JLCPCB. The drill and place origin should be set at the lower-left corner of the board in KiCad, so that every coordinate is positive, since negative coordinates are queried by assembly houses.

Licence

Apache 2.0.

Read the announcement: kicad-fab-tools: circuit board orders, checked.

Hear when FirePod goes on saleGet the early-bird price

FirePod isn't on sale yet. Leave your email and we'll write when it is.

FirePod isn't on sale yet. Sign up and the early-bird price comes to your inbox when it is.