← Commit history
AI Flow 0.2.102: AVR ISP and JTAG programming (#244)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 files changed
+62−18
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-board", "serde",@@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.101"+version = "0.2.102" dependencies = [ "roxmltree", "serde",@@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-board", "serde",@@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-board", "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-board", "serde",@@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-board", "serde",@@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-board", "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.101"+version = "0.2.102" dependencies = [ "aiflow-board", "aiflow-grid",@@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.101"+version = "0.2.102" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.101"+version = "0.2.102" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/programming.rs+40−4@@ -16,6 +16,8 @@ const STEMS: &[&str] = &[ "STM32", "STM8", "GD32", "CH32", "APM32", "AT32", "ATMEGA", "ATTINY", "ATXMEGA", "ATSAM", "SAMD", "SAML", "SAME", "AVR", "PIC1", "PIC2", "PIC3", "DSPIC", "RP2040", "RP2350", "ESP32", "ESP8266", "NRF51", "NRF52", "NRF53", "NRF91", "MSP430", "MSPM0", "EFM32", "EFR32", "EFM8", "LPC8", "LPC1", "LPC5", "MKL", "MK2", "MK6", "MIMXRT", "CY8C", "PSOC", "TM4C", "CC13", "CC26", "R7FA", "RA4", "RA6", "XMC", "PY32", "ICE40", "ICE5", "LFE5", "LCMXO", "XC7", "XC6S", "10M0", "5CE", "GW1N", "GW2A",+ // issue #244: CPLDs and more FPGAs programmed over JTAG+ "EPM", "5M40", "5M80", "5M16", "5M24", "5M57", "5M12", "5M22", "EP4C", "EP2C", "EP3C", "10CL", "XC9", "XC2C", "XC3S", "XCKU", "XCZU", "LC4", "LCMXO2", "ATF15", "ATF22", "M2S", "M2GL", "A3P", "AGL", ]; /// The pins each interface needs at a machine contact or a labelled test pad (aliases after `|`).@@ -26,10 +28,17 @@ pub fn required(interface: &str) -> Option<&'static [&'static str]> { "usb-dfu" => Some(&["D+|DP|USB_DP", "D-|DM|USB_DM", "GND"]), // AVR 0/1/2-series (ATtiny, AVR-DA/DB/DD) and megaAVR 0: one-wire UPDI plus GND. "updi" => Some(&["UPDI", "GND"]),+ // issue #244: classic megaAVR/tinyAVR over the 6-pin Atmel ISP header (VCC sensed, not required here)+ "avr-isp" | "isp" => Some(&["MISO", "MOSI", "SCK", "RESET|RST|NRST", "GND"]),+ // issue #244: JTAG (a CPLD, an FPGA, an MCU's JTAG port); TRST is optional+ "jtag" => Some(&["TCK", "TMS", "TDI", "TDO", "GND"]), _ => None, } } +/// The interfaces `required` knows, for the message that names them.+pub const INTERFACES: &str = "swd, uart-boot, usb-dfu, updi, avr-isp or jtag";+ fn texts(fp: &aiflow_board::sx::Node) -> Vec<String> { let mut v = vec![fp.atom(1).unwrap_or("").to_string()]; for p in fp.find_all("property") {@@ -175,7 +184,7 @@ fn tag_connect_check(b: &Board, rec: &Value) -> Result<(), Vec<String>> { let target_ref = target_ref_of(b, rec); let target_ref = target_ref.as_str(); let iface = rec["interface"].as_str().unwrap_or("");- let Some(req) = required(iface) else { return Err(vec![format!("interface {iface:?} is not swd, uart-boot, usb-dfu or updi")]) };+ let Some(req) = required(iface) else { return Err(vec![format!("interface {iface:?} is not {INTERFACES}")]) }; // the evidence is the declared pads carrying the nets into the part (below), not the footprint's // name: a project-library pogo-pin pad set is as valid a cable landing as a TC2030 (as for usb-cable) if !b.footprints.contains_key(connector) || connector == target_ref {@@ -242,7 +251,7 @@ fn check_one(b: &Board, rec: &Value) -> Result<(), Vec<String>> { let iface = rec["interface"].as_str().unwrap_or(""); let pins = rec["pins"].as_object().cloned().unwrap_or_default(); match required(iface) {- None => p.push(format!("interface {iface:?} is not swd, uart-boot, usb-dfu or updi")),+ None => p.push(format!("interface {iface:?} is not {INTERFACES}")), Some(req) => for need in req { let alias: Vec<&str> = need.split('|').collect(); if !pins.keys().any(|k| alias.iter().any(|a| a.eq_ignore_ascii_case(k))) { p.push(format!("pins.{} missing", alias[0])); }@@ -382,6 +391,33 @@ mod tests { assert!(check("/nonexistent/b.kicad_pcb", &b, &uart).unwrap_err().iter().any(|e| e.contains("connectorPins.RX"))); } + /// Issue #244: an ATmega328P on a 2x3 AVR ISP header, and a CPLD on a JTAG header, are checked like UPDI.+ #[test]+ fn avr_isp_and_jtag_headers_are_programming_landings() {+ let board = |part: &str, nets: &[&str]| {+ let mut t = String::from("(kicad_pcb (version 20241229)\n (gr_rect (start 0 0) (end 30 20) (layer \"Edge.Cuts\") (width 0.1))\n");+ for (i, n) in nets.iter().enumerate() { t.push_str(&format!(" (net {} \"{n}\")\n", i + 1)); }+ t.push_str(&format!(" (footprint \"Package_QFP:TQFP-32\" (layer \"F.Cu\") (at 20 10) (property \"Reference\" \"U3\") (property \"Value\" \"{part}\")\n"));+ for (i, n) in nets.iter().enumerate() { t.push_str(&format!(" (pad \"{}\" smd rect (at {} 0) (size 0.3 1) (layers \"F.Cu\") (net {} \"{n}\"))\n", i + 1, i, i + 1)); }+ t.push_str(" )\n (footprint \"Connector:IDC-Header_2x03\" (layer \"F.Cu\") (at 5 10) (property \"Reference\" \"J1\")\n");+ for (i, n) in nets.iter().enumerate() { t.push_str(&format!(" (pad \"{}\" thru_hole circle (at {} 0) (size 1.7 1.7) (drill 1) (layers \"*.Cu\") (net {} \"{n}\"))\n", i + 1, i, i + 1)); }+ t.push_str(" )\n)\n");+ Board::from_text("/nonexistent/b.kicad_pcb", t).unwrap()+ };+ let pins = |names: &[(&str, &str)]| -> Value { let mut m = serde_json::Map::new(); for (i, (sig, net)) in names.iter().enumerate() { m.insert(sig.to_string(), json!({"pads": [format!("{}", i + 1)], "net": net})); } Value::Object(m) };+ let isp = [("MISO", "MISO"), ("SCK", "SCK"), ("RESET", "RESET"), ("GND", "GND"), ("MOSI", "MOSI")];+ let b = board("ATmega328P-AU", &["MISO", "SCK", "RESET", "GND", "MOSI"]);+ let rec = json!({"programming": {"interface": "avr-isp", "access": "cable", "connector": "J1", "targetRef": "U3", "target": "ATmega328P-AU", "connectorPins": pins(&isp)}});+ assert_eq!(check("/nonexistent/b.kicad_pcb", &b, &rec), Ok(()));+ let mut no_mosi = rec.clone(); no_mosi["programming"]["connectorPins"].as_object_mut().unwrap().remove("MOSI");+ assert!(check("/nonexistent/b.kicad_pcb", &b, &no_mosi).unwrap_err().iter().any(|e| e.contains("connectorPins.MOSI")));+ let jt = [("TCK", "TCK"), ("TMS", "TMS"), ("TDI", "TDI"), ("TDO", "TDO"), ("GND", "GND")];+ let c = board("EPM570T100C5N", &["TCK", "TMS", "TDI", "TDO", "GND"]);+ assert_eq!(targets(&c), vec![("U3".to_string(), "EPM570T100C5N".to_string())], "a MAX II CPLD is a programmable part");+ let jrec = json!({"programming": {"interface": "jtag", "access": "header", "connector": "J1", "target": "EPM570T100C5N", "connectorPins": pins(&jt)}});+ assert_eq!(check("/nonexistent/b.kicad_pcb", &c, &jrec), Ok(()));+ }+ #[test] fn programmable_boards_bring_their_interface_to_the_workcell() { let b = Board::from_text("/nonexistent/b.kicad_pcb", BOARD.to_string()).unwrap();@@ -405,8 +441,8 @@ mod tests { // a missing pin and an unknown interface spec["programming"]["pins"].as_object_mut().unwrap().remove("GND"); assert!(check("/nonexistent/b.kicad_pcb", &b2, &spec).unwrap_err().contains(&"pins.GND missing".to_string()));- spec["programming"]["interface"] = json!("jtag");- assert!(gate_message(&check("/nonexistent/b.kicad_pcb", &b2, &spec).unwrap_err()).starts_with("programming: interface \"jtag\" is not swd, uart-boot, usb-dfu or updi"));+ spec["programming"]["interface"] = json!("pdi");+ assert!(gate_message(&check("/nonexistent/b.kicad_pcb", &b2, &spec).unwrap_err()).starts_with("programming: interface \"pdi\" is not swd, uart-boot, usb-dfu, updi, avr-isp or jtag")); } #[test]
docs/release-0.2.102.mdadded+8@@ -0,0 +1,8 @@+# AI Flow 0.2.102++- **AVR ISP and JTAG programming** (#244, RobInMaine). The programming check accepts `"interface": "avr-isp"`+ (MISO, MOSI, SCK, RESET, GND: a classic megaAVR or tinyAVR on the 6-pin Atmel ISP header) and `"interface":+ "jtag"` (TCK, TMS, TDI, TDO, GND), checked like `updi`: each declared pad carries its net and every signal net+ reaches the part. CPLDs and more FPGA families (Intel MAX II/V and Cyclone, Xilinx CoolRunner, XC9500 and+ Spartan-3, Lattice ispMACH, Microchip ATF15xx, Microsemi IGLOO, ProASIC3 and SmartFusion2) count as+ programmable parts, so a JTAG-programmed CPLD is no longer "not a programmable part on the board".
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.101",+ "version": "0.2.102", "title": "AI Flow", "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.", "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",
page.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.101",+ "version": "0.2.102", "title": "AI Flow", "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.", "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",
skills/aiflow-molecule/SKILL.md+1−1@@ -201,6 +201,6 @@ Record it as `programming` in board-release.json beside the board (or `programmi {"interface": "swd", "pins": {"SWDIO": "J8", "SWCLK": "J9", "NRST": "J10", "GND": "J7"}, "target": "STM32G431CBT6", "boot": "BOOT0 low via R2; JP1 bridges for DFU"} ``` -`interface` is `swd`, `uart-boot` or `usb-dfu`; `pins` maps each interface signal to the reference that carries it; `target` is the MPN being programmed. A board programmed over its own USB connector instead (an ESP32-S3 or C3 with native USB Serial/JTAG) declares `"interface": "usb-serial-jtag", "access": "usb-cable"` with `connector` (the USB connector's reference), `targetRef` and `target` (the ESP32), `boot` (how to force download mode) and `connectorPins` mapping `D+`, `D-`, `GND` and `VBUS` to `{"pads": [...], "net": "..."}`; the check confirms those pads carry those four distinct nets, and no robot contacts are needed. `step schematic` and `step placement` print the Hint; `finish` lists it as an open item when a programmable part has no `programming` record, a required pin is missing, or a pin is not reachable (a machine contact, a labelled test pad or a cable header).+`interface` is `swd` (SWDIO, SWCLK, NRST optional, GND), `uart-boot` (TX, RX, GND), `usb-dfu` (D+, D-, GND), `updi` (UPDI, GND), `avr-isp` (MISO, MOSI, SCK, RESET, GND: a classic megaAVR or tinyAVR on the 6-pin ISP header) or `jtag` (TCK, TMS, TDI, TDO, GND: a CPLD, an FPGA or an MCU's JTAG port); `pins` maps each interface signal to the reference that carries it; `target` is the MPN being programmed. A board programmed over its own USB connector instead (an ESP32-S3 or C3 with native USB Serial/JTAG) declares `"interface": "usb-serial-jtag", "access": "usb-cable"` with `connector` (the USB connector's reference), `targetRef` and `target` (the ESP32), `boot` (how to force download mode) and `connectorPins` mapping `D+`, `D-`, `GND` and `VBUS` to `{"pads": [...], "net": "..."}`; the check confirms those pads carry those four distinct nets, and no robot contacts are needed. `step schematic` and `step placement` print the Hint; `finish` lists it as an open item when a programmable part has no `programming` record, a required pin is missing, or a pin is not reachable (a machine contact, a labelled test pad or a cable header). A board with several programmable parts (four MCUs, or an MCU beside an ESP32 on its own USB) records `programming` as a list, one record per interface, each naming the part(s) it programs with `targetRef` or `targetRefs` (their part number must be its `target`); `finish` lists a programmable part no record names as an open item. SWD over a Tag-Connect footprint (TC2030 / TC2050, or any project-library pad set made for a spring-pin cable: the pads and nets are the evidence, not the footprint's name) declares `"access": "tag-connect"` with `connector` (the Tag-Connect footprint), `targetRef`, `target` and `connectorPins` mapping `SWDIO`, `SWCLK`, `GND` and (when reset is wired) `NRST` to `{"pads": [...], "net": "..."}`; the check confirms the pads carry those nets and that the SWD nets reach the part, like the USB-cable record. A cable header (an STDC14 or ARM-10 SWD header for an ST-LINK or J-Link cable, a UART-boot or UPDI header) is the same record with `"access": "cable"` (or `"header"`): `connectorPins` maps that interface's signals (SWDIO, SWCLK, GND and optional NRST; TX, RX, GND; UPDI, GND), `targetRef` may be left out when the board has one programmable part, and `"pins": {"SWDIO": "J7.4", ...}` written as pads of one connector reads as the same header (each pad's net from the board).