From 8f5d5d39a030f7fc45ba4ecfecbef10b7f948a92 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 10:52:08 +0000 Subject: [PATCH] hardware: M2 screw-hole footprint for the W board; footprint script renamed Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013PRsUCpxazyipPn5UGGkF8 --- .github/workflows/hardware.yml | 2 +- hardware/README.md | 2 +- hardware/kicad/build_pcb.py | 18 ++++---------- .../{make_rm2_fp.py => make_footprints.py} | 24 +++++++++++++++++-- .../MountingHole_M2.kicad_mod | 15 ++++++++++++ 5 files changed, 44 insertions(+), 17 deletions(-) rename hardware/kicad/lib/{make_rm2_fp.py => make_footprints.py} (69%) create mode 100644 hardware/kicad/lib/pico-serial.pretty/MountingHole_M2.kicad_mod diff --git a/.github/workflows/hardware.yml b/.github/workflows/hardware.yml index e14fe05..6e86109 100644 --- a/.github/workflows/hardware.yml +++ b/.github/workflows/hardware.yml @@ -31,7 +31,7 @@ jobs: python3 hardware/netlist/build_netlist.py --variant $v python3 hardware/kicad/build_schematic.py --variant $v done - python3 hardware/kicad/lib/make_rm2_fp.py + python3 hardware/kicad/lib/make_footprints.py git diff --exit-code -- hardware/netlist hardware/kicad firmware/src/generated - name: ERC diff --git a/hardware/README.md b/hardware/README.md index 7033d67..36fbe0f 100644 --- a/hardware/README.md +++ b/hardware/README.md @@ -32,7 +32,7 @@ symbol and footprint libraries. KiCad 10 opens it too. | `kicad/render-top.png`, `render-bottom.png` | KiCad 3D renders, without part models (generated) | | `netlist/pico-serial-w.net`, `NETLIST-w.md`, `bom-jlc-w.csv` | The same for pico-serial W (generated) | | `kicad/pico-serial-w.*`, `preview-w.svg`, `render-w-*.png` | pico-serial W's schematic, PCB, rules and renders | -| `kicad/lib/make_rm2_fp.py` | Writes the RM2 footprint, `lib/pico-serial.pretty/`, from the datasheet's drawing | +| `kicad/lib/make_footprints.py` | Writes `lib/pico-serial.pretty/`: the RM2 (from its datasheet's drawing) and the M2 screw hole | | `kicad/fp-lib-table` | Points KiCad at `lib/pico-serial.pretty` | ## Regenerate diff --git a/hardware/kicad/build_pcb.py b/hardware/kicad/build_pcb.py index 53dcd6b..d8f7f83 100644 --- a/hardware/kicad/build_pcb.py +++ b/hardware/kicad/build_pcb.py @@ -493,25 +493,17 @@ def rf_keepout(board): def screw_holes(board): """The hood's M2 screws pass through the board: a plain hole each (a board-only footprint, so it isn't expected in the schematic), and a keep-out around it for - the screw head and the hood's bosses.""" + the screw head and the hood's bosses (lib/pico-serial.pretty/MountingHole_M2).""" import math for k, (x, y) in enumerate(SCREWS, 1): - fp = pcbnew.FOOTPRINT(board) - fp.SetReference(f"H{k}"); fp.SetValue("M2 screw") - fp.SetBoardOnly(True); fp.SetExcludedFromBOM(True); fp.SetExcludedFromPosFiles(True) - fp.Reference().SetVisible(False); fp.Value().SetVisible(False) - pad = pcbnew.PAD(fp) - pad.SetAttribute(pcbnew.PAD_ATTRIB_NPTH) - pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE) - pad.SetSize(pcbnew.VECTOR2I(mm(SCREW_HOLE), mm(SCREW_HOLE))) - pad.SetDrillSize(pcbnew.VECTOR2I(mm(SCREW_HOLE), mm(SCREW_HOLE))) - pad.SetLayerSet(pad.UnplatedHoleMask()) - fp.Add(pad) + fp = pcbnew.FootprintLoad(os.path.join(LOCAL_FP, "pico-serial.pretty"), "MountingHole_M2") + fp.SetFPID(pcbnew.LIB_ID("pico-serial", "MountingHole_M2")) + fp.SetReference(f"H{k}") fp.SetPosition(pcbnew.VECTOR2I(mm(x), mm(y))) board.Add(fp) r = SCREW_CLEAR / 2 rule_area(board, [(x + r * math.cos(2 * math.pi * i / 24), y + r * math.sin(2 * math.pi * i / 24)) - for i in range(24)], CU, footprints=True) + for i in range(24)], CU) # its courtyard keeps other parts out def crystal_keepout(board, fps): diff --git a/hardware/kicad/lib/make_rm2_fp.py b/hardware/kicad/lib/make_footprints.py similarity index 69% rename from hardware/kicad/lib/make_rm2_fp.py rename to hardware/kicad/lib/make_footprints.py index b0d4a6d..41206cd 100644 --- a/hardware/kicad/lib/make_rm2_fp.py +++ b/hardware/kicad/lib/make_footprints.py @@ -1,8 +1,10 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: CERN-OHL-S-2.0 # Copyright (C) 2026 Neo-Desktop -"""Writes pico-serial.pretty/RaspberryPi_RM2.kicad_mod from the RM2 datasheet -(Raspberry Pi Radio Module 2 datasheet, Figure 6 "PCB footprint"). +"""Writes the footprints KiCad doesn't ship into pico-serial.pretty/: + +RaspberryPi_RM2: from the RM2 datasheet (Raspberry Pi Radio Module 2, +Figure 6 "PCB footprint"). Origin: module centre. Antenna end toward -y (pins 1 and 21 nearest it). - 7 pads down each side, 1.5 mm pitch; lowest pad centres 1.8 mm above the @@ -62,3 +64,21 @@ for num, x, y, w, h in pads: out.append(')') here = os.path.dirname(os.path.abspath(__file__)) open(os.path.join(here, "pico-serial.pretty", "RaspberryPi_RM2.kicad_mod"), "w").write("\n".join(out) + "\n") + +# MountingHole_M2: a plain 2.3 mm hole for the W hood's M2 self-tapping +# screws. Board-only (no schematic symbol). The courtyard is the 5.4 mm +# circle kept free of copper and parts for the screw head and the hood's bosses. +HOLE, CLEAR = 2.3, 5.4 +mh = ['(footprint "MountingHole_M2"', '\t(version 20241229)', '\t(generator "pico-serial")', + '\t(generator_version "1")', '\t(layer "F.Cu")', + '\t(descr "M2 screw hole, unplated, 2.3 mm; 5.4 mm kept clear (pico-serial W hood)")', + '\t(tags "mounting hole M2")', + '\t(attr board_only exclude_from_pos_files exclude_from_bom)', + '\t(property "Reference" "H**" (at 0 -3.4 0) (layer "F.Fab") (effects (font (size 1 1) (thickness 0.15))))', + '\t(property "Value" "M2 screw" (at 0 3.4 0) (layer "F.Fab") (effects (font (size 1 1) (thickness 0.15))))', + f'\t(fp_circle (center 0 0) (end {CLEAR / 2:g} 0) (stroke (width 0.05) (type solid)) (fill no) (layer "F.CrtYd"))', + f'\t(fp_circle (center 0 0) (end {CLEAR / 2:g} 0) (stroke (width 0.05) (type solid)) (fill no) (layer "B.CrtYd"))', + f'\t(fp_circle (center 0 0) (end {HOLE / 2:g} 0) (stroke (width 0.1) (type solid)) (fill no) (layer "F.Fab"))', + f'\t(pad "" np_thru_hole circle (at 0 0) (size {HOLE:g} {HOLE:g}) (drill {HOLE:g}) (layers "*.Cu" "*.Mask"))', + ')'] +open(os.path.join(here, "pico-serial.pretty", "MountingHole_M2.kicad_mod"), "w").write("\n".join(mh) + "\n") diff --git a/hardware/kicad/lib/pico-serial.pretty/MountingHole_M2.kicad_mod b/hardware/kicad/lib/pico-serial.pretty/MountingHole_M2.kicad_mod new file mode 100644 index 0000000..631d09f --- /dev/null +++ b/hardware/kicad/lib/pico-serial.pretty/MountingHole_M2.kicad_mod @@ -0,0 +1,15 @@ +(footprint "MountingHole_M2" + (version 20241229) + (generator "pico-serial") + (generator_version "1") + (layer "F.Cu") + (descr "M2 screw hole, unplated, 2.3 mm; 5.4 mm kept clear (pico-serial W hood)") + (tags "mounting hole M2") + (attr board_only exclude_from_pos_files exclude_from_bom) + (property "Reference" "H**" (at 0 -3.4 0) (layer "F.Fab") (effects (font (size 1 1) (thickness 0.15)))) + (property "Value" "M2 screw" (at 0 3.4 0) (layer "F.Fab") (effects (font (size 1 1) (thickness 0.15)))) + (fp_circle (center 0 0) (end 2.7 0) (stroke (width 0.05) (type solid)) (fill no) (layer "F.CrtYd")) + (fp_circle (center 0 0) (end 2.7 0) (stroke (width 0.05) (type solid)) (fill no) (layer "B.CrtYd")) + (fp_circle (center 0 0) (end 1.15 0) (stroke (width 0.1) (type solid)) (fill no) (layer "F.Fab")) + (pad "" np_thru_hole circle (at 0 0) (size 2.3 2.3) (drill 2.3) (layers "*.Cu" "*.Mask")) +)