| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412 |
- #!/usr/bin/env python3
- """Generate board-viewer assets for FCB V2.0 (Mainboard) and FCB_FAN V2.0 (Fan Board).
- Extracts board-viewer data from the supplied Allegro 17.4 BRDs using record-pattern scans.
- Pin/net extraction is distinct from electrical path verification. Geometry is approximate;
- arcs, pad shapes and layer artwork are simplified. This is not a lossless CAD importer:
- - 0x1200 string table, 0x31/0x30 pin text records, 0x00020003 component value records
- - 0x1b net records, 0x04 net connection records, 0x1c padstack records
- - 0x2d placed symbol instances (exact x, y, rotation, side)
- - 0x07 component instances, 0x0d footprint pin definitions, 0x32 placed pin instances
- - 0xfd010014 board outline geometry, 0xf7090014/0xfc090014/0xf6090014 silkscreen outlines
- - 0x00060005/0x05060005 copper clines, 0x15/0x16/0x17/0x01 line/arc segments
- """
- from __future__ import annotations
- from collections import Counter, deque
- from collections.abc import Mapping
- from datetime import datetime, timezone
- import hashlib
- import json
- import math
- from pathlib import Path
- import re
- import struct
- import sys
- from typing import Any
- from jsonschema import Draft202012Validator
- VIEWER_DIR = Path(__file__).resolve().parent
- ROOT = VIEWER_DIR.parents[1]
- if str(VIEWER_DIR) not in sys.path:
- sys.path.insert(0, str(VIEWER_DIR))
- from board_viewer.annotations import expand_annotation_templates
- from board_viewer.data import (
- BOARD_DATA_SCHEMA_ID,
- _apply_connector_profile,
- _attach_related_resistors,
- _build_value_coverage,
- _merge_annotation,
- _merge_programming_annotation,
- _programming_guidance,
- _refresh_recommendation,
- _resistor_dict,
- _touchpoint_dict,
- _unique_strings,
- validate_resistor_index,
- )
- from board_viewer.pcb import (
- Footprint,
- Pad,
- ParsedBoard,
- _footprint_bounds,
- select_resistors,
- select_touchpoints,
- )
- DATA_SCHEMA_PATH = ROOT / "schemas" / "board_viewer_data.schema.json"
- BUILD_INFO_SCHEMA_PATH = ROOT / "schemas" / "board_viewer_build_info.schema.json"
- ANNOTATIONS_V12_PATH = ROOT / "config" / "board_viewer_annotations.fcb_fpga_mcu_v1_2.json"
- POWER_AND_GND_NETS = {
- "GND",
- "AGND",
- "PGND",
- "DGND",
- "+3.3V",
- "+3V3",
- "+5V",
- "+12V",
- "+24V",
- "+24V_VIN",
- "VBUS",
- "VCC",
- "VDD",
- }
- def sha256_file(path: Path | str) -> str:
- h = hashlib.sha256()
- with open(path, "rb") as f:
- while chunk := f.read(1024 * 1024):
- h.update(chunk)
- return h.hexdigest()
- def _generator_sources() -> dict[str, dict[str, str]]:
- paths = {"generator_v20": Path(__file__).resolve()}
- for name in ("annotations", "data", "eligibility", "pcb", "sexpr"):
- paths[f"generator_{name}"] = VIEWER_DIR / "board_viewer" / f"{name}.py"
- return {
- key: {"path": str(path.relative_to(ROOT)), "sha256": sha256_file(path)}
- for key, path in paths.items()
- }
- def _mark_inferred(value: Any) -> None:
- """A reused annotation or graph search does not constitute cross-verification."""
- if isinstance(value, dict):
- if "evidence_tier" in value:
- value["evidence_tier"] = "name_inferred"
- for child in value.values():
- _mark_inferred(child)
- elif isinstance(value, list):
- for child in value:
- _mark_inferred(child)
- def _pad_sort_key(pad: Pad) -> tuple[int, int, str]:
- num = pad.number.strip()
- if not num:
- return (2, 0, "")
- if num.isdigit():
- return (0, int(num), "")
- m = re.match(r"^([A-Za-z]+)(\d+)$", num)
- if m:
- return (1, int(m.group(2)), m.group(1))
- return (1, 0, num)
- # ---------------------------------------------------------------------------
- # Targeted Cadence Allegro 17.4 Binary .brd Extraction
- # ---------------------------------------------------------------------------
- def parse_allegro_brd(brd_path: Path) -> tuple[ParsedBoard, dict[str, Any]]:
- """Parse an Allegro 17.x binary .brd into ParsedBoard + CAD graphics metadata."""
- data = brd_path.read_bytes()
- u32 = struct.unpack(f"<{len(data) // 4}I", data[: len(data) // 4 * 4])
- i32 = struct.unpack(f"<{len(data) // 4}i", data[: len(data) // 4 * 4])
- # 1. String table at 0x1200
- pos = 0x1200
- strings: dict[int, str] = {}
- while pos < len(data) - 8:
- sid = struct.unpack_from("<I", data, pos)[0]
- if sid < 0x7C or sid > 50000:
- break
- end = data.find(b"\x00", pos + 4)
- if end == -1:
- break
- strings[sid] = data[pos + 4 : end].decode("latin1", errors="replace")
- pos = (end + 1 + 3) & ~3
- # 2. Text records (0x31 -> 0x30) for pin numbers
- t31: dict[int, str] = {}
- for idx in range(len(u32) - 8):
- if (u32[idx] & 0xFFFF) == 0x0031 and (u32[idx] >> 24) >= 0xF0:
- oid = u32[idx + 1]
- off = (idx + 7) * 4
- end = data.find(b"\x00", off)
- if end != -1 and end - off < 64:
- t31[oid] = data[off:end].decode("latin1", errors="replace")
- text30: dict[int, str] = {}
- for idx in range(len(u32) - 10):
- if (u32[idx] & 0xFFFF) == 0x0030:
- oid = u32[idx + 1]
- t31_id = u32[idx + 8]
- if t31_id in t31:
- text30[oid] = t31[t31_id]
- # 3. Device value property records (0x00020003)
- dev_val: dict[int, str] = {}
- for idx in range(len(u32) - 10):
- if u32[idx] == 0x00020003:
- dev_id = u32[idx + 3]
- off = (idx + 6) * 4
- end = data.find(b"\x00", off)
- if end != -1 and end - off < 120:
- val = data[off:end].decode("latin1", errors="replace").strip()
- if val:
- dev_val[dev_id] = val
- # 4. Nets (0x1b) and connection pointers (0x04)
- nets: dict[int, str] = {}
- for idx in range(len(u32) - 10):
- if u32[idx] == 0x1B:
- oid = u32[idx + 1]
- nsid = u32[idx + 3]
- if nsid in strings:
- nets[oid] = strings[nsid]
- conn04: dict[int, int] = {}
- for idx in range(len(u32) - 6):
- if (u32[idx] & 0xFF) == 0x04 and (u32[idx] & 0xFFFF00) in (0, 0x0900):
- conn04[u32[idx + 1]] = u32[idx + 2]
- # 5. Padstacks (0x1c) and Footprint Pin Definitions (0x0d)
- padstacks: dict[int, dict[str, Any]] = {}
- for idx in range(len(u32) - 24):
- if u32[idx] == 0x1C:
- psid = u32[idx + 1]
- nsid = u32[idx + 3]
- if nsid in strings:
- ptype = u32[idx + 11]
- drill_raw = i32[idx + 16] / 10000.0
- drill = max(0.0, drill_raw) if ptype != 1 and 0.0 < drill_raw <= 10.0 else 0.0
- padstacks[psid] = {
- "name": strings[nsid],
- "ptype": ptype,
- "drill": round(drill, 4),
- }
- pindefs: dict[int, int] = {}
- for idx in range(len(u32) - 8):
- if u32[idx] == 0x0D:
- pindefs[u32[idx + 1]] = u32[idx + 2]
- # 6. Placed Symbol Instances (0x2d / 0x1002d) and Component Instances (0x07)
- syms: dict[int, dict[str, Any]] = {}
- for idx in range(len(u32) - 10):
- if u32[idx] in (0x2D, 0x1002D) and u32[idx + 4] == 0 and u32[idx + 5] == 0:
- oid = u32[idx + 1]
- syms[oid] = {
- "fpid": u32[idx + 3],
- "side": "back" if (u32[idx] & 0x10000) else "front",
- "rot": round((u32[idx + 7] / 1000.0) % 360.0, 4),
- "x": round(i32[idx + 8] / 10000.0, 4),
- "y": round(i32[idx + 9] / 10000.0, 4),
- }
- sym_to_comp: dict[int, dict[str, str]] = {}
- for idx in range(len(u32) - 10):
- if u32[idx] == 0x07 and u32[idx + 4] == 0 and u32[idx + 5] == 0:
- dev_id = u32[idx + 3]
- sym_id = u32[idx + 6]
- ref_sid = u32[idx + 7]
- pkg_id = u32[idx + 8]
- if ref_sid in strings and sym_id in syms:
- pkg_name = strings.get(pkg_id, "")
- cval = dev_val.get(dev_id, "") or pkg_name
- sym_to_comp[sym_id] = {
- "ref": strings[ref_sid],
- "cval": cval,
- "pkg": pkg_name,
- }
- # 7. Placed Pin Instances (0x32)
- sym_pads: dict[int, list[Pad]] = {}
- comp_pins: dict[str, dict[str, str]] = {}
- net_to_pins: dict[str, list[tuple[str, str]]] = {}
- unassigned_holes: list[tuple[float, float, float]] = []
- for idx in range(len(u32) - 21):
- w0 = u32[idx]
- if (w0 & 0xFF00FF) in (0x0C0032, 0x0C0232):
- sym_id = u32[idx + 7]
- if sym_id not in syms:
- continue
- c04 = u32[idx + 3]
- pdid = u32[idx + 9]
- tid = u32[idx + 15]
- pnum = text30.get(tid, "").strip()
- net = nets.get(conn04.get(c04, 0), "")
- ps = padstacks.get(pindefs.get(pdid, 0), {"name": "", "ptype": 1, "drill": 0.0})
- bx1 = i32[idx + 17] / 10000.0
- by1 = i32[idx + 18] / 10000.0
- bx2 = i32[idx + 19] / 10000.0
- by2 = i32[idx + 20] / 10000.0
- if not (-50.0 <= bx1 <= 600.0 and -50.0 <= by1 <= 600.0):
- continue
- wx = round((bx1 + bx2) / 2.0, 4)
- wy = round((by1 + by2) / 2.0, 4)
- bw = round(max(abs(bx2 - bx1), ps["drill"], 0.24), 4)
- bh = round(max(abs(by2 - by1), ps["drill"], 0.24), 4)
- ptype = ps["ptype"]
- side = syms[sym_id]["side"]
- if sym_id not in sym_to_comp:
- if ptype == 0 or "MTG" in ps["name"].upper():
- unassigned_holes.append((wx, wy, max(ps["drill"], bw)))
- continue
- ref = sym_to_comp[sym_id]["ref"]
- comp_pins.setdefault(ref, {})[pnum] = net
- if net:
- net_to_pins.setdefault(net, []).append((ref, pnum))
- if ptype == 0 or not pnum:
- pad_type = "np_thru_hole"
- layers = ("*.Cu", "*.Mask")
- mech = True
- elif ptype == 1:
- pad_type = "smd"
- layers = ("F.Cu", "F.Mask", "F.Paste") if side == "front" else ("B.Cu", "B.Mask", "B.Paste")
- mech = False
- else:
- pad_type = "thru_hole"
- layers = ("*.Cu", "*.Mask")
- mech = False
- ps_upper = ps["name"].upper()
- if "CIR" in ps_upper or ptype == 0 or (abs(bw - bh) < 0.02 and "REC" not in ps_upper):
- shape = "circle"
- elif "SLOT" in ps_upper or "OB" in ps_upper:
- shape = "oval"
- else:
- shape = "rect"
- pad = Pad(
- number=pnum,
- pad_type=pad_type,
- shape=shape,
- x=wx,
- y=round(-wy, 4),
- width=bw,
- height=bh,
- rotation=0.0,
- net=net if net else None,
- layers=layers,
- drill_width=round(ps["drill"], 4),
- drill_height=round(ps["drill"], 4),
- mechanical=mech,
- electrical=not mech,
- )
- sym_pads.setdefault(sym_id, []).append(pad)
- footprints: list[Footprint] = []
- for sym_id, cinfo in sym_to_comp.items():
- s = syms[sym_id]
- pads = sorted(sym_pads.get(sym_id, []), key=_pad_sort_key)
- fx, fy = s["x"], round(-s["y"], 4)
- fp = Footprint(
- reference=cinfo["ref"],
- component_value=cinfo["cval"],
- x=fx,
- y=fy,
- rotation=s["rot"],
- side=s["side"],
- layer="B.Cu" if s["side"] == "back" else "F.Cu",
- pads=pads,
- bounds=_footprint_bounds(pads, fx, fy),
- )
- footprints.append(fp)
- # 8. Board Outline, Silkscreen Outlines, and Copper Clines
- outline_oids: set[int] = set()
- silk_front_oids: set[int] = set()
- silk_back_oids: set[int] = set()
- cline_front_oids: set[int] = set()
- cline_back_oids: set[int] = set()
- for idx in range(len(u32) - 8):
- w0 = u32[idx]
- oid = u32[idx + 1]
- if w0 == 0xFD010014:
- outline_oids.add(oid)
- elif w0 in (0xF7090014, 0xFC090014) and u32[idx + 3] in syms:
- silk_front_oids.add(oid)
- elif w0 == 0xF6090014 and u32[idx + 3] in syms:
- silk_back_oids.add(oid)
- elif w0 == 0x00060005:
- cline_front_oids.add(oid)
- elif w0 == 0x05060005:
- cline_back_oids.add(oid)
- ox: list[float] = []
- oy: list[float] = []
- silk_front_segs: list[tuple[float, float, float, float, float]] = []
- silk_back_segs: list[tuple[float, float, float, float, float]] = []
- cline_front_segs: list[tuple[float, float, float, float, float]] = []
- cline_back_segs: list[tuple[float, float, float, float, float]] = []
- for idx in range(len(u32) - 12):
- w0 = u32[idx]
- if w0 in (0x15, 0x16, 0x17, 0x01, 0x40000001, 0x80000001):
- parent = u32[idx + 3]
- if (
- parent not in outline_oids
- and parent not in silk_front_oids
- and parent not in silk_back_oids
- and parent not in cline_front_oids
- and parent not in cline_back_oids
- ):
- continue
- width = max(0.12, min(1.2, u32[idx + 6] / 10000.0))
- x1 = i32[idx + 7] / 10000.0
- y1 = i32[idx + 8] / 10000.0
- x2 = i32[idx + 9] / 10000.0
- y2 = i32[idx + 10] / 10000.0
- if not (-10.0 <= x1 <= 500.0 and -10.0 <= y1 <= 200.0 and -10.0 <= x2 <= 500.0 and -10.0 <= y2 <= 200.0):
- continue
- if abs(x1 - x2) < 1e-4 and abs(y1 - y2) < 1e-4:
- continue
- if parent in outline_oids:
- ox.extend([x1, x2])
- oy.extend([y1, y2])
- elif parent in silk_front_oids:
- silk_front_segs.append((x1, y1, x2, y2, width))
- elif parent in silk_back_oids:
- silk_back_segs.append((x1, y1, x2, y2, width))
- elif parent in cline_front_oids:
- cline_front_segs.append((x1, y1, x2, y2, width))
- elif parent in cline_back_oids:
- cline_back_segs.append((x1, y1, x2, y2, width))
- board_w = round(max(ox) - min(ox), 4) if ox else 430.0
- board_h = round(max(oy) - min(oy), 4) if oy else 60.0
- bounds = {"x": 0.0, "y": round(-board_h, 4), "width": board_w, "height": board_h}
- parsed_board = ParsedBoard(
- footprints=footprints,
- footprint_count=len(footprints),
- bounds=bounds,
- )
- cad_meta = {
- "comp_pins": comp_pins,
- "net_to_pins": net_to_pins,
- "silk_front_segs": silk_front_segs,
- "silk_back_segs": silk_back_segs,
- "cline_front_segs": cline_front_segs,
- "cline_back_segs": cline_back_segs,
- "unassigned_holes": unassigned_holes,
- }
- return parsed_board, cad_meta
- def trace_net_to_u3_u27(
- start_ref: str,
- start_pin: str,
- comp_pins: Mapping[str, Mapping[str, str]],
- net_to_pins: Mapping[str, list[tuple[str, str]]],
- ) -> tuple[str, tuple[str, str, str, list[str], list[str]] | None]:
- """Return a structural path candidate to U3/U27, not verified conduction.
- This search crosses component pins without checking fitted/NC options or
- transistor gate/source/drain behavior. Its result must remain name_inferred;
- it cannot prove a usable GPIO, polarity, voltage or populated signal path.
- """
- start_net = comp_pins.get(start_ref, {}).get(start_pin, "")
- if not start_net or start_net in POWER_AND_GND_NETS:
- return start_net, None
- queue: deque[tuple[str, list[str], list[str]]] = deque(
- [(start_net, [f"{start_ref}.{start_pin} ({start_net})"], [])]
- )
- visited_nets = {start_net}
- visited_comps = {start_ref}
- while queue:
- net, path, ext_comps = queue.popleft()
- for r, p in net_to_pins.get(net, []):
- if r == "U3":
- return start_net, ("U3", p, net, [*path, f"U3.{p} ({net})"], ext_comps)
- if r == "U27":
- return start_net, ("U27", p, net, [*path, f"U27.{p} ({net})"], ext_comps)
- if len(path) >= 6:
- continue
- for r, p in net_to_pins.get(net, []):
- if r in visited_comps or r.startswith(("C", "CON", "J", "TP", "PL", "U")):
- continue
- pins_of_r = comp_pins.get(r, {})
- if len(pins_of_r) <= 6:
- visited_comps.add(r)
- for p2, n2 in pins_of_r.items():
- if p2 != p and n2 and n2 not in POWER_AND_GND_NETS and n2 not in visited_nets:
- visited_nets.add(n2)
- new_ext = [*ext_comps, f"{r}.{p}->{p2}" if r.startswith("R") else r]
- queue.append((n2, [*path, f"{r}.{p}->{p2} ({n2})"], new_ext))
- return start_net, None
- # ---------------------------------------------------------------------------
- # Derived SVG Layer Renderer (simplified geometry)
- # ---------------------------------------------------------------------------
- def generate_svg_layers_from_brd(
- parsed_board: ParsedBoard,
- cad_meta: Mapping[str, Any],
- title: str,
- touchpoints: list[dict[str, Any]],
- out_dir: Path,
- ) -> None:
- """Render simplified SVG layers from parsed Allegro geometry; not a lossless CAD export."""
- out_dir.mkdir(parents=True, exist_ok=True)
- board_w = float(parsed_board.bounds["width"])
- board_h = float(parsed_board.bounds["height"])
- # Collect mounting holes (NPTH pads + unassigned MTG holes)
- mounting_holes: list[tuple[float, float, float]] = []
- for hx, hy, hd in cad_meta.get("unassigned_holes", []):
- mounting_holes.append((hx, board_h - hy, hd / 2.0))
- for fp in parsed_board.footprints:
- for pad in fp.pads:
- if pad.pad_type == "np_thru_hole" and pad.drill_width >= 1.0:
- mounting_holes.append((pad.x, board_h + pad.y, pad.drill_width / 2.0))
- # --- 1. MASK & EDGE ---
- def build_mask(side: str) -> str:
- bg_col = "#eef7f2"
- inner_stroke = "#cde7d8"
- border_stroke = "#64748b"
- lines = [
- '<?xml version="1.0" encoding="UTF-8"?>',
- f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {board_w:g} {board_h:g}" width="{board_w:g}mm" height="{board_h:g}mm">',
- f' <title>{title} - {"Front" if side == "front" else "Back"} Mask & Edge</title>',
- f' <rect x="0" y="0" width="{board_w:g}" height="{board_h:g}" rx="2.0" fill="{bg_col}" stroke="{border_stroke}" stroke-width="0.35"/>',
- f' <rect x="0.8" y="0.8" width="{board_w - 1.6:g}" height="{board_h - 1.6:g}" rx="1.6" fill="none" stroke="{inner_stroke}" stroke-width="0.18"/>',
- " <!-- Soldermask Openings -->",
- ' <g fill="#fbbf24" stroke="#b45309" stroke-width="0.05">',
- ]
- for fp in parsed_board.footprints:
- for pad in fp.pads:
- if pad.pad_type == "np_thru_hole":
- continue
- is_th = "*.Mask" in pad.layers or pad.drill_width > 0
- if (side == "front" and ("F.Mask" in pad.layers or is_th)) or (
- side == "back" and ("B.Mask" in pad.layers or is_th)
- ):
- vx = pad.x
- vy = board_h + pad.y
- if side == "back":
- vx = board_w - vx
- pw = pad.width + 0.06
- ph = pad.height + 0.06
- if pad.shape == "circle":
- r = max(pw, ph) / 2.0
- lines.append(f' <circle cx="{vx:.3f}" cy="{vy:.3f}" r="{r:.3f}"/>')
- else:
- rx_attr = f' rx="{min(pw, ph)/2:.3f}"' if pad.shape == "oval" else ""
- lines.append(
- f' <rect x="{vx - pw/2:.3f}" y="{vy - ph/2:.3f}" width="{pw:.3f}" height="{ph:.3f}"{rx_attr}/>'
- )
- if pad.drill_width > 0:
- lines.append(
- f' <circle cx="{vx:.3f}" cy="{vy:.3f}" r="{pad.drill_width/2:.3f}" fill="#1e293b" stroke="none"/>'
- )
- for hx, hy, hr in mounting_holes:
- vx = board_w - hx if side == "back" else hx
- lines.append(
- f' <circle cx="{vx:.3f}" cy="{hy:.3f}" r="{hr + 0.45:.3f}" fill="#cbd5e1" stroke="#64748b" stroke-width="0.08"/>'
- )
- lines.append(f' <circle cx="{vx:.3f}" cy="{hy:.3f}" r="{hr:.3f}" fill="#1e293b" stroke="none"/>')
- lines.append(" </g>")
- lines.append("</svg>")
- return "\n".join(lines) + "\n"
- # --- 2. COPPER ---
- def build_copper(side: str) -> str:
- segs = cad_meta["cline_front_segs"] if side == "front" else cad_meta["cline_back_segs"]
- lines = [
- '<?xml version="1.0" encoding="UTF-8"?>',
- f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {board_w:g} {board_h:g}" width="{board_w:g}mm" height="{board_h:g}mm">',
- f' <title>{title} - {"Front" if side == "front" else "Back"} Copper</title>',
- ' <g id="copper-tracks" stroke="#529b7a" stroke-opacity="0.26" stroke-linecap="round" fill="none">',
- ]
- # Group segments by rounded width for compact SVG path output
- by_width: dict[float, list[str]] = {}
- for x1, y1, x2, y2, w in segs:
- vx1 = board_w - x1 if side == "back" else x1
- vy1 = board_h - y1
- vx2 = board_w - x2 if side == "back" else x2
- vy2 = board_h - y2
- rw = round(max(0.15, min(0.8, w)), 2)
- by_width.setdefault(rw, []).append(f"M{vx1:.2f} {vy1:.2f}L{vx2:.2f} {vy2:.2f}")
- for rw, d_parts in sorted(by_width.items()):
- for i in range(0, len(d_parts), 200):
- chunk = "".join(d_parts[i : i + 200])
- lines.append(f' <path stroke-width="{rw:.2f}" d="{chunk}"/>')
- lines.append(" </g>")
- lines.append(' <g id="pads" fill="#fbbf24" stroke="#b45309" stroke-width="0.05">')
- for fp in parsed_board.footprints:
- for pad in fp.pads:
- if pad.pad_type == "np_thru_hole":
- continue
- is_th = "*.Cu" in pad.layers or pad.drill_width > 0
- if (side == "front" and ("F.Cu" in pad.layers or is_th)) or (
- side == "back" and ("B.Cu" in pad.layers or is_th)
- ):
- vx = pad.x
- vy = board_h + pad.y
- if side == "back":
- vx = board_w - vx
- pw = pad.width
- ph = pad.height
- if pad.shape == "circle":
- r = max(pw, ph) / 2.0
- lines.append(f' <circle cx="{vx:.3f}" cy="{vy:.3f}" r="{r:.3f}"/>')
- else:
- rx_attr = f' rx="{min(pw, ph)/2:.3f}"' if pad.shape == "oval" else ""
- lines.append(
- f' <rect x="{vx - pw/2:.3f}" y="{vy - ph/2:.3f}" width="{pw:.3f}" height="{ph:.3f}"{rx_attr}/>'
- )
- if pad.drill_width > 0:
- lines.append(
- f' <circle cx="{vx:.3f}" cy="{vy:.3f}" r="{pad.drill_width/2:.3f}" fill="#1e293b" stroke="none"/>'
- )
- lines.append(" </g>")
- lines.append("</svg>")
- return "\n".join(lines) + "\n"
- # --- 3. SILKSCREEN ---
- def build_silkscreen(side: str) -> str:
- segs = cad_meta["silk_front_segs"] if side == "front" else cad_meta["silk_back_segs"]
- lines = [
- '<?xml version="1.0" encoding="UTF-8"?>',
- f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {board_w:g} {board_h:g}" width="{board_w:g}mm" height="{board_h:g}mm">',
- f' <title>{title} - {"Front" if side == "front" else "Back"} Silkscreen</title>',
- ' <g id="silkscreen-outlines" stroke="#0f172a" stroke-width="0.14" stroke-linecap="round" fill="none">',
- ]
- d_parts: list[str] = []
- for x1, y1, x2, y2, _w in segs:
- vx1 = board_w - x1 if side == "back" else x1
- vy1 = board_h - y1
- vx2 = board_w - x2 if side == "back" else x2
- vy2 = board_h - y2
- d_parts.append(f"M{vx1:.2f} {vy1:.2f}L{vx2:.2f} {vy2:.2f}")
- for i in range(0, len(d_parts), 200):
- chunk = "".join(d_parts[i : i + 200])
- lines.append(f' <path d="{chunk}"/>')
- lines.append(" </g>")
- lines.append(' <g id="silkscreen-labels" fill="#0f172a" font-family="monospace, sans-serif" font-weight="bold">')
- for tp in touchpoints:
- if tp.get("side", "front") != side:
- continue
- ref = str(tp["reference"])
- if ref.startswith("J") and len(tp.get("pins", [])) == 1 and tp["pins"][0].get("mechanical"):
- continue
- vb = tp["view_bounds"]
- bx = board_w - (vb["x"] + vb["width"]) if side == "back" else vb["x"]
- by = vb["y"]
- bw = vb["width"]
- bh = vb["height"]
- tx = bx + bw / 2.0
- ty = by - 0.35 if by > 2.2 else by + bh + 0.95
- lines.append(f' <text x="{tx:.2f}" y="{ty:.2f}" font-size="0.82" text-anchor="middle">{ref}</text>')
- for fp in parsed_board.footprints:
- if fp.side != side:
- continue
- if re.match(r"^(U|F)\d+$", fp.reference):
- vx = board_w - fp.x if side == "back" else fp.x
- vy = board_h + fp.y
- fsize = "1.15" if fp.reference in ("U3", "U27") else "0.72"
- lines.append(
- f' <text x="{vx:.2f}" y="{vy + 0.3:.2f}" font-size="{fsize}" text-anchor="middle">{fp.reference}</text>'
- )
- lines.append(" </g>")
- lines.append("</svg>")
- return "\n".join(lines) + "\n"
- (out_dir / "board-mask-edge.svg").write_text(build_mask("front"), encoding="utf-8")
- (out_dir / "board-mask-edge-back.svg").write_text(build_mask("back"), encoding="utf-8")
- (out_dir / "board-silkscreen.svg").write_text(build_silkscreen("front"), encoding="utf-8")
- (out_dir / "board-silkscreen-back.svg").write_text(build_silkscreen("back"), encoding="utf-8")
- (out_dir / "board-copper.svg").write_text(build_copper("front"), encoding="utf-8")
- (out_dir / "board-copper-back.svg").write_text(build_copper("back"), encoding="utf-8")
- # ---------------------------------------------------------------------------
- # Build V2.0 Mainboard Annotations & Connector Profiles
- # ---------------------------------------------------------------------------
- def _build_v20_annotations(
- parsed_board: ParsedBoard,
- cad_meta: Mapping[str, Any],
- pin_inv: Mapping[str, Any],
- ) -> dict[str, Any]:
- """Build complete V2.0 annotations combining V1.2 shared touchpoints + V2.0 pin inventory + BRD net trace."""
- v12_raw = json.loads(ANNOTATIONS_V12_PATH.read_text(encoding="utf-8"))
- v12_expanded = expand_annotation_templates(v12_raw)
- v12_tps = v12_expanded.get("touchpoints", {})
- comp_pins = cad_meta["comp_pins"]
- net_to_pins = cad_meta["net_to_pins"]
- connector_profiles = {
- "CON_11251W00_NPX_SX_4P": {
- "references": [
- "CON12",
- "CON54",
- "CON70",
- "CON77",
- "CON103",
- "CON126",
- "CON134",
- "CON144",
- "CON145",
- "CON146",
- "CON164",
- "CON171",
- ],
- "contact_pins": ["1", "2", "3", "4"],
- "shield_pads": ["5", "6"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "CON_51541_00301_V01_3P": {
- "references": ["CON53", "CON55", "CON56", "CON57", "CON79", "CON80", "CON81", "CON82"],
- "contact_pins": ["1", "2", "3"],
- "shield_pads": ["4", "5"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "CON_3110_20P_P2D54": {
- "references": ["CON147", "CON148", "CON149", "CON150"],
- "contact_pins": [str(i) for i in range(1, 21)],
- "shield_pads": [],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- },
- "CON_SMD_2D54_2X7P": {
- "references": [
- "CON154",
- "CON155",
- "CON156",
- "CON157",
- "CON158",
- "CON159",
- "CON160",
- "CON161",
- "CON162",
- "CON163",
- "CON165",
- "CON166",
- ],
- "contact_pins": [str(i) for i in range(1, 15)],
- "shield_pads": ["15", "16"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- },
- "HDR_1X4P_P2D54": {
- "references": ["CON168"],
- "contact_pins": ["1", "2", "3", "4"],
- "shield_pads": [],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "RJ45_RJHSE538X_12P": {
- "references": ["CON170"],
- "contact_pins": [str(i) for i in range(1, 13)],
- "shield_pads": ["13", "14"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "USBC_16P_U263": {
- "references": ["CON172"],
- "contact_pins": [
- "A1",
- "A4",
- "A5",
- "A6",
- "A7",
- "A9",
- "A12",
- "B1",
- "B4",
- "B5",
- "B6",
- "B7",
- "B9",
- "B12",
- ],
- "shield_pads": ["1", "2", "3", "4"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "CON_3110_12P_P4D2": {
- "references": ["CON173", "CON174"],
- "contact_pins": [str(i) for i in range(1, 13)],
- "shield_pads": [],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- },
- "J3_FPGA_JTAG_2X5": v12_expanded["connector_profiles"]["J3_FPGA_JTAG_2X5"],
- "J19_FPGA_BANK1_DEBUG_1X5": v12_expanded["connector_profiles"]["J19_FPGA_BANK1_DEBUG_1X5"],
- "J25_GD32_SWD_1X5": v12_expanded["connector_profiles"]["J25_GD32_SWD_1X5"],
- "J_GD32_HEADER_2X5": {
- "references": ["J29", "J30"],
- "contact_pins": [str(i) for i in range(1, 11)],
- "shield_pads": [],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- }
- # Copy shared touchpoints from V1.2 annotations and adapt to V2.0
- touchpoint_anns: dict[str, Any] = {}
- v2_tp_refs = {fp.reference for fp in select_touchpoints(parsed_board)}
- for ref in v2_tp_refs:
- if ref in v12_tps:
- touchpoint_anns[ref] = json.loads(json.dumps(v12_tps[ref]))
- _mark_inferred(touchpoint_anns[ref])
- touchpoint_anns[ref]["summary"] = (
- "V1.2 参考注释,V2.0 未逐项复核:" + touchpoint_anns[ref].get("summary", ref)
- )
- # Fix V2.0-specific differences on shared touchpoints:
- # 1. CON12 is 6400 V2.0 Host TTL (R1875/R1876 instead of V1.2 R1307/R1308)
- touchpoint_anns["CON12"] = {
- "summary": "6400 V2.0 Host TTL 串口座(Pin 3 TX → R1875 → U3.K2 host_ttl_tx,Pin 4 RX ← R1876 ← U3.J4 host_ttl_rx,对接 STM32H7 P1.26/P1.25)",
- "pins": {
- "1": {
- "summary": "CON12.1 +3.3V 板内电源参考(跨板连接不并接)",
- "direction": "passive",
- "external_level": "+3.3V",
- "function_category": "power",
- "reserved": True,
- "path": ["CON12.1 +3.3V"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- },
- "2": {
- "summary": "CON12.2 GND 串口信号共地(接 STM32H7 P1.19 GND)",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": ["CON12.2 GND"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- },
- "3": {
- "summary": "CON12.3 (EX_GPIO1) Host TTL TX → R1875 → FPGA U3.K2 (host_ttl_tx) ↔ STM32H7 P1.26 (PB11)",
- "direction": "output",
- "external_level": "3.3V LVCMOS",
- "function_category": "uart_tx",
- "external_components": ["R1875", "STM32H7 P1.26 (PB11)"],
- "path": ["CON12.3 (EX_GPIO1)", "R1875.2->1 (CPLD_GPIO79)", "U3.K2 (host_ttl_tx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- "fpga": {
- "ball": "K2",
- "board_signal": "EX_GPIO1",
- "io_standard": "LVCMOS33",
- "capabilities": ["uart_tx", "gpio_output", "gpio"],
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- },
- "4": {
- "summary": "CON12.4 (EX_GPIO2) Host TTL RX ← R1876 ← FPGA U3.J4 (host_ttl_rx) ↔ STM32H7 P1.25 (PB10)",
- "direction": "input",
- "external_level": "3.3V LVCMOS",
- "function_category": "uart_rx",
- "external_components": ["R1876", "STM32H7 P1.25 (PB10)"],
- "path": ["CON12.4 (EX_GPIO2)", "R1876.2->1 (CPLD_GPIO80)", "U3.J4 (host_ttl_rx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- "fpga": {
- "ball": "J4",
- "board_signal": "EX_GPIO2",
- "io_standard": "LVCMOS33",
- "capabilities": ["uart_rx", "gpio_input", "gpio"],
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- },
- },
- }
- # 2. CON54 in V2.0 has R572/R574 removed (uses R573/R747 and R575/R748)
- if "CON54" in touchpoint_anns:
- for pnum, r_list in (("1", ["R573", "R747"]), ("2", ["R575", "R748"])):
- p_ann = touchpoint_anns["CON54"].get("pins", {}).get(pnum, {})
- p_ann["external_components"] = r_list
- p_ann["path"] = [
- f"CON54.{pnum}",
- f"{r_list[0]}",
- f"{r_list[1]}",
- f"U3.{'A9' if pnum == '1' else 'C9'}",
- ]
- # These V2.0 LED outputs use HL2309 and fitted +24V selection resistors.
- # Replace the inherited V1.2 pin annotation (12V/AO3415A) as one object.
- for ref, number, ball, series, gate, nmos, pmos, supply, option in (
- ("CON144", 1, "G6", "R1299", "R1274", "Q10617", "Q10616", "R1281", "R1282"),
- ("CON145", 2, "F5", "R1300", "R1290", "Q10619", "Q10618", "R1287", "R1288"),
- ):
- touchpoint_anns[ref]["summary"] = (
- f"V2.0 LED/按键连接器{number}:Pin1为24V KEYLED功率输出,由U3.{ball}控制;"
- "Pin3为按键输入,Pin2/4为GND;Host TTL使用CON12。"
- )
- touchpoint_anns[ref]["pins"]["1"] = {
- "summary": f"U3.{ball}经{series}/{gate}、{nmos} 2N7002和{pmos} HL2309控制KEYLED_V{number};{supply}已装接+24V,{option}的+5V选项未装。不是TTL。",
- "direction": "output", "external_level": "+24V switched power",
- "function_category": "power", "reserved": True,
- "fixed_load_conflict": True, "evidence_tier": "cross_verified",
- "fpga": None,
- "path": [f"U3.{ball}", series, gate, nmos, pmos, f"{ref}.1 (KEYLED_V{number})"],
- "external_components": [series, gate, nmos, pmos, supply, option],
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "evidence/hardware/20261023/main_bom.csv", "evidence/hardware/20261023/main_pins.csv"],
- }
- # V2.0 R1294 is fitted to +24V; V1.2 uses +12V at the same reference.
- # V3.0 schematic & v3.2.0 RTL bind CON146.1/2 to the MCU-triggered +24V buzzer
- # (4000 Hz, 80% duty square wave on U3.H6; NOT a TTL UART).
- touchpoint_anns["CON146"] = {
- "summary": "蜂鸣器 +24V 高边驱动座(电气图 V3.0:Pin1 KEYLED_V3 +24V 蜂鸣器正端 ← U3.H6 经 R1301/R1297/Q10621/Q10620 驱动,开启时 4000Hz 80% 占空比方波;Pin2 GND 蜂鸣器负端;SET_ALL 字节35 / GET_DATA 字节89;非 TTL)",
- "pins": {
- "1": {
- "summary": "CON146.1 (KEYLED_V3, +24V 高边蜂鸣器输出) ← Q10620(HL2309, R1294装+24V/R1295 NC) ← Q10621(2N7002) ← R1297(220Ω) ← SW_KEYLED3 ← R1301(0Ω) ← FPGA U3.H6 (buzzer_out:开启 4000Hz 80% 占空比方波 6250拍周期/5000高/1250低;关闭/复位/看门狗保持低电平;非 TTL)",
- "direction": "output", "external_level": "+24V high-side buzzer (4000Hz 80% duty)",
- "function_category": "pwm", "active_level": "high", "polarity": "normal",
- "reserved": True, "fixed_load_conflict": True, "evidence_tier": "cross_verified",
- "path": ["U3.H6 (buzzer_out)", "R1301 (0R)", "SW_KEYLED3", "R1297 (220R)", "Q10621 (2N7002)", "Q10620 (HL2309 +24V)", "CON146.1 (KEYLED_V3)"],
- "external_components": ["R1301", "R1297", "Q10621", "Q10620", "R1294", "R1295"],
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V3.0.pdf", "constraints/prod2u_6400_v2.adc"],
- "fpga": {
- "ball": "H6",
- "board_signal": "SW_KEYLED3",
- "io_standard": "LVCMOS33",
- "capabilities": ["pwm", "gpio_output"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V3.0.pdf", "constraints/prod2u_6400_v2.adc"],
- },
- },
- "3": {
- "summary": "CON146.3 KEY3_CON 经 R1293/R1110 接 U3.N7;按键输入网络带 RC,当前固件未绑定,不作为 Host TTL。",
- "direction": "input", "external_level": "3.3V key input with RC",
- "function_category": "gpio_input", "reserved": True,
- "evidence_tier": "cross_verified",
- "path": ["CON146.3 (KEY3_CON)", "R1293", "R1110", "U3.N7"],
- "external_components": ["R1293", "R1110"],
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "2": {
- "summary": "CON146.2 GND(蜂鸣器负极回路地)",
- "direction": "passive", "external_level": "0V", "function_category": "ground",
- "path": ["CON146.2 (GND)"], "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V3.0.pdf"],
- },
- "4": {
- "summary": "CON146.4 GND",
- "direction": "passive", "external_level": "0V", "function_category": "ground",
- "path": ["CON146.4 (GND)"], "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- },
- }
- # 3b. CON134 is 6400 V2.0 active Host RS-232 (Pin 1 TX -> U22 -> R1225 -> U3.T14, Pin 2 RX <- U22 <- R1226 <- U3.R13)
- touchpoint_anns["CON134"] = {
- "summary": "6400 V2.0 Host RS-232 串口座(Pin 1 RS232_TX3 → U22 → R1225 → U3.T14 host_rs232_tx,Pin 2 RS232_RX3 ← U22 ← R1226 ← U3.R13 host_rs232_rx,Pin 3/4 GND)",
- "pins": {
- "1": {
- "summary": "CON134.1 (RS232_TX3) → TRSF3232EIPWR U22.7/10 → R1225 → FPGA U3.T14 (host_rs232_tx)",
- "direction": "output",
- "external_level": "RS232",
- "function_category": "uart_tx",
- "external_components": ["U22", "R1225"],
- "path": ["CON134.1 (RS232_TX3)", "U22.7->10 (UART3_TX)", "R1225.2->1 (BANK2_LVDS8_N)", "U3.T14 (host_rs232_tx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- "fpga": {
- "ball": "T14",
- "board_signal": "RS232_TX3",
- "io_standard": "LVCMOS33",
- "capabilities": ["uart_tx", "rs232_via_transceiver"],
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- },
- "2": {
- "summary": "CON134.2 (RS232_RX3) ← TRSF3232EIPWR U22.8/9 ← R1226 ← FPGA U3.R13 (host_rs232_rx)",
- "direction": "input",
- "external_level": "RS232",
- "function_category": "uart_rx",
- "external_components": ["U22", "R1226"],
- "path": ["CON134.2 (RS232_RX3)", "U22.8->9 (UART3_RX)", "R1226.2->1 (BANK2_LVDS8_P)", "U3.R13 (host_rs232_rx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- "fpga": {
- "ball": "R13",
- "board_signal": "RS232_RX3",
- "io_standard": "LVCMOS33",
- "capabilities": ["uart_rx", "rs232_via_transceiver"],
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- },
- "3": {
- "summary": "CON134.3 GND 串口地",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": ["CON134.3 (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "4": {
- "summary": "CON134.4 GND 串口地",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": ["CON134.4 (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- },
- }
- # 3c. CON77 is BMC RS-232 (Pin 1 TX -> U22 -> R818 -> U3.L10, Pin 2 RX <- U22 <- R819 <- U3.M9)
- touchpoint_anns["CON77"] = {
- "summary": "BMC 测温轮询 RS-232 串口座(Pin 1 RS232_TX1 → U22 → R818 → U3.L10 bmc_tx,Pin 2 RS232_RX1 ← U22 ← R819 ← U3.M9 bmc_rx,Pin 3/4 GND)",
- "pins": {
- "1": {
- "summary": "CON77.1 (RS232_TX1) → TRSF3232EIPWR U22.14/11 → R818 → FPGA U3.L10 (bmc_tx, 115200 8N1)",
- "direction": "output",
- "external_level": "RS232",
- "function_category": "uart_tx",
- "external_components": ["U22", "R818"],
- "path": ["CON77.1 (RS232_TX1)", "U22.14->11 (UART1_TX)", "R818.2->1 (BANK2_GPIO52)", "U3.L10 (bmc_tx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- "fpga": {
- "ball": "L10",
- "board_signal": "RS232_TX1",
- "io_standard": "LVCMOS33",
- "capabilities": ["uart_tx", "rs232_via_transceiver"],
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- },
- "2": {
- "summary": "CON77.2 (RS232_RX1) ← TRSF3232EIPWR U22.13/12 ← R819 ← FPGA U3.M9 (bmc_rx, 115200 8N1)",
- "direction": "input",
- "external_level": "RS232",
- "function_category": "uart_rx",
- "external_components": ["U22", "R819"],
- "path": ["CON77.2 (RS232_RX1)", "U22.13->12 (UART1_RX)", "R819.2->1 (BANK2_GPIO53)", "U3.M9 (bmc_rx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- "fpga": {
- "ball": "M9",
- "board_signal": "RS232_RX1",
- "io_standard": "LVCMOS33",
- "capabilities": ["uart_rx", "rs232_via_transceiver"],
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- },
- "3": {
- "summary": "CON77.3 GND 串口地",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": ["CON77.3 (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "4": {
- "summary": "CON77.4 GND 串口地",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": ["CON77.4 (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- },
- }
- # 3d. CON103 on V2.0: schematic Page 4/9 labels "-CON103 MCU串口连接器" wired to -U6-2 TX1/RX1,
- # while PCB routes CON103.1/2 to onboard STM32 U27.12/13 (PA2/PA3) & CP2102 U33 (not FPGA U3; CON12 routes to FPGA U3.K2/J4).
- touchpoint_anns["CON103"] = {
- "summary": "板载 STM32 MCU 串口连接器(电气图第4/9页标为 -CON103 MCU串口连接器 对接 -U6-2 TX1/RX1;PCB 网表 Pin 1/2 接板载 STM32 U27.12/13 PA2/PA3 与 CP2102 U33,直通 FPGA U3.K2/J4 的 TTL 口为紧邻的 CON12)",
- "pins": {
- "1": {
- "summary": "CON103.1 (MCU_UART1_TX_CON) → R1029 → 板载 STM32 U27.12 (PA2/MCU_UART1_TX) & R1921 → CP2102 U33(电气图第4/9页标为 TX1 接 -U6-2 P1.26 RX1)",
- "direction": "bidirectional",
- "external_level": "3.3V LVCMOS",
- "function_category": "mcu_gpio",
- "reserved": True,
- "fixed_load_conflict": False,
- "external_components": ["R1029", "R1921", "U33"],
- "path": ["CON103.1 (MCU_UART1_TX_CON)", "R1029.2->1 (MCU_UART1_TX)", "U27.12 (PA2)", "R1921 -> CP2102 U33"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- "mcu": {
- "device": "U27",
- "family": "STM32F103CBT6",
- "pin": "12",
- "signal": "PA2/MCU_UART1_TX",
- "capabilities": ["gpio", "firmware_configurable", "mcu_uart_tx"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- },
- "2": {
- "summary": "CON103.2 (MCU_UART1_RX_CON) ← R1030 ← 板载 STM32 U27.13 (PA3/MCU_UART1_RX) & R1920 ← CP2102 U33(电气图第4/9页标为 RX1 接 -U6-2 P1.25 TX1)",
- "direction": "bidirectional",
- "external_level": "3.3V LVCMOS",
- "function_category": "mcu_gpio",
- "reserved": True,
- "fixed_load_conflict": False,
- "external_components": ["R1030", "R1920", "U33"],
- "path": ["CON103.2 (MCU_UART1_RX_CON)", "R1030.2->1 (MCU_UART1_RX)", "U27.13 (PA3)", "R1920 -> CP2102 U33"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- "mcu": {
- "device": "U27",
- "family": "STM32F103CBT6",
- "pin": "13",
- "signal": "PA3/MCU_UART1_RX",
- "capabilities": ["gpio", "firmware_configurable", "mcu_uart_rx"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- },
- "3": {
- "summary": "CON103.3 +3.3V 电源参考",
- "direction": "passive",
- "external_level": "+3.3V",
- "function_category": "power",
- "reserved": True,
- "fixed_load_conflict": True,
- "path": ["CON103.3 (+3.3V)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- "4": {
- "summary": "CON103.4 GND 串口参考地(电气图第4/9页接 -U6-2 P1.19 GND3)",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "reserved": True,
- "fixed_load_conflict": True,
- "path": ["CON103.4 (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- },
- },
- }
- # 3e. CON53..CON82 temperature probe labels from Page 4 of 温控板测试V2.0电气图
- v20_probe_labels = {
- "CON53": "1#腔室温度1(进风口)— CT7428 U6 远端温度通道 1(DP1/DN 二极管差分接口)",
- "CON55": "1#腔室温度2(出风口)— CT7428 U6 远端温度通道 2(DP2/DN 二极管差分接口)",
- "CON56": "2#腔室温度1(进风口)— CT7428 U6 远端温度通道 3(DP3/DN 二极管差分接口)",
- "CON57": "2#腔室温度2(出风口)— CT7428 U6 远端温度通道 4(DP4/DN 二极管差分接口)",
- "CON79": "3#腔室温度1(进风口)— CT7428 U6 远端温度通道 5(DP5/DN 二极管差分接口)",
- "CON80": "3#腔室温度2(出风口)— CT7428 U6 远端温度通道 6(DP6/DN 二极管差分接口)",
- "CON81": "4#腔室温度1(进风口)— CT7428 U6 远端温度通道 7(DP7/DN 二极管差分接口)",
- "CON82": "4#腔室温度2(出风口)— CT7428 U6 远端温度通道 8(DP8/DN 二极管差分接口)",
- }
- for probe_ref, probe_summary in v20_probe_labels.items():
- if probe_ref in touchpoint_anns:
- touchpoint_anns[probe_ref]["summary"] = probe_summary
- # 4. Build PTC lookup from pin_inventory
- ptc_active_map: dict[str, dict[str, Any]] = {}
- for item in pin_inv.get("ptc_channels", []):
- conn_str = str(item["connector"])
- if "/" in conn_str:
- base_ref, pin_pair = conn_str.split(".", 1)
- for p_part in pin_pair.split("/"):
- ptc_active_map[f"{base_ref}.{p_part}"] = item
- else:
- ptc_active_map[conn_str] = item
- # CON147, CON148, CON149, CON150 (20-pin PTC headers, 30W/24V heaters on Page 8)
- ptc_summaries = {
- "CON147": "1# 腔体 20Pin PTC 加热输出座(6×30W/24V -1-E1..6:奇脚 1..11 为 6400 V2.0 启用 PTC1..6 → U3.F16/G16/T4/R5/T6/R7;奇脚 13..19 为预留 PTC7..10 → U3.M1/N1/P1/R1;偶脚 2..20 为 PGND)",
- "CON148": "2# 腔体 20Pin PTC 加热输出座(6×30W/24V -2-E1..6:奇脚 1..11 为 6400 V2.0 启用 PTC11..16 → U3.T2/R3/P16/R16/M16/N16;奇脚 13..19 为预留 PTC17..20 → U3.P8/P7/T9/P9;偶脚 2..20 为 PGND)",
- "CON149": "3# 腔体 20Pin PTC 加热输出座(6×30W/24V -3-E1..6:奇脚 1..11 为 6400 V2.0 启用 PTC21..26 → U3.P10/R10/T13/T12/L3/N2;Pin 19 PTC30 → U3.K5 为 ptc_pwm_out[18]、4#腔第1路;Pin 13/15/17 为预留 PTC27..29 → U3.P2/M3/L5;偶脚 2..20 为 PGND)",
- "CON150": "4# 腔体 20Pin PTC 双针并联加热输出座(30W/24V -4-E2..6:PCB 奇脚对 1/3, 5/7, 9/11, 13/15, 17/19 两两并联为 5 路物理通道 PTC31..35 → U3.L4/H4/J6/H5/C15 对应 ptc_pwm_out[19..23];4#腔第1路在 CON149.19;偶脚 2..20 为 PGND)",
- }
- for ref in ("CON147", "CON148", "CON149", "CON150"):
- pins_dict: dict[str, Any] = {}
- for p_idx in range(1, 21):
- pnum = str(p_idx)
- key = f"{ref}.{pnum}"
- net, hit = trace_net_to_u3_u27(ref, pnum, comp_pins, net_to_pins)
- if p_idx % 2 == 0:
- pins_dict[pnum] = {
- "summary": f"{key} PTC 加热回路功率地 (PGND)",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": [f"{key} (PGND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- }
- elif hit is not None:
- _dev, ball, fpga_net, path_list, ext_list = hit
- active_info = ptc_active_map.get(key)
- if active_info is not None:
- idx = active_info["index"]
- role_txt = f"ptc_pwm_out[{idx}] (6400 V2.0 已启用, 30W/24V)"
- else:
- role_txt = f"{net} 预留加热通道 (6400 V2.0 未启用)"
- pins_dict[pnum] = {
- "summary": f"{key} ({net}) → FPGA U3.{ball} ({role_txt})",
- "direction": "output",
- "external_level": "24V PTC PWM",
- "function_category": "pwm",
- "active_level": "high",
- "polarity": "normal",
- "external_components": ext_list,
- "path": path_list,
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- "fpga": {
- "ball": ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["pwm", "gpio_output"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- }
- touchpoint_anns[ref] = {"summary": ptc_summaries[ref], "pins": pins_dict}
- # CON154..CON158 (14-pin + 2-shield Fan headers)
- fan_active_map = {item["connector"]: item for item in pin_inv.get("fan_channels", [])}
- fan_summaries = {
- "CON155": "3# & 4# 腔体风扇控制座(Pin 5/6/11/12 为 CON_PWM5..8 → 经 NMOS 反相至 U3.P12/A10/D8/C7 对应 fan_front_out[2..3]/fan_rear_out[2..3];Pin 1..4/7..10 为 FG 测速反馈;Pin 13/14 为 GND)",
- "CON154": "1# & 2# 腔体风扇控制座(Pin 5/6/11/12 为 CON_PWM1..4 → 经 NMOS 反相至 U3.C4/B5/B1/A14 对应 fan_front_out[0..1]/fan_rear_out[0..1];Pin 1..4/7..10 为 FG 测速反馈;Pin 13/14 为 GND)",
- "CON156": "备用 14Pin 风扇控制扩展座 1(空余插座:Pin 5/6/11/12 为 CON_PWM9..12 → U3.F10/L8/C8/E7,Pin 1..4/7..10 为 FG9..12 测速,Pin 13/14 为 GND)",
- "CON157": "备用 14Pin 风扇控制扩展座 2(空余插座:Pin 5/6/11/12 为 CON_PWM13..16 → U3.A3/B11/K15/J15,Pin 1..4/7..10 为 FG13..16 测速,Pin 13/14 为 GND)",
- "CON158": "备用 14Pin 风扇控制扩展座 3(空余插座:Pin 5/6/11/12 为 CON_PWM17..20 → U3.T3/T5/T7/P13,Pin 1..4/7..10 为 FG17..20 测速,Pin 13/14 为 GND)",
- }
- for ref in ("CON154", "CON155", "CON156", "CON157", "CON158"):
- pins_dict = {}
- for p_idx in range(1, 15):
- pnum = str(p_idx)
- key = f"{ref}.{pnum}"
- net, hit = trace_net_to_u3_u27(ref, pnum, comp_pins, net_to_pins)
- if p_idx in (13, 14):
- pins_dict[pnum] = {
- "summary": f"{key} 风扇控制共地 (GND)",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": [f"{key} (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- }
- elif hit is not None:
- _dev, ball, _fpga_net, path_list, ext_list = hit
- if p_idx in (5, 6, 11, 12):
- f_act = fan_active_map.get(key)
- if f_act is not None:
- rtl_sig = f"fan_{f_act['group']}_out[{f_act['index']}]"
- desc = f"{key} ({net}) → 经 {f_act['nmos']} 2N7002 反相 → FPGA U3.{ball} ({rtl_sig})"
- else:
- desc = f"{key} ({net}) → 经 NMOS 反相 → FPGA U3.{ball}(备用风扇 PWM)"
- pins_dict[pnum] = {
- "summary": desc,
- "direction": "output",
- "external_level": "主板NMOS反相后的开漏PWM;连接器高电平为ON",
- "function_category": "pwm",
- "active_level": "FPGA低电平有效;连接器高电平为ON",
- "polarity": "FPGA与连接器之间反相(主板NMOS)",
- "external_components": ext_list,
- "path": path_list,
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- "fpga": {
- "ball": ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["pwm", "gpio_output"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- }
- else:
- pins_dict[pnum] = {
- "summary": f"{key} ({net} 风扇转速反馈) ← FPGA U3.{ball}",
- "direction": "input",
- "external_level": "3.3V Divided Tach",
- "function_category": "tach",
- "external_components": ext_list,
- "path": path_list,
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "fpga": {
- "ball": ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["tach", "gpio_input"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- }
- touchpoint_anns[ref] = {"summary": fan_summaries[ref], "pins": pins_dict}
- # CON159..CON163 (14-pin + 2-shield Stepper Motor headers)
- con159_damper_map = {
- 1: "X1-S → -U1 X-STEP (1轴 -M1 1#前部风门 STEP)",
- 2: "X1-D → -U1 X-DIR (1轴 -M1 1#前部风门 DIR)",
- 3: "Y1-S → -U1 Y-STEP (2轴 -M2 1#后部风门 STEP)",
- 4: "Y1-D → -U1 Y-DIR (2轴 -M2 1#后部风门 DIR)",
- 5: "Z1-S → -U1 Z-STEP (3轴 -M3 1#顶部风门 STEP)",
- 6: "Z1-D → -U1 Z-DIR (3轴 -M3 1#顶部风门 DIR)",
- 7: "A1-S → -U1 A-STEP (轴4 -M4 2#前部风门 STEP)",
- 8: "A1-D → -U1 A-DIR (轴4 -M4 2#前部风门 DIR)",
- 9: "ENA1 → -U1 EN: 使能 (与 CAD CON165.1/现场14 共用 U3.F3,已固定低电平)",
- }
- for idx_m, ref in enumerate(("CON159", "CON160", "CON161", "CON162", "CON163"), start=1):
- ch_start = (idx_m - 1) * 4 + 1
- ch_end = idx_m * 4
- pins_dict = {}
- for p_idx in range(1, 15):
- pnum = str(p_idx)
- key = f"{ref}.{pnum}"
- net, hit = trace_net_to_u3_u27(ref, pnum, comp_pins, net_to_pins)
- if p_idx in (11, 13):
- pins_dict[pnum] = {
- "summary": (
- f"{key} (GND6) 步进驱动器信号地 (GND, 接第3页 -U1 GND)"
- if ref == "CON159"
- else f"{key} 步进驱动器信号地 (GND)"
- ),
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": [f"{key} (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- }
- elif p_idx in (12, 14):
- pins_dict[pnum] = {
- "summary": (
- f"{key} (P6 +5V) 步进驱动板 +5V 逻辑电源 (接第3页 -U1 5V)"
- if ref == "CON159"
- else f"{key} +5V 步进驱动器光电耦合共阳电源"
- ),
- "direction": "output",
- "external_level": "+5V",
- "function_category": "power",
- "path": [f"{key} (+5V)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- }
- elif p_idx == 10:
- pins_dict[pnum] = {
- "summary": (
- f"{key} (NC1) 电气图第3/4页接 -U1 GND: 使能地(PCB 焊盘悬空 NC)"
- if ref == "CON159"
- else f"{key} 悬空空脚 (NC)"
- ),
- "direction": "passive",
- "external_level": "none",
- "function_category": "unknown",
- "path": [f"{key} (NC)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- }
- elif hit is not None:
- _dev, ball, _fpga_net, path_list, ext_list = hit
- if ref == "CON159" and p_idx in con159_damper_map:
- damper_desc = con159_damper_map[p_idx]
- pins_dict[pnum] = {
- "summary": f"{key} ({net}) → FPGA U3.{ball}(电气图第3/4页:{damper_desc};6400 32B 协议空余未启用)",
- "direction": "output",
- "external_level": "3.3V LVCMOS",
- "function_category": "gpio_output",
- "external_components": ext_list,
- "path": path_list,
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- "fpga": {
- "ball": ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["gpio_output", "gpio"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"],
- },
- }
- else:
- pins_dict[pnum] = {
- "summary": f"{key} ({net}) → FPGA U3.{ball}(6400 V2.0 无步进电机,空余未用)",
- "direction": "output",
- "external_level": "5V CMOS Buffer",
- "function_category": "gpio_output",
- "external_components": ext_list,
- "path": path_list,
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "fpga": {
- "ball": ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["gpio_output", "gpio"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- }
- if ref == "CON159":
- touchpoint_anns[ref] = {
- "summary": (
- "步进控制接口 1(电气图第3/4页接 -U1 四轴驱动板控制 -M1 1#前部风门 / -M2 1#后部风门 / -M3 1#顶部风门 / -M4 2#前部风门:"
- "Pin 1..8 为 PUL/DIR1..4 → U3.C12/B12/L12/J11/L14/K14/L13/K11,Pin 9 为 ENA1 → U3.F3;6400 协议空余插座)"
- ),
- "pins": pins_dict,
- }
- else:
- touchpoint_anns[ref] = {
- "summary": f"备用 14Pin 步进电机驱动扩展座 {idx_m}(空余插座:Pin 1..8 为 PUL/DIR{ch_start}..{ch_end},Pin 9 为 ENA{idx_m} → U3.F3,Pin 11/13 为 GND,Pin 12/14 为 +5V)",
- "pins": pins_dict,
- }
- # CON165, CON166 (14-pin + 2-shield SSR / Hood-Button / Photoelectric headers)
- # 6400高温罩电气图V3.0 Page 4 aligns CON165 pins 1:1 with FCB_FPGA+MCU_V2.0_20260914.brd:
- # CON165.14/13/11 -> SSR1/SSR2/SSR4 (U3.E14/E8/D9, 20Hz PWM)
- # CON165.12 -> NC (empty pin; old temporary U3.F7 removed)
- # CON165.10/9/8 -> EPB1/SB1/SB2 (U3.F8/C11/A11, PULLDOWN, GET_ALL bytes 86/87/88)
- ssr_active_pins = {
- "CON165.14": ("SSR1 (ssr1_out, 腔1 -1-7E 110W/24V 加热布)", "R1698", "R1860", "CPLD_GPIO64"),
- "CON165.13": ("SSR2 (ssr2_out, 腔2+3共用 -2-7E 220W/24V 加热布)", "R1695", "R1859", "ADC0_CH7"),
- "CON165.11": ("SSR4 (ssr4_out, 腔4 -4-7E 110W/24V 加热布)", "R1694", "R1857", "ADC0_CH5"),
- }
- v30_button_pins = {
- "CON165.10": (
- "急停按钮 EPB1 (estop_btn_in)",
- "F8",
- "IO10 / CON_PE10 -> R1696(22Ω) -> PE10 -> R1856(0Ω) -> ADC0_CH0 -> U3.F8",
- ["R1696", "R1856", "R1724"],
- "R1724(10K上拉)未贴装(NC),约束配 LVCMOS33 + 内部 PULLDOWN(默认低 0x00,按下高 0x01);仅在 GET_ALL 时放进回包第 86 字节透传,不做任何 CPLD 安全联锁或停机处理",
- ),
- "CON165.9": (
- "开罩按钮 SB1 (hood_open_btn_in)",
- "C11",
- "IO9 / CON_PE9 -> R1693(22Ω) -> PE9 -> R1855(0Ω) -> BANK0_GPIO2 -> U3.C11",
- ["R1693", "R1855", "R1717"],
- "R1717(10K上拉)未贴装(NC),约束配 LVCMOS33 + 内部 PULLDOWN(默认低 0x00,按下高 0x01);仅在 GET_ALL 时放进回包第 87 字节,不主动上报",
- ),
- "CON165.8": (
- "合罩按钮 SB2 (hood_close_btn_in)",
- "A11",
- "IO8 / CON_PE8 -> R1692(22Ω) -> PE8 -> R1854(0Ω) -> BANK0_GPIO1 -> U3.A11",
- ["R1692", "R1854", "R1723"],
- "R1723(10K上拉)未贴装(NC),约束配 LVCMOS33 + 内部 PULLDOWN(默认低 0x00,按下高 0x01);仅在 GET_ALL 时放进回包第 88 字节,不主动上报",
- ),
- }
- con165_verified_pins = {"14", "13", "12", "11", "10", "9", "8", "1", "2", "4"}
- for ref in ("CON165", "CON166"):
- pins_dict = {}
- for p_idx in range(1, 15):
- pnum = str(p_idx)
- key = f"{ref}.{pnum}"
- net, hit = trace_net_to_u3_u27(ref, pnum, comp_pins, net_to_pins)
- if key in v30_button_pins:
- btn_label, btn_ball, chain_txt, btn_res, btn_note = v30_button_pins[key]
- pins_dict[pnum] = {
- "summary": f"{key} ({net}) → {btn_label} → FPGA U3.{btn_ball}({chain_txt};{btn_note})",
- "direction": "input",
- "external_level": "3.3V LVCMOS (PULLDOWN, active-HIGH 0x01)",
- "function_category": "gpio_input",
- "active_level": "high",
- "polarity": "normal",
- "adc_pulltype": "PULLDOWN",
- "external_components": btn_res,
- "path": [f"{key} ({net})", f"{btn_res[0]} (22R)", f"{btn_res[1]} (0R)", f"U3.{btn_ball} ({btn_label})"],
- "evidence_tier": "cross_verified",
- "sources": [
- "FCB_FPGA+MCU_V2.0_20260914.brd",
- "6400高温罩电气图V3.0.pdf",
- "evidence/hardware/20261023/main_bom.csv",
- "constraints/prod2u_6400_v2.adc",
- ],
- "fpga": {
- "ball": btn_ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["gpio_input", "gpio"],
- "evidence_tier": "cross_verified",
- "sources": ["6400高温罩电气图V3.0.pdf", "constraints/prod2u_6400_v2.adc"],
- },
- }
- elif key == "CON165.12":
- pins_dict[pnum] = {
- "summary": "CON165.12 (IO12 / CON_PE12) — 电气图 V3.0 第4页为空脚 (NC),已取消旧版暂绑的 U3.F7",
- "direction": "passive",
- "external_level": "NC (unconnected in V3.0)",
- "function_category": "unknown",
- "path": ["CON165.12 (CON_PE12)", "R1697 (22R)", "R1858 (0R)", "U3.F7 (unbound/NC in V3.0)"],
- "external_components": ["R1697", "R1858", "R1725"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V3.0.pdf"],
- }
- elif hit is not None:
- _dev, ball, _fpga_net, path_list, ext_list = hit
- if key in ssr_active_pins:
- ssr_label, r_ser, r_zero, fpga_sig = ssr_active_pins[key]
- pins_dict[pnum] = {
- "summary": f"{key} ({net} → {r_ser}/{r_zero} → {fpga_sig}) → FPGA U3.{ball}({ssr_label},20Hz PWM 50ms周期,高有效,默认/看门狗关闭)",
- "direction": "output",
- "external_level": "3.3V SSR 20Hz PWM",
- "function_category": "pwm",
- "active_level": "high",
- "polarity": "normal",
- "external_components": [r_ser, r_zero],
- "path": [f"{key} ({net})", f"{r_ser} (22R)", f"{r_zero} (0R)", f"U3.{ball} ({fpga_sig})"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V3.0.pdf", "constraints/prod2u_6400_v2.adc"],
- "fpga": {
- "ball": ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["pwm", "gpio_output", "gpio"],
- "evidence_tier": "cross_verified",
- "sources": ["6400高温罩电气图V3.0.pdf", "constraints/prod2u_6400_v2.adc"],
- },
- }
- elif ref == "CON165" and p_idx in (1, 2, 4):
- pins_dict[pnum] = {
- "summary": f"{key} ({net}) → U3.{ball},旧版废弃 SSR 引脚(当前固件 ssr_unused_zero 固定拉低)",
- "direction": "output", "external_level": "0V", "function_category": "gpio_output",
- "reserved": True,
- "path": path_list, "external_components": ext_list,
- "evidence_tier": "cross_verified", "sources": ["constraints/prod2u_6400_v2.adc"],
- "fpga": {"ball": ball, "board_signal": net, "io_standard": "LVCMOS33", "evidence_tier": "cross_verified", "sources": ["constraints/prod2u_6400_v2.adc"]},
- }
- else:
- pins_dict[pnum] = {
- "summary": f"{key} ({net}) ↔ FPGA U3.{ball}(光电限位/GPIO 预留通道,6400 V2.0 空余)",
- "direction": "bidirectional",
- "external_level": "3.3V LVCMOS",
- "function_category": "gpio",
- "external_components": ext_list,
- "path": path_list,
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "fpga": {
- "ball": ball,
- "board_signal": net,
- "io_standard": "LVCMOS33",
- "capabilities": ["gpio", "gpio_input", "gpio_output"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- },
- }
- touchpoint_anns[ref] = {
- "summary": (
- "固态继电器 SSR 与急停/开关罩按钮接口座(电气图 V3.0 第4页与主板物理脚位 1:1 对齐:"
- "Pin 14/13/11=SSR1/SSR2/SSR4 → U3.E14/E8/D9 20Hz PWM;Pin 12=空脚 NC;"
- "Pin 10=急停 EPB1 → U3.F8、Pin 9=开罩 SB1 → U3.C11、Pin 8=合罩 SB2 → U3.A11 均配 PULLDOWN 仅 GET_ALL 透传;旧 F3/F1/G4 固定低电平)"
- if ref == "CON165"
- else "光电限位与 GPIO 扩展座 2(空余插座:Pin 1..14 为 CON_PE15..28 ↔ U3.D16/E15/D14/R9/T10/L2/L1/M2/N3/K4/H2/H1/J2/K3)"
- ),
- "pins": pins_dict,
- }
- # CON164 (4-pin + 2-shield SSR GND & auxiliary power)
- touchpoint_anns["CON164"] = {
- "summary": "固态继电器 SSR 公共回路地与辅助电源座(Pin 1: +5V,Pin 2/3: GND1 配合 CON165.1/2/4 构成 SSR 回路负端,Pin 4: +3.3V)",
- "pins": {
- "1": {"summary": "CON164.1 +5V 辅助电源", "direction": "output", "external_level": "+5V", "function_category": "power", "path": ["CON164.1 (+5V)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- "2": {"summary": "CON164.2 GND 公共地", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": ["CON164.2 (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- "3": {"summary": "CON164.3 GND1 固态继电器 SSR 公共负端回路 (配合 CON165.1/2/4)", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": ["CON164.3 (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"]},
- "4": {"summary": "CON164.4 +3.3V 辅助电源参考", "direction": "output", "external_level": "+3.3V", "function_category": "power", "path": ["CON164.4 (+3.3V)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- },
- }
- # CON168 on Mainboard (4-pin LCD UART header)
- touchpoint_anns["CON168"] = {
- "summary": "板载 STM32 MCU 串口屏扩展座(空余插座:Pin 1 GND,Pin 2 CON_LCD_RX → U27.30 PA9,Pin 3 CON_LCD_TX ← U27.31 PA10,Pin 4 CON_LCD_VCC;新版电气图第4页未接线)",
- "pins": {
- "1": {"summary": "CON168.1 GND", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": ["CON168.1 (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- "2": {
- "summary": "CON168.2 (CON_LCD_RX) → R1892 → 板载 MCU U27.30 (PA9 / MCU_UART0_TX)",
- "direction": "output",
- "external_level": "3.3V LVCMOS",
- "function_category": "uart_tx",
- "external_components": ["R1892"],
- "path": ["CON168.2 (CON_LCD_RX)", "R1892.2->1 (MCU_UART0_TX)", "U27.30 (PA9)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "mcu": {"device": "U27", "family": "STM32F103CBT6", "pin": "30", "signal": "PA9/MCU_UART0_TX", "capabilities": ["mcu_uart_tx"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- },
- "3": {
- "summary": "CON168.3 (CON_LCD_TX) ← R1893 ← 板载 MCU U27.31 (PA10 / MCU_UART0_RX)",
- "direction": "input",
- "external_level": "3.3V LVCMOS",
- "function_category": "uart_rx",
- "external_components": ["R1893"],
- "path": ["CON168.3 (CON_LCD_TX)", "R1893.2->1 (MCU_UART0_RX)", "U27.31 (PA10)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "mcu": {"device": "U27", "family": "STM32F103CBT6", "pin": "31", "signal": "PA10/MCU_UART0_RX", "capabilities": ["mcu_uart_rx"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- },
- "4": {"summary": "CON168.4 (CON_LCD_VCC) 经 R1891 接 +5V", "direction": "output", "external_level": "+5V", "function_category": "power", "external_components": ["R1891"], "path": ["CON168.4 (CON_LCD_VCC)", "R1891", "+5V"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- },
- }
- # CON170 on Mainboard (RJ45 BMC RS232 alternate port)
- con170_pins: dict[str, Any] = {}
- for p_idx in range(1, 13):
- pnum = str(p_idx)
- if pnum == "3":
- con170_pins[pnum] = {
- "summary": "CON170.3 (RS232_TX1_RJ45) → R1898 → TRSF3232EIPWR U22.14/11 → R818 → FPGA U3.L10 (bmc_tx,与 CON77.1 并联)",
- "direction": "output",
- "external_level": "RS232",
- "function_category": "uart_tx",
- "external_components": ["R1898", "U22", "R818"],
- "path": ["CON170.3 (RS232_TX1_RJ45)", "R1898.2->1 (RS232_TX1)", "U22.14->11 (UART1_TX)", "R818.2->1 (BANK2_GPIO52)", "U3.L10 (bmc_tx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "fpga": {"ball": "L10", "board_signal": "BANK2_GPIO52", "io_standard": "LVCMOS33", "capabilities": ["uart_tx", "rs232_via_transceiver"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- }
- elif pnum == "6":
- con170_pins[pnum] = {
- "summary": "CON170.6 (RS232_RX1_RJ45) ← R1899 ← TRSF3232EIPWR U22.13/12 ← R819 ← FPGA U3.M9 (bmc_rx,与 CON77.2 并联)",
- "direction": "input",
- "external_level": "RS232",
- "function_category": "uart_rx",
- "external_components": ["R1899", "U22", "R819"],
- "path": ["CON170.6 (RS232_RX1_RJ45)", "R1899.2->1 (RS232_RX1)", "U22.13->12 (UART1_RX)", "R819.2->1 (BANK2_GPIO53)", "U3.M9 (bmc_rx)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "fpga": {"ball": "M9", "board_signal": "BANK2_GPIO53", "io_standard": "LVCMOS33", "capabilities": ["uart_rx", "rs232_via_transceiver"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- }
- elif pnum in ("4", "9"):
- con170_pins[pnum] = {"summary": f"CON170.{pnum} GND", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": [f"CON170.{pnum} (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]}
- elif pnum == "10":
- con170_pins[pnum] = {"summary": "CON170.10 RJ45 指示灯阳极 (经 R1900 接 +3.3V)", "direction": "passive", "external_level": "3.3V", "function_category": "power", "external_components": ["R1900"], "path": ["CON170.10 (N11538228)", "R1900", "+3.3V"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]}
- else:
- con170_pins[pnum] = {"summary": f"CON170.{pnum} 悬空触点 (NC)", "direction": "passive", "external_level": "none", "function_category": "unknown", "path": [f"CON170.{pnum} (NC)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]}
- touchpoint_anns["CON170"] = {
- "summary": "RJ45 BMC RS-232 备用接口座(Pin 3 TX1_RJ45 → U3.L10,Pin 6 RX1_RJ45 ← U3.M9,与 CON77 共用 TRSF3232EIPWR U22 通道)",
- "pins": con170_pins,
- }
- # CON171 (4-pin + 2-shield GPIO header: EX_GPIO7..10 -> M10, N11, L7, M7)
- con171_pins: dict[str, Any] = {}
- for p_idx in range(1, 5):
- pnum = str(p_idx)
- net, hit = trace_net_to_u3_u27("CON171", pnum, comp_pins, net_to_pins)
- if hit is not None:
- _dev, ball, _fpga_net, path_list, ext_list = hit
- con171_pins[pnum] = {
- "summary": f"CON171.{pnum} ({net}) ↔ FPGA U3.{ball}(外部 3.3V GPIO 扩展,6400 V2.0 空余)",
- "direction": "bidirectional",
- "external_level": "3.3V LVCMOS",
- "function_category": "gpio",
- "external_components": ext_list,
- "path": path_list,
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "fpga": {"ball": ball, "board_signal": net, "io_standard": "LVCMOS33", "capabilities": ["gpio", "gpio_input", "gpio_output"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- }
- touchpoint_anns["CON171"] = {
- "summary": "外部 3.3V GPIO 扩展座(空余插座:Pin 1..4 为 EX_GPIO7..10 ↔ R1901..R1904 ↔ FPGA U3.M10/N11/L7/M7)",
- "pins": con171_pins,
- }
- # CON172 on Mainboard (18-pad USB Type-C connector -> CP2102 U33 -> MCU U27.12/13)
- con172_pins: dict[str, Any] = {}
- for pnum in ("A1", "A4", "A5", "A6", "A7", "A9", "A12", "B1", "B4", "B5", "B6", "B7", "B9", "B12"):
- if pnum in ("A6", "B6"):
- con172_pins[pnum] = {
- "summary": f"CON172.{pnum} (USB_D+) ↔ R1917 ↔ CP2102 U33.4 ↔ R1920/R1921 ↔ 板载 MCU U27.12/13 (PA2/PA3 MCU_UART1)",
- "direction": "bidirectional",
- "external_level": "USB 2.0 Differential",
- "function_category": "uart",
- "external_components": ["R1917", "U33", "R1920", "R1921"],
- "path": [f"CON172.{pnum} (USB_D+)", "R1917", "U33 (CP2102)", "R1920/R1921", "U27.12/13 (PA2/PA3)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "mcu": {"device": "U27", "family": "STM32F103CBT6", "pin": "12/13", "signal": "PA2/PA3 (via CP2102 U33)", "capabilities": ["usb_uart_bridge"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- }
- elif pnum in ("A7", "B7"):
- con172_pins[pnum] = {
- "summary": f"CON172.{pnum} (USB_D-) ↔ R1918 ↔ CP2102 U33.5 ↔ R1920/R1921 ↔ 板载 MCU U27.12/13 (PA2/PA3 MCU_UART1)",
- "direction": "bidirectional",
- "external_level": "USB 2.0 Differential",
- "function_category": "uart",
- "external_components": ["R1918", "U33", "R1920", "R1921"],
- "path": [f"CON172.{pnum} (USB_D-)", "R1918", "U33 (CP2102)", "R1920/R1921", "U27.12/13 (PA2/PA3)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"],
- "mcu": {"device": "U27", "family": "STM32F103CBT6", "pin": "12/13", "signal": "PA2/PA3 (via CP2102 U33)", "capabilities": ["usb_uart_bridge"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]},
- }
- elif pnum in ("A4", "A9", "B4", "B9"):
- con172_pins[pnum] = {"summary": f"CON172.{pnum} (VBUS) USB 5V 供电输入 (经 R1915 至 CP2102 U33)", "direction": "input", "external_level": "+5V VBUS", "function_category": "power", "external_components": ["R1915"], "path": [f"CON172.{pnum} (VBUS)", "R1915", "CP2102_VBUS"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]}
- elif pnum in ("A5", "B5"):
- r_cc = "R1913" if pnum == "A5" else "R1914"
- con172_pins[pnum] = {"summary": f"CON172.{pnum} USB Type-C CC 配置脚 (经 {r_cc} 5.1k 下拉至 GND)", "direction": "passive", "external_level": "USB CC", "function_category": "power", "external_components": [r_cc], "path": [f"CON172.{pnum}", r_cc, "GND"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]}
- else:
- con172_pins[pnum] = {"summary": f"CON172.{pnum} USB GND", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": [f"CON172.{pnum} (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd"]}
- touchpoint_anns["CON172"] = {
- "summary": "USB Type-C 板载 MCU 调试串口座(经 CP2102 U33 USB-UART 桥接芯片连接 GD32 U27.12/13 PA2/PA3,非 FPGA 端口)",
- "pins": con172_pins,
- }
- # CON173, CON174 (12-pin +24V_VIN main power connectors)
- for ref in ("CON173", "CON174"):
- p_dict: dict[str, Any] = {}
- for p_idx in range(1, 13):
- pnum = str(p_idx)
- if p_idx <= 6:
- p_dict[pnum] = {"summary": f"{ref}.{pnum} PCB 网表 24V 主电源输入负端 (GND;注:电气图第4页符号将 Pin 1..6 标为 24V P24,接线请以 PCB 铜皮为准)", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": [f"{ref}.{pnum} (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"]}
- else:
- p_dict[pnum] = {"summary": f"{ref}.{pnum} PCB 网表 +24V_VIN 主电源输入正端 (+24V;注:电气图第4页符号将 Pin 7..12 标为 GND N24,接线请以 PCB 铜皮为准)", "direction": "input", "external_level": "+24V DC", "function_category": "power", "path": [f"{ref}.{pnum} (+24V_VIN)"], "evidence_tier": "cross_verified", "sources": ["FCB_FPGA+MCU_V2.0_20260914.brd", "6400高温罩电气图V2.0.pdf"]}
- touchpoint_anns[ref] = {
- "summary": "12Pin +24V_VIN 主功率电源输入座(PCB 网表 Pin 1..6 为 GND、Pin 7..12 为 +24V_VIN;注:电气图第4页符号标为 Pin 1..6=24V P24、Pin 7..12=GND N24)",
- "pins": p_dict,
- }
- interfaces = [
- {
- "id": "host-ttl",
- "name": "Host TTL 串口 (连接外部 STM32H7 核心板)",
- "touchpoint": "CON12",
- "pins": ["1", "2", "3", "4"],
- "external_level": "3.3V LVCMOS",
- "evidence_tier": "cross_verified",
- "sources": ["reference/original/schematics/6400高温罩电气图V2.0.pdf", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "host-rs232",
- "name": "Host RS-232 串口 (921600 波特率)",
- "touchpoint": "CON134",
- "pins": ["1", "2", "3", "4"],
- "external_level": "RS232",
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "bmc-rs232",
- "name": "BMC RS-232 串口 (115200 波特率)",
- "touchpoint": "CON77",
- "pins": ["1", "2", "3", "4"],
- "external_level": "RS232",
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "ptc-chamber1",
- "name": "1# 腔体 PTC 加热输出 (PTC1..6)",
- "touchpoint": "CON147",
- "pins": ["1", "3", "5", "7", "9", "11"],
- "external_level": "24V PTC PWM",
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "ptc-chamber2",
- "name": "2# 腔体 PTC 加热输出 (PTC11..16)",
- "touchpoint": "CON148",
- "pins": ["1", "3", "5", "7", "9", "11"],
- "external_level": "24V PTC PWM",
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "ptc-chamber3",
- "name": "3# 腔体 PTC 加热输出 (PTC21..26)",
- "touchpoint": "CON149",
- "pins": ["1", "3", "5", "7", "9", "11"],
- "external_level": "24V PTC PWM",
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "ptc-chamber4",
- "name": "4# 腔体 PTC 第2..6路 (PTC31..35;第1路在CON149.19)",
- "touchpoint": "CON150",
- "pins": ["1", "3", "5", "7", "9", "11", "13", "15", "17", "19"],
- "external_level": "24V PTC PWM",
- "evidence_tier": "cross_verified",
- "sources": ["config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "fan-chamber1-2",
- "name": "1# & 2# 腔体前/后风扇 PWM (Front0..1, Rear0..1)",
- "touchpoint": "CON154",
- "pins": ["5", "6", "11", "12"],
- "external_level": "主板NMOS反相后的风扇PWM",
- "evidence_tier": "cross_verified",
- "sources": ["docs/evidence/FCB_FAN_V2_0_ANALYSIS.md", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "fan-chamber3-4",
- "name": "3# & 4# 腔体前/后风扇 PWM (Front2..3, Rear2..3)",
- "touchpoint": "CON155",
- "pins": ["5", "6", "11", "12"],
- "external_level": "主板NMOS反相后的风扇PWM",
- "evidence_tier": "cross_verified",
- "sources": ["docs/evidence/FCB_FAN_V2_0_ANALYSIS.md", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "ssr-control",
- "name": "三路加热布 SSR 调功控制 (SSR1/SSR2/SSR4)",
- "touchpoint": "CON165",
- "pins": ["14", "13", "11"],
- "external_level": "3.3V高有效;20Hz PWM (50ms周期);默认/看门狗关闭",
- "evidence_tier": "cross_verified",
- "sources": ["reference/original/schematics/6400高温罩电气图V3.0.pdf", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "hood-buttons",
- "name": "急停 EPB1 / 开罩 SB1 / 合罩 SB2 按钮检测 (仅 GET_ALL 透传)",
- "touchpoint": "CON165",
- "pins": ["10", "9", "8"],
- "external_level": "3.3V LVCMOS + 内部 PULLDOWN(外置上拉未贴装,默认低0x00/按下高0x01)",
- "evidence_tier": "cross_verified",
- "sources": ["reference/original/schematics/6400高温罩电气图V3.0.pdf", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- {
- "id": "buzzer-output",
- "name": "MCU 触发蜂鸣器高边驱动 (4000Hz / 80% 占空比)",
- "touchpoint": "CON146",
- "pins": ["1", "2"],
- "external_level": "+24V 高边开关 (U3.H6 4000Hz 80%占空比方波:6250拍周期/5000高/1250低)",
- "evidence_tier": "cross_verified",
- "sources": ["reference/original/schematics/6400高温罩电气图V3.0.pdf", "config/pin_inventory.fcb_fpga_mcu_v2_0.json"],
- },
- ]
- # These pin paths are produced by the structural BFS above. NC options and
- # transistor conduction are not verified by that search, even if names match.
- # CON165 pins verified against main_bom.csv + main_pins.csv + V3.0 PDF stay cross_verified.
- for ref in [*(f"CON{i}" for i in range(147, 151)),
- *(f"CON{i}" for i in range(154, 164)), "CON165", "CON166", "CON171"]:
- for pnum, pin in touchpoint_anns.get(ref, {}).get("pins", {}).items():
- if ref == "CON165" and pnum in con165_verified_pins:
- continue
- if "fpga" in pin:
- _mark_inferred(pin)
- pin["summary"] = "拓扑候选(未核装配/导通):" + pin.get("summary", "")
- return {
- "board_id": "fcb_fpga_mcu_v2_0_20260914",
- "connector_profiles": connector_profiles,
- "touchpoints": touchpoint_anns,
- "interfaces": interfaces,
- }
- def _assemble_board_payload(
- parsed_board: ParsedBoard,
- annotations: Mapping[str, Any],
- *,
- board_name: str,
- ) -> dict[str, Any]:
- """Assemble and validate a board-viewer-data-v2 payload from ParsedBoard + annotations."""
- touchpoints = [_touchpoint_dict(fp, parsed_board.bounds) for fp in select_touchpoints(parsed_board)]
- resistors = [
- _resistor_dict(fp, parsed_board.bounds)
- for fp in sorted(select_resistors(parsed_board), key=lambda item: int(item.reference[1:]))
- ]
- profiles: dict[str, tuple[str, Mapping[str, Any]]] = {}
- for prof_name, prof_obj in annotations.get("connector_profiles", {}).items():
- for ref in prof_obj.get("references", []):
- profiles[str(ref)] = (str(prof_name), prof_obj)
- tp_anns = annotations.get("touchpoints", {})
- for tp in touchpoints:
- ref = tp["reference"]
- prof_entry = profiles.get(ref)
- if tp["category"] == "CON" or prof_entry is not None:
- _apply_connector_profile(tp, prof_entry)
- tp_ann = tp_anns.get(ref, {})
- if isinstance(tp_ann, Mapping) and tp_ann.get("summary"):
- tp["summary"] = str(tp_ann["summary"])
- pin_anns = tp_ann.get("pins", {}) if isinstance(tp_ann, Mapping) else {}
- for pin in tp["pins"]:
- p_ann = pin_anns.get(str(pin["number"]), {})
- if isinstance(p_ann, Mapping) and p_ann:
- _merge_annotation(pin, p_ann)
- pin["evidence_sources"] = _unique_strings(list(pin.get("evidence_sources", [])))
- pin["programming"] = _programming_guidance(ref, pin)
- prog_ann = p_ann.get("programming", {}) if isinstance(p_ann, Mapping) else {}
- if isinstance(prog_ann, Mapping) and prog_ann:
- _merge_programming_annotation(pin["programming"], prog_ann)
- _refresh_recommendation(pin)
- _attach_related_resistors(touchpoints, resistors)
- category_counts = Counter(item["category"] for item in touchpoints)
- touchpoint_side_counts = Counter(item["side"] for item in touchpoints)
- resistor_side_counts = Counter(item["side"] for item in resistors)
- connector_touchpoints = [item for item in touchpoints if item["category"] == "CON"]
- resistor_pad_count = sum(len(item["pads"]) for item in resistors)
- resistor_electrical_pad_count = sum(
- 1 for item in resistors for pad in item["pads"] if pad.get("pad_role") == "electrical"
- )
- if resistors:
- value_coverage = _build_value_coverage(resistors)
- else:
- value_coverage = {
- "resistors_total": 0,
- "component_value_nonempty": 0,
- "value_parsed": 0,
- "value_zero_ohm_fitted_or_unknown": 0,
- "value_zero_ohm_not_fitted": 0,
- "assembly_not_fitted": 0,
- "value_missing_or_unparsed": 0,
- "component_value_source_status": "passive_board_no_resistors",
- "example_available_tokens": ["fuse"],
- "note": "Passive connector expansion board with no discrete resistors.",
- }
- payload = {
- "schema": BOARD_DATA_SCHEMA_ID,
- "board": {
- "id": str(annotations.get("board_id")),
- "name": board_name,
- "source_bounds": dict(parsed_board.bounds),
- "view_box": {
- "x": 0.0,
- "y": 0.0,
- "width": parsed_board.bounds["width"],
- "height": parsed_board.bounds["height"],
- },
- },
- "counts": {
- "footprints": parsed_board.footprint_count,
- "touchpoints": len(touchpoints),
- "pads": sum(len(item["pins"]) for item in touchpoints),
- "resistors": len(resistors),
- "resistor_pads": resistor_pad_count,
- "resistor_electrical_pads": resistor_electrical_pad_count,
- "connector_contacts": sum(int(item["connector"]["contact_count"]) for item in connector_touchpoints),
- "connector_auxiliary_pads": sum(
- int(item["connector"]["auxiliary_pad_count"]) for item in connector_touchpoints
- ),
- "categories": {
- "CON": category_counts.get("CON", 0),
- "J": category_counts.get("J", 0),
- "PL": category_counts.get("PL", 0),
- "TP": category_counts.get("TP", 0),
- "R": len(resistors),
- },
- "sides": {key: touchpoint_side_counts.get(key, 0) for key in ("front", "back")},
- "touchpoint_sides": {key: touchpoint_side_counts.get(key, 0) for key in ("front", "back")},
- "resistor_sides": {key: resistor_side_counts.get(key, 0) for key in ("front", "back")},
- },
- "value_coverage": value_coverage,
- "component_value_source_status": value_coverage["component_value_source_status"],
- "touchpoints": touchpoints,
- "resistors": resistors,
- "resistor_links": [],
- "evidence_conflicts": [],
- "interfaces": list(annotations.get("interfaces", [])),
- "photo_overlay": None,
- }
- validate_resistor_index(payload)
- data_schema = json.loads(DATA_SCHEMA_PATH.read_text(encoding="utf-8"))
- Draft202012Validator(data_schema).validate(payload)
- return payload
- # ---------------------------------------------------------------------------
- # Entry Points: Mainboard & Fan Board
- # ---------------------------------------------------------------------------
- def generate_v2_0_mainboard() -> None:
- print("[V2.0] Starting FCB V2.0 (6400 Mainboard) asset generation from Allegro BRD...")
- brd_path = ROOT / "reference/original/board/FCB_FPGA_MCU_V2.0_20260914/FCB_FPGA+MCU_V2.0_20260914.brd"
- pin_inv_path = ROOT / "config/pin_inventory.fcb_fpga_mcu_v2_0.json"
- out_dir = ROOT / "tools/board-viewer/generated-v2_0"
- out_dir.mkdir(parents=True, exist_ok=True)
- parsed_board, cad_meta = parse_allegro_brd(brd_path)
- pin_inv = json.loads(pin_inv_path.read_text(encoding="utf-8"))
- annotations = _build_v20_annotations(parsed_board, cad_meta, pin_inv)
- board_data = _assemble_board_payload(
- parsed_board,
- annotations,
- board_name="FCB FPGA+MCU V2.0 20260914 (6400 主控板)",
- )
- print(
- f"[V2.0] Parsed {board_data['counts']['footprints']} footprints, "
- f"{board_data['counts']['touchpoints']} touchpoints ({board_data['counts']['pads']} pads), "
- f"{board_data['counts']['resistors']} resistors ({board_data['counts']['resistor_pads']} pads) "
- f"on {parsed_board.bounds['width']}x{parsed_board.bounds['height']} mm board"
- )
- (out_dir / "board-data.json").write_text(
- json.dumps(board_data, indent=2, ensure_ascii=False) + "\n",
- encoding="utf-8",
- )
- generate_svg_layers_from_brd(
- parsed_board,
- cad_meta,
- "FCB FPGA+MCU V2.0 20260914",
- board_data["touchpoints"],
- out_dir,
- )
- cats = board_data["counts"]["categories"]
- import_report = {
- "board_id": "fcb_fpga_mcu_v2_0_20260914",
- "source": "reference/original/board/FCB_FPGA_MCU_V2.0_20260914/FCB_FPGA+MCU_V2.0_20260914.brd",
- "source_file": brd_path.name,
- "source_format": "allegro_brd",
- "output_file": "board-data.json",
- "errors": [],
- "timestamp": datetime.now(timezone.utc).isoformat(),
- "stats": {
- "connectors": cats["CON"],
- "jumpers": cats["J"],
- "power_terminals": cats["PL"],
- "test_points": cats["TP"],
- "resistors": cats["R"],
- },
- "status": "success",
- }
- (out_dir / "import-report.json").write_text(json.dumps(import_report, indent=2) + "\n", encoding="utf-8")
- assets_meta: dict[str, dict[str, Any]] = {}
- for asset_file in (out_dir / name for name in (
- "board-data.json", "import-report.json", "board-mask-edge.svg",
- "board-mask-edge-back.svg", "board-copper.svg", "board-copper-back.svg",
- "board-silkscreen.svg", "board-silkscreen-back.svg",
- )):
- if asset_file.is_file():
- assets_meta[asset_file.name] = {
- "sha256": sha256_file(asset_file),
- "bytes": asset_file.stat().st_size,
- }
- v30_pdf_path = ROOT / "reference/original/schematics/6400高温罩电气图V3.0.pdf"
- build_info = {
- "schema": "board-viewer-build-info-v1",
- "generated_at": datetime.now(timezone.utc).isoformat(),
- "generator_version": "3.3.0",
- "toolchain": {"python": sys.version.split()[0], "kicad": "not_used"},
- "sources": {
- **_generator_sources(),
- "brd": {
- "path": "reference/original/board/FCB_FPGA_MCU_V2.0_20260914/FCB_FPGA+MCU_V2.0_20260914.brd",
- "sha256": sha256_file(brd_path),
- },
- "schematic_v3_0": {
- "path": "reference/original/schematics/6400高温罩电气图V3.0.pdf",
- "sha256": sha256_file(v30_pdf_path),
- },
- "annotations": {
- "path": str(ANNOTATIONS_V12_PATH.relative_to(ROOT)),
- "sha256": sha256_file(ANNOTATIONS_V12_PATH),
- },
- "inventory": {
- "path": "config/pin_inventory.fcb_fpga_mcu_v2_0.json",
- "sha256": sha256_file(pin_inv_path),
- },
- "schema_data": {
- "path": "schemas/board_viewer_data.schema.json",
- "sha256": sha256_file(DATA_SCHEMA_PATH),
- },
- "schema_build_info": {
- "path": "schemas/board_viewer_build_info.schema.json",
- "sha256": sha256_file(BUILD_INFO_SCHEMA_PATH),
- },
- },
- "assets": assets_meta,
- "verification": {
- "ipcd356": {
- "status": "not_run",
- "reason": "No independent IPC-D-356 export or alignment comparison was executed by this BRD viewer generator.",
- },
- "side_views": {
- "front_layers": [
- "board-mask-edge.svg",
- "board-silkscreen.svg",
- "board-copper.svg",
- ],
- "back_layers": [
- "board-mask-edge-back.svg",
- "board-silkscreen-back.svg",
- "board-copper-back.svg",
- ],
- "back_mirror_axis": "y",
- "back_svg_export_mirrored": True,
- "convention": "Back SVGs are rendered by this script, mirrored about the vertical/Y axis; viewer hotspot X = board_width - view_position.x. Geometry is simplified, not a KiCad export.",
- },
- },
- "counts": {
- "footprints": board_data["counts"]["footprints"],
- "touchpoints": board_data["counts"]["touchpoints"],
- "pads": board_data["counts"]["pads"],
- "resistors": board_data["counts"]["resistors"],
- "resistor_pads": board_data["counts"]["resistor_pads"],
- },
- }
- build_info_schema = json.loads(BUILD_INFO_SCHEMA_PATH.read_text(encoding="utf-8"))
- Draft202012Validator(build_info_schema).validate(build_info)
- (out_dir / "build-info.json").write_text(json.dumps(build_info, indent=2) + "\n", encoding="utf-8")
- print(f"[V2.0] Asset generation complete! {len(assets_meta)} assets in {out_dir.name}")
- def _build_v20_fan_annotations() -> dict[str, Any]:
- connector_profiles = {
- "CON_SMD_2D54_2X7P": {
- "references": ["CON168"],
- "contact_pins": [str(i) for i in range(1, 15)],
- "shield_pads": [],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd"],
- },
- "CON_PZGM_B03_08P": {
- "references": ["CON8", "CON169", "CON170", "CON171"],
- "contact_pins": [str(i) for i in range(1, 9)],
- "shield_pads": [],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd"],
- },
- "CON_X9556WV_2X4P": {
- "references": ["CON2", "CON172"],
- "contact_pins": [str(i) for i in range(1, 9)],
- "shield_pads": [],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd"],
- },
- }
- con168_pins: dict[str, Any] = {}
- fg_map = {
- "1": ("FG1_1", "CON8.5", "D2/N10"),
- "2": ("FG2_1", "CON169.5", "E6 / U3.R11"),
- "3": ("FG1_2", "CON8.6", "D3/M11"),
- "4": ("FG2_2", "CON169.6", "D6/B9"),
- "7": ("FG3_1", "CON170.5", "C1/D10"),
- "8": ("FG4_1", "CON171.5", "B3/E9"),
- "9": ("FG3_2", "CON170.6", "C2/E10"),
- "10": ("FG4_2", "CON171.6", "B13/B7"),
- }
- pwm_map = {
- "5": ("PWM1", "CON8.7", "P12/C4", "fan_front_2_0"),
- "6": ("PWM2", "CON169.7", "A10/B5", "fan_rear_2_0"),
- "11": ("PWM3", "CON170.7", "D8/B1", "fan_front_3_1"),
- "12": ("PWM4", "CON171.7", "C7/A14", "fan_rear_3_1"),
- }
- for p_idx in range(1, 15):
- pnum = str(p_idx)
- if pnum in pwm_map:
- net, dest, ball, bsig = pwm_map[pnum]
- con168_pins[pnum] = {
- "summary": f"CON168.{pnum} ({net}) → 直通 {dest} ↔ 主板 CON155/CON154.{pnum} → FPGA U3.{ball} ({bsig})",
- "direction": "input",
- "external_level": "主板NMOS反相后的开漏PWM;连接器高电平为ON",
- "function_category": "pwm",
- "path": [f"CON168.{pnum} ({net})", dest, f"主板 U3.{ball} ({bsig})"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd", "docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- }
- elif pnum in fg_map:
- net, src, ball = fg_map[pnum]
- con168_pins[pnum] = {
- "summary": f"CON168.{pnum} ({net}) ← 直通 {src} 转速反馈 → 主板 FPGA U3.{ball}",
- "direction": "output",
- "external_level": "Tach Open-Collector",
- "function_category": "tach",
- "path": [src, f"CON168.{pnum} ({net})", f"主板 U3.{ball}"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd", "docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- }
- else:
- con168_pins[pnum] = {
- "summary": f"CON168.{pnum} (GND) 主控板与风扇板信号共地",
- "direction": "passive",
- "external_level": "0V",
- "function_category": "ground",
- "path": [f"CON168.{pnum} (GND)"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd"],
- }
- touchpoint_anns: dict[str, Any] = {
- "CON168": {
- "summary": "主控板 14Pin 风扇控制与测速输入座(Pin 5/6/11/12 为 PWM1..4,Pin 1..4/7..10 为 FG1_1..FG4_2,Pin 13/14 为 GND,对接主板 CON155/CON154)",
- "pins": con168_pins,
- }
- }
- fan_out_defs = {
- "CON8": ("1# 前风扇输出座 (FM1或FM5双风机)", "PWM1", "5", "FG1_1", "1", "FG1_2", "3", "F32", "P12/C4", "fan_front_2_0"),
- "CON169": ("2# 后风扇输出座 (FM2或FM6)", "PWM2", "6", "FG2_1", "2", "FG2_2", "4", "F132", "A10/B5", "fan_rear_2_0"),
- "CON170": ("3# 前风扇输出座 (FM3或FM7双风机)", "PWM3", "11", "FG3_1", "7", "FG3_2", "9", "F133", "D8/B1", "fan_front_3_1"),
- "CON171": ("4# 后风扇输出座 (FM4或FM8)", "PWM4", "12", "FG4_1", "8", "FG4_2", "10", "F134", "C7/A14", "fan_rear_3_1"),
- }
- for ref, (title_desc, pwm_net, pwm_pin, fg_a, fg_a_pin, fg_b, fg_b_pin, fuse_ref, ball, bsig) in fan_out_defs.items():
- p_dict: dict[str, Any] = {
- "1": {"summary": f"{ref}.1 +12V 风扇供电正极 (经保险丝 {fuse_ref} 保护)", "direction": "output", "external_level": "+12V DC", "function_category": "power", "path": ["CON2/CON172 (+12V)", fuse_ref, f"{ref}.1"], "evidence_tier": "cross_verified", "sources": ["FCB_FAN_V2.0_20260914.brd"]},
- "2": {"summary": f"{ref}.2 +12V 风扇供电正极 (经保险丝 {fuse_ref} 保护)", "direction": "output", "external_level": "+12V DC", "function_category": "power", "path": ["CON2/CON172 (+12V)", fuse_ref, f"{ref}.2"], "evidence_tier": "cross_verified", "sources": ["FCB_FAN_V2.0_20260914.brd"]},
- "3": {"summary": f"{ref}.3 GND 风扇回路地", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": [f"{ref}.3 (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FAN_V2.0_20260914.brd"]},
- "4": {"summary": f"{ref}.4 GND 风扇回路地", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": [f"{ref}.4 (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FAN_V2.0_20260914.brd"]},
- "5": {
- "summary": f"{ref}.5 ({fg_a}) 转速反馈输入 → CON168.{fg_a_pin}",
- "direction": "input",
- "external_level": "Tach Open-Collector",
- "function_category": "tach",
- "path": [f"{ref}.5 ({fg_a})", f"CON168.{fg_a_pin}"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd"],
- },
- "6": {
- "summary": f"{ref}.6 ({fg_b}) 转速反馈输入 → CON168.{fg_b_pin}",
- "direction": "input",
- "external_level": "Tach Open-Collector",
- "function_category": "tach",
- "path": [f"{ref}.6 ({fg_b})", f"CON168.{fg_b_pin}"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd"],
- },
- "7": {
- "summary": f"{ref}.7 ({pwm_net}) 风扇 PWM 输出 ← CON168.{pwm_pin} ← 主板 FPGA U3.{ball} ({bsig})",
- "direction": "output",
- "external_level": "主板NMOS反相后的开漏PWM;连接器高电平为ON",
- "function_category": "pwm",
- "path": [f"{ref}.7 ({pwm_net})", f"CON168.{pwm_pin}", f"主板 U3.{ball} ({bsig})"],
- "evidence_tier": "cross_verified",
- "sources": ["FCB_FAN_V2.0_20260914.brd", "docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- },
- "8": {"summary": f"{ref}.8 GND 风扇回路地", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": [f"{ref}.8 (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FAN_V2.0_20260914.brd"]},
- }
- touchpoint_anns[ref] = {
- "summary": f"{title_desc}(Pin 1/2: +12V 经 {fuse_ref},Pin 3/4/8: GND,Pin 5/6: {fg_a}/{fg_b},Pin 7: {pwm_net} 直通 CON168.{pwm_pin})",
- "pins": p_dict,
- }
- for ref, role_desc in (("CON2", "外部 DC +12V 主电源输入座"), ("CON172", "DC +12V 电源级联输出座")):
- p_dict = {}
- for p_idx in range(1, 9):
- pnum = str(p_idx)
- if p_idx <= 4:
- p_dict[pnum] = {"summary": f"{ref}.{pnum} (GND) 12V 电源地", "direction": "passive", "external_level": "0V", "function_category": "ground", "path": [f"{ref}.{pnum} (GND)"], "evidence_tier": "cross_verified", "sources": ["FCB_FAN_V2.0_20260914.brd"]}
- else:
- p_dict[pnum] = {"summary": f"{ref}.{pnum} (+12V) 12V 功率主电源轨", "direction": "input" if ref == "CON2" else "output", "external_level": "+12V DC", "function_category": "power", "path": [f"{ref}.{pnum} (+12V)"], "evidence_tier": "cross_verified", "sources": ["FCB_FAN_V2.0_20260914.brd"]}
- touchpoint_anns[ref] = {
- "summary": f"{role_desc}(Pin 1..4 为 GND,Pin 5..8 为 +12V 电源轨)",
- "pins": p_dict,
- }
- fan_interfaces = [
- {
- "id": "fan-ctrl-in",
- "name": "主控板风扇控制输入母座",
- "touchpoint": "CON168",
- "pins": ["5", "6", "11", "12"],
- "external_level": "12V PWM",
- "evidence_tier": "cross_verified",
- "sources": ["docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- },
- {
- "id": "fan-1",
- "name": "1# 风扇输出 (FM1或FM5双风机)",
- "touchpoint": "CON8",
- "pins": ["1", "2", "3", "4", "5", "6", "7", "8"],
- "external_level": "12V / 5V PWM",
- "evidence_tier": "cross_verified",
- "sources": ["docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- },
- {
- "id": "fan-2",
- "name": "2# 风扇输出 (FM2或FM6)",
- "touchpoint": "CON169",
- "pins": ["1", "2", "3", "4", "5", "6", "7", "8"],
- "external_level": "12V / 5V PWM",
- "evidence_tier": "cross_verified",
- "sources": ["docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- },
- {
- "id": "fan-3",
- "name": "3# 风扇输出 (FM3或FM7双风机)",
- "touchpoint": "CON170",
- "pins": ["1", "2", "3", "4", "5", "6", "7", "8"],
- "external_level": "12V / 5V PWM",
- "evidence_tier": "cross_verified",
- "sources": ["docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- },
- {
- "id": "fan-4",
- "name": "4# 风扇输出 (FM4或FM8)",
- "touchpoint": "CON171",
- "pins": ["1", "2", "3", "4", "5", "6", "7", "8"],
- "external_level": "12V / 5V PWM",
- "evidence_tier": "cross_verified",
- "sources": ["docs/evidence/FCB_FAN_V2_0_ANALYSIS.md"],
- },
- ]
- return {
- "board_id": "fcb_fan_v2_0_20260914",
- "connector_profiles": connector_profiles,
- "touchpoints": touchpoint_anns,
- "interfaces": fan_interfaces,
- }
- def generate_v2_0_fan_board() -> None:
- print("[V2.0-FAN] Starting FCB_FAN V2.0 (Fan Board) asset generation from Allegro BRD...")
- brd_path = ROOT / "reference/original/board/FCB_FAN_V2.0_20260914/FCB_FAN_V2.0_20260914.brd"
- out_dir = ROOT / "tools/board-viewer/generated-v2_0_fan"
- out_dir.mkdir(parents=True, exist_ok=True)
- parsed_board, cad_meta = parse_allegro_brd(brd_path)
- annotations = _build_v20_fan_annotations()
- fan_board_data = _assemble_board_payload(
- parsed_board,
- annotations,
- board_name="FCB_FAN V2.0 20260914 (风扇扩展板)",
- )
- print(
- f"[V2.0-FAN] Parsed {fan_board_data['counts']['footprints']} footprints, "
- f"{fan_board_data['counts']['touchpoints']} touchpoints ({fan_board_data['counts']['pads']} pads) "
- f"on {parsed_board.bounds['width']}x{parsed_board.bounds['height']} mm board"
- )
- (out_dir / "board-data.json").write_text(
- json.dumps(fan_board_data, indent=2, ensure_ascii=False) + "\n",
- encoding="utf-8",
- )
- generate_svg_layers_from_brd(
- parsed_board,
- cad_meta,
- "FCB_FAN V2.0 20260914",
- fan_board_data["touchpoints"],
- out_dir,
- )
- import_report = {
- "board_id": "fcb_fan_v2_0_20260914",
- "source": "reference/original/board/FCB_FAN_V2.0_20260914/FCB_FAN_V2.0_20260914.brd",
- "source_file": brd_path.name,
- "source_format": "allegro_brd",
- "output_file": "board-data.json",
- "errors": [],
- "timestamp": datetime.now(timezone.utc).isoformat(),
- "stats": {"connectors": fan_board_data["counts"]["touchpoints"], "fuses": 4},
- "status": "success",
- }
- (out_dir / "import-report.json").write_text(json.dumps(import_report, indent=2) + "\n", encoding="utf-8")
- assets_meta: dict[str, dict[str, Any]] = {}
- for asset_file in (out_dir / name for name in (
- "board-data.json", "import-report.json", "board-mask-edge.svg",
- "board-mask-edge-back.svg", "board-copper.svg", "board-copper-back.svg",
- "board-silkscreen.svg", "board-silkscreen-back.svg",
- )):
- if asset_file.is_file():
- assets_meta[asset_file.name] = {
- "sha256": sha256_file(asset_file),
- "bytes": asset_file.stat().st_size,
- }
- build_info = {
- "schema": "board-viewer-build-info-v1",
- "generated_at": datetime.now(timezone.utc).isoformat(),
- "generator_version": "2.1.0",
- "toolchain": {"python": sys.version.split()[0], "kicad": "not_used"},
- "sources": {
- **_generator_sources(),
- "brd": {
- "path": "reference/original/board/FCB_FAN_V2.0_20260914/FCB_FAN_V2.0_20260914.brd",
- "sha256": sha256_file(brd_path),
- },
- "schema_data": {
- "path": "schemas/board_viewer_data.schema.json",
- "sha256": sha256_file(DATA_SCHEMA_PATH),
- },
- "schema_build_info": {
- "path": "schemas/board_viewer_build_info.schema.json",
- "sha256": sha256_file(BUILD_INFO_SCHEMA_PATH),
- },
- },
- "assets": assets_meta,
- "verification": {
- "ipcd356": {
- "status": "not_run",
- "reason": "No independent IPC-D-356 export or alignment comparison was executed by this BRD viewer generator.",
- },
- "side_views": {
- "front_layers": [
- "board-mask-edge.svg",
- "board-silkscreen.svg",
- "board-copper.svg",
- ],
- "back_layers": [
- "board-mask-edge-back.svg",
- "board-silkscreen-back.svg",
- "board-copper-back.svg",
- ],
- "back_mirror_axis": "y",
- "back_svg_export_mirrored": True,
- "convention": "Back SVGs are rendered by this script, mirrored about the vertical/Y axis; viewer hotspot X = board_width - view_position.x. Geometry is simplified, not a KiCad export.",
- },
- },
- "counts": {
- "footprints": fan_board_data["counts"]["footprints"],
- "touchpoints": fan_board_data["counts"]["touchpoints"],
- "pads": fan_board_data["counts"]["pads"],
- "resistors": 0,
- "resistor_pads": 0,
- },
- }
- build_info_schema = json.loads(BUILD_INFO_SCHEMA_PATH.read_text(encoding="utf-8"))
- Draft202012Validator(build_info_schema).validate(build_info)
- (out_dir / "build-info.json").write_text(json.dumps(build_info, indent=2) + "\n", encoding="utf-8")
- print(f"[V2.0-FAN] Asset generation complete! {len(assets_meta)} assets in {out_dir.name}")
- def main() -> None:
- generate_v2_0_mainboard()
- generate_v2_0_fan_board()
- print("\n[SUCCESS] Generated all V2.0 board viewer assets from Allegro BRD binaries!")
- if __name__ == "__main__":
- main()
|