Skip to content

prog_flash: flash UPDI, PIC, C2, TPI and PDI chips from the SDK and MCP - #147

Merged
wardviaene merged 9 commits into
mainfrom
prog-flash-sdk
Nov 24, 2026
Merged

wardviaene merged 9 commits into
mainfrom
prog-flash-sdk

Conversation

@wardviaene

@wardviaene wardviaene commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Adds the pod's prog_flash (AVR UPDI, PIC ICSP, Silicon Labs C2, AVR TPI, XMEGA PDI) to the SDK and the MCP server, through the existing flash(). No new modes; no release cut. Pod firmware main with features revision 17 and the xip_prog blob are needed on the pod.

What changes

  • Feature map synced to revision 17: supports("prog_flash") works.
  • flash(file, target="avr-updi" | "pic" | "efm8" | "attiny-tpi" | "xmega", ...) (aliases updi, pic, c2, tpi, pdi). It reads the chip ID with the pod's info, matches it in the device table, cuts a .hex/.elf/.bin into the chip's memories (flash first, config last, partial pages padded with 0xFF), stages each with load_bin psram, starts each with expect_id (chip erase before the first region only when the image has flash), polls status with progress and maps every pod result and refusal to an error with a fix (ProgFlashError, ProgNoAnswerError, ProgLockedError, ProgVerifyError, ProgDeviceError).
  • New flash() arguments, documented in README and the MCP README: device, clk, data, reset_pin, erase (chip default, page, none), dry_run (enter programming mode and read the ID only). No new wiring-profile keys: pins come from arguments, then profile signals named for the protocol (UPDI, ICSPCLK/ICSPDAT, C2CK/C2D, TPICLK/TPIDATA, PDI_CLK/PDI_DATA, MCLR/RESET), then swd_swclk/swd_swdio; pic and attiny-tpi reset on the pod's reset pin by default.
  • MCP: the flash tool takes the targets and the new arguments; description, server instructions, README, tool snapshot updated.
  • Blobs: the SDK has no blob list or installer, so nothing to add; the XipUnavailableError text now covers xip_prog.
  • Docs: README section, error table, prog_devices.README.md, unreleased entries in both CHANGELOGs, API surface snapshot.

Device table for the CLI: prog_devices.json

Path: packages/embeddedci/src/embeddedci/benchpod/prog_devices.json (package data, plain JSON, one chip per line). Schema and sources: prog_devices.README.md next to it.

{ "schema": 1, "about": "...",
  "families": { "<proto: updi|pic|c2|tpi|pdi>": {
      "target": "avr-updi|pic|efm8|attiny-tpi|xmega", "title": "...",
      "ignore": [{"hex": int, "size": int, "name": str}],     # image regions left out (AVR lock bits, signature row)
      "devices": [{
         "name": str, "aliases": [str], "family": str,
         "id": "hex bytes of status.id, '??' = varies; matched as a prefix; expect_id = up to the first '??'",
         "mem": {"flash|eeprom|config|user": {"size": bytes, "page": bytes, "addr": int (pod address of byte 0),
                                              "hex": int (image address of byte 0), "align": int?, "stride": int?}},
         "opts": {"flags": int, "cp_addr": int},                  # extra fields of every start (cp_addr: PIC only)
         "vmin_mv": int, "vmax_mv": int, "erase_vmin_mv": int?, "vnote": str?, "notes": str?,
         "chip_erase_only": bool? } ] } } }

Pod address of image byte a = mem.addr + (a - mem.hex) / stride. 79 UPDI, 8 TPI, 38 XMEGA, 149 PIC (F and LF) and 14 C2 entries.

Tested

pytest packages/embeddedci (1558 passed), packages/embeddedci-mcp (258 passed), scripts (12 passed): unit tests on the repo's fake transport cover table loading and consistency, Intel HEX/ELF/bin parsing, splitting per family, the whole start/status flow, pins from arguments and the profile, and every error path (each pod result string, no answer, locked, verify, timeouts, unknown or wrong chip, 5 V-only chips, brown-out erase, missing feature, serial console). The OpenHTF package could not be run here. The e2e tier test_e2e_prog.py (marker prog) skips without a chip or the feature. No lint or type tooling is configured in the repo.

Needs a pod and a chip (nothing here ran on hardware)

  • Every protocol on a real chip, including the firmware's own open review items.
  • The device table was built from vendor documents and avrdude's part data, not hardware. Gaps are listed in prog_devices.README.md: no data EEPROM for PIC16 (hex layout unverified, a wrong layout would write silently), PIC16F1827/193x erase only by chip, C2 limited to EFM8 BB1/BB2/SB1/SB2/UB1/UB2 (BB3, LB1, UB3, C8051F not covered), the C2 derivative ID is not used, PIC Q41 and AVR DU/EA/EB/LA/SD left out.
  • Check on the first 6-bit PIC: the LVP key bit order (spec wording is ambiguous).

🤖 Generated with Claude Code

wardviaene and others added 9 commits November 23, 2026 17:35
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… routing for prog_flash targets

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…reset_pin, erase, dry_run); server instructions

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e (WIP)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ash targets

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r the feature)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… DUT output gets a message

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@wardviaene
wardviaene merged commit 0c6bfbd into main Nov 24, 2026
12 checks passed
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.

1 participant