sistemas-cibernetico-fisicos/hardware/common/scripts/README.md
Fábio Cunha 893778143a docs(sync): add README/AGENTS.md, fix hardware docs, sync central brain
- Add root README.md and AGENTS.md for hardware repo

- Fix cross-repo and internal broken links

- Document hardware/common/scripts

- Populate v2.9 placeholder READMEs

- Update replica-omnisciente central brain pointer
2026-07-05 18:21:00 +01:00

71 lines
2.3 KiB
Markdown

# Hardware Automation Scripts
## WHY
The Savearth hardware repo contains many PCB versions and manufacturing exports. Manual BOM extraction and library conversion is error-prone and not reproducible. These scripts turn the EDA source into structured JSON, JLCPCB CSVs, and KiCad libraries in a repeatable way.
## HOW
All scripts are Python 3 and read from/write to the per-version directories under `hardware/`. They share a common version list (`2_3` through `2_8`) and use the file naming convention `bom_v{version}.json`.
Run each script with `--help` for full argument lists.
## WHAT
### `extract_bom.py`
Extract component data from EasyEDA Pro `.epro` archives.
```bash
python3 hardware/common/scripts/extract_bom.py \
--epro-dir hardware/v2.8/easyeda \
--output-dir hardware/v2.8/bom
```
Outputs:
- `bom_v2_8.json` — structured BOM with LCSC, manufacturer, footprint, value, category
- Updates `hardware/savearth_hw_knowledge.json` with cross-version data
### `generate_jlcpcb_bom.py`
Generate a JLCPCB-compatible CSV from a JSON BOM produced by `extract_bom.py`.
```bash
python3 hardware/common/scripts/generate_jlcpcb_bom.py \
--bom-dir hardware/v2.8/bom \
--version 2_8
```
Output: `hardware/v2.8/bom/bom_v2_8_jlcpcb.csv`
### `convert_to_kicad.py`
Convert LCSC parts to KiCad symbol/footprint/3D libraries via `easyeda2kicad`.
```bash
python3 hardware/common/scripts/convert_to_kicad.py \
--bom-dir hardware/v2.8/bom \
--kicad-lib-dir hardware/common/kicad_libs
```
Requires `easyeda2kicad` to be installed (`pip install easyeda2kicad`).
### `extract_easyeda_db.py`
Parse the SQLite-backed `.eprj` project directly to raw JSON schematics, netlists, and BOMs.
```bash
python3 hardware/common/scripts/extract_easyeda_db.py \
--db-path hardware/v2.8/easyeda/Savearth\ GBT.eprj \
--output-dir hardware/v2.8/parsed_data
```
Useful when you have the binary `.eprj` but no manual `.epro` export.
## Typical workflow
1. Export or locate the EasyEDA Pro source (`.epro` or `.eprj`).
2. Run `extract_bom.py` (or `extract_easyeda_db.py` for `.eprj`) to refresh `bom_v2_8.json`.
3. Run `generate_jlcpcb_bom.py` to refresh the assembly CSV.
4. Run `convert_to_kicad.py` if the KiCad library needs updating.
5. Commit the generated files and update any affected docs.