factory-flashing

Provisions per-device cryptographic keys into STM32 devices during factory manufacture.

23|1|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/Alexey-Lukin/silken_net --skill factory-flashing-alexey-lukin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: factory-flashing
Source: https://github.com/Alexey-Lukin/silken_net/tree/main/.claude/skills/factory-flashing
Command: npx skills add https://github.com/Alexey-Lukin/silken_net --skill factory-flashing-alexey-lukin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Burning per-device keys into STM32 Soldier/Queen nodes at manufacture involves a fragile multi-step pipeline — silicon UID to DID derivation, wrong-board detection, HKDF key derivation, Flash block writes, and audit logging — where any mistake bricks the device or silently diverges keys between backend and silicon. ## Core Features & Use Cases - One-pass UID-to-DID derivation: Converts the 24-hex silicon UID into a wire DID via a single frozen function shared by factory and field provisioning, with collision detection routing units to quarantine. - Wrong-board guard and supervisor gate: Reads the board UID over SWD before any key write and refuses to run unless the provisioning session is supervisor-approved (2-Person Rule). - Six Flash key blocks with audit trail: Writes KEYL, LSED, KEYC, EDSK, KOTA, and KEYB blocks matching firmware addresses, then records a chain-hashed audit log inside one database transaction. - Use Case: When factory:flash raises a CollisionError or a backend DID does not match the silicon, use this Skill to trace the TreeResolver and UidReadout logic and diagnose whether it is a birthday collision, wrong chip, or endianness bug. ## Quick Start Ask the assistant to explain why factory:flash raised a CollisionError for a specific silicon UID and walk through the flashing session steps in order.

Frequently Asked Questions about factory-flashing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I provision keys into an STM32 at the factory?

Run the factory:flash rake task with the 24-hex silicon UID, which derives the DID, resolves or creates the Tree, and executes a supervised session. The session preflights the board UID, derives keys via HKDF, writes six Flash blocks over SWD, locks RDP, and records a chain-hashed audit log.

Why did factory:flash raise a CollisionError?

A CollisionError means the derived DID already exists but with a different silicon UID, indicating a birthday collision or wrong chip. The unit is routed to quarantine rather than reflashed; an identical UID is treated as a legitimate idempotent re-flash.

Why does the backend DID not match the STM32 silicon?

Mismatch usually comes from parsing the UID readout in the wrong word or byte order. The wire form is frozen as three %08X words in register order starting at 0x1FFF7590, and any reordering produces a different DID on the backend than on the silicon.

Can I use the SE05x secure element branch for provisioning?

No, the SE05x branch is emit-only today. The provisioner writes textual legacy ATECC calls with no real transport, so a unit flashed through it receives no Flash KEYL and bricks; treat any SE05x request as blocked until the SE050 eval-kit migration lands.

What happens if the Flash key layout drifts from firmware?

The device cannot read its own keys and fails at boot. CommandBuilder addresses and magics must mirror firmware FLASH_KEY_ADDR definitions, and each -w32 word is unpacked MSB-first, so changing one side requires changing both plus the host tests.