Skip to content

fix(templates): name symbols and pins that exist in KiCad 10 (#783) - #867

Open
YORROY123 wants to merge 1 commit into
mixelpixx:mainfrom
YORROY123:fix/templates-real-symbols-783
Open

YORROY123 wants to merge 1 commit into
mixelpixx:mainfrom
YORROY123:fix/templates-real-symbols-783

Conversation

@YORROY123

Copy link
Copy Markdown

Summary

Two bundled templates could not be applied on KiCad 10 at all, and four templates sent the agent to pins their symbols do not have. This fixes every template's symbol and pin names, gives ldo_3v3 and stm32_minimal the content #783 asks for, and adds a test that checks the templates against the installed KiCad library.

Closes #783

Measured on main @ 9488e5f, applying each bundled template to a fresh copy of tests/fixtures/derived_lib_name.kicad_sch (KiCad 10.0.6, Windows 11):

template before after
usb_c_5v_sink refused: Connector:USB_C_Receptacle_USB2.0 not found placed
stm32_minimal refused: Connector:Conn_ARM_SWD_10 not found placed
ldo_3v3, i2c_pullups, led_indicator, buck_converter placed placed

kicad-cli sch export netlist loads every result; the stm32_minimal netlist lists all 15 template parts with their pins.

The new test, run against the unchanged templates, reports:

usb_c_5v_sink: Connector:USB_C_Receptacle_USB2.0 is not in the KiCad library
ldo_3v3: U.VIN — Regulator_Linear:AMS1117-3.3 has no pin VIN
ldo_3v3: U.VOUT — Regulator_Linear:AMS1117-3.3 has no pin VOUT
stm32_minimal: Connector:Conn_ARM_SWD_10 is not in the KiCad library
stm32_minimal: U.OSC_IN — MCU_ST_STM32F4:STM32F411CEUx has no pin OSC_IN
stm32_minimal: U.OSC_OUT — MCU_ST_STM32F4:STM32F411CEUx has no pin OSC_OUT
stm32_minimal: U.SWDIO — MCU_ST_STM32F4:STM32F411CEUx has no pin SWDIO
stm32_minimal: U.SWCLK — MCU_ST_STM32F4:STM32F411CEUx has no pin SWCLK
buck_converter: U.FB — Regulator_Switching:TPS563200 has no pin FB
buck_converter: U.BOOT — Regulator_Switching:TPS563200 has no pin BOOT

Three of these were not listed in #783: the USB-C symbol name and the TPS563200 FB/BOOT pins (VFB/VBST).

Approach

Symbol and pin names. USB_C_Receptacle_USB2.0 → USB_C_Receptacle_USB2.0_16P; Conn_ARM_SWD_10 → Conn_ARM_JTAG_SWD_10; STM32 pins by name (PH0, PH1, PA13, PA14); U.FB/U.BOOT → U.VFB/U.VBST.

ldo_3v3. AMS1117 with a 10 µF ceramic output contradicted the template's own note. It now uses AP2112K-3.3, as #783 suggests. The values below come from the Diodes datasheet (DS39724 Rev. 2-2):

  • It is stable with 1 µF ceramic capacitors on input and output, so the template lists two 1 µF capacitors.
  • EN has an internal 3 MΩ pull-down, so it is mapped to VIN. Left open, the regulator stays off.
  • The design notes give the 6.5 V absolute maximum input. On a hot-plugged USB input, cable inductance rings with a small input capacitor and can overshoot that limit.
  • Dropout is 250 mV typical and 400 mV max at 600 mA.

stm32_minimal. Every item in #783's acceptance list:

  • VCAP1 4.7 µF, ESR < 1 Ω
  • BOOT0 and PB2 each pulled down with 10 kΩ
  • VBAT, VSSA and VCAP1 mapped
  • four 100 nF capacitors: one per VDD pin (3) plus VDDA
  • a connection for every capacitor and resistor
  • ST's 10 pF Cstray estimate

The SWD header's ~{RESET}, VTref, GND and GNDDetect are mapped too. The VCAP and Cstray values follow the datasheet references in #783. st.com refused automated downloads, so I could not re-read DS10314 myself.

Capacitor and resistor endpoints use the template-local convention that i2c_pullups and led_indicator already use (C8.1 = the eighth capacitor in component-list order). The design notes say so, because apply_template numbers parts from the schematic's next free reference.

Test. builtin_templates_name_symbols_and_pins_that_exist_in_kicad checks every bundled template:

  • Each lib_id must resolve through KiCadSymbolSource and resolve_lib_symbol_flattened_node.
  • Each from/to endpoint of the form PREFIX[N].PIN must match a pin name, number or alternate of that part's symbol. A symbol that resolves with no pins also fails, so the check cannot pass vacuously.

When no KiCad library is installed the test skips, unless KICAD_CLI is set. In that case it fails, so the E2E job cannot skip it silently. A step in e2e-kicad.yml runs it there.

Architectural fit

This uses the existing symbol resolution that apply_template itself places parts with. No new mechanism or workaround is added.

Exclusions:

Branch and dependencies

Base branch: main @ 9488e5f. No dependencies. Not part of a series. This PR owns all of #783's acceptance criteria.

Compatibility and safety

  • Template content changes: ldo_3v3 places AP2112K-3.3 and two capacitors instead of AMS1117-3.3 and four. A caller that hard-coded the old part list for ldo_3v3 sees different parts.
  • No schema, tool or file-format change.

Validation

Changed tool behavior

Behavior Contract and evidence for this change
Accepted inputs and declared defaults Unchanged.
Invalid/unsupported inputs and structured errors Unchanged. Before this change, usb_c_5v_sink and stm32_minimal hit the existing "not found in library" error.
Target, data source and prerequisite state Unchanged; the template data is what changed.
Observed changes and preserved unrelated objects All six bundled templates apply to the fixture; kicad-cli loads each result.
Failure before/after mutation, including applied work Unchanged; placement remains all-or-nothing.
Recovery from partial/uncertain results without repeating applied work Unchanged.

Windows 11, KiCad 10.0.6 installed:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p konnect-core --all-targets --locked -- -D warnings: clean
  • cargo test -p konnect-core --locked --lib: 1657 passed, 23 failed, 21 ignored. The same 23 tests fail on unchanged main @ 9488e5f on this machine (pcb_components, sch_components, schematic_placement_tests, library::symbol_source_tests). The list was compared line by line and is identical, so the failures are environmental. The new test is the one extra pass.
  • cargo test -p konnect-core --locked --test integration_test --test conformance_test: 16 passed
  • cargo test -p konnect-core --locked --doc: ok
  • The whole workspace was not run locally; CI covers it.

…xx#783)

Two bundled templates could not be applied at all on KiCad 10, and four
mapped pins that their symbols do not have:

- usb_c_5v_sink placed Connector:USB_C_Receptacle_USB2.0 and stm32_minimal
  placed Connector:Conn_ARM_SWD_10; neither exists, so apply_template
  refused both templates.
- ldo_3v3 mapped U.VIN/U.VOUT on AMS1117-3.3 (pins VI/VO), stm32_minimal
  mapped OSC_IN/OSC_OUT/SWDIO/SWCLK (pins PH0/PH1/PA13/PA14), and
  buck_converter mapped FB/BOOT on TPS563200 (pins VFB/VBST).

ldo_3v3 now uses AP2112K-3.3 with 1uF ceramic capacitors, which its
datasheet states is stable, ties EN to VIN (EN has a 3M pull-down), and
maps both capacitors. stm32_minimal gets VCAP1 4.7uF, BOOT0 and PB2
pull-downs, VBAT/VSSA/VCAP1 mapped, a connection for every capacitor,
four 100nF for the three VDD pins plus VDDA, and ST's 10pF Cstray
estimate.

A test resolves every component of every bundled template against the
installed KiCad library and checks every mapped pin against the symbol's
pin names, numbers and alternates. It skips without KiCad and runs in the
E2E workflow, which installs it.
@YORROY123
YORROY123 requested a review from mixelpixx as a code owner October 10, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Templates: stm32_minimal cannot be applied on KiCad 10 and is wrong for its MCU; ldo_3v3 contradicts its own note

1 participant