dsh-plugin-stm32-workbench: Compile, Flash, and Debug STM32 within DSH Sessions

Preface

When doing STM32 development in DSH, the common practice is: agents call Keil, OpenOCD, and serial-port tools via shell or handwritten HTTP, with the UI and the agent each going their own way, so states easily drift out of sync. dsh-plugin-stm32-workbench turns the “MCU workbench” into a DSH plugin: after selecting a workspace and entering a “MCU mode” session, the workbench hangs inside the conversation view, and compilation, flashing, pins, and serial all share the same backend API with the mcu tool. Below is what it is, what it can do, and how to install and use it.

What This Is

dsh-plugin-stm32-workbench (repo Airls-bubble/dsh-plugin-stm32-workbench) is published by maintainer Airls-bubble and categorized as Workflow in the SkillHub directory. The current plugin version is 0.4.0, and the README states compatibility with DSH 0.2.1-rc.2 (2026-10-19/20).

In one sentence: a built-in STM32 workbench for DSH—Keil AC5 builds, ST-Link/OpenOCD flashing, pin planning, serial and functional contracts—targeted at scenarios where you write firmware in the Harness and want agents to call the same set of capabilities directly.

How It Mounts in DSH

The first version registered the panel into conversation.input.dock, which caused the workbench to appear under every conversation; the current implementation references the dsh-openwrite pattern:

  1. A “STM32 Workbench” entry at the bottom of the sidebar (slot id stm32.launch).
  2. Clicking it opens a project-directory picker → creates a workspace and session, and selects the preset id mcu via agentPresets (the “MCU mode” is registered by the plugin through ctx.agentPresets.register(), not dependent on handwritten profile patches).
  3. The workbench is registered as conversation.view, gated by watchScope: it mounts only when the main view session’s projectionValues.agentPreset is mcu.

The responsibility split between the two halves is as follows:

Half File Responsibility
Host index.js Registers the “MCU mode” preset; starts/stops the MCU backend; registers /mcu/state, /mcu/start, /mcu/stop, and /mcu/api/* proxies
Client client.js Sidebar entry, workspace picker dialog; workbench under gating (pin map, build panel, serial, calculator, etc.)
Backend backend/ Keil AC5 build, OpenOCD + ST-Link flashing, serial bridge; ships test firmware and BSP; portable OpenOCD is fetched on demand by scripts

Once a session is in MCU mode, the agent can build, flash, and read serial directly via the mcu tool registered by the host (the README documents 18 actions), sharing the /mcu routes with the UI.

Core Features

Build and Flash

  • The backend uses the Keil AC5 toolchain (armcc → armasm → armlink → fromelf) and supports opening your own .uvprojx projects; the README states artifacts can be byte-for-byte identical to Keil UV4 (with a verified example from a real graduation-project repo).
  • The flash path is OpenOCD + ST-Link; portable OpenOCD is not distributed with the repo and must be prepared locally.
  • The repo ships test projects such as firmware/projects; you can also smoke-test with just the projects bundled in the plugin package.

Keil Project Integration (HTTP API)

After a user project is hooked up, the backend exposes, for example (paths proxied via /mcu to backend /api):

  • POST /api/keil/open — open the project and keep state in-process
  • GET /api/keil/state — current project summary
  • GET /api/keil/pins — statically parse pin configuration
  • POST /api/keil/registers — register comparison between “source analysis vs actual chip”
  • POST /api/keil/build — build per the project, NDJSON streaming logs

Supporting modules include uvprojx.js (project parsing), keil-build.js (toolchain driver), pinmap.js (pin static analysis), regread.js (SWD register read), etc.

Agent Tool mcu

The host registers one tool with multiple actions in index.js; the README lists capabilities including status, open, scan, files, read, write, build, flash, size, pins, regs, chip, reset, spec, symbols, readmem, gfx, watch, etc. From 0.3.0, symbols / readmem / gfx were added; 0.4.0 adds watch and tightens output shapes for “AI token savings” (e.g., status gives the full picture in one shot, gfx baseline diffs, etc.).

The UI and the agent go through the same API, avoiding the “panel numbers disagree with script results” dual-track problem.

Workbench UI

The client provides panels such as pin map, build panel, and serial; design constraints include: no iframes, must use DSH theme tokens, must not import Harness client primitives packages, and resource registration must manage lifecycle via effects (see the repo README for details).

Installation and Activation

The plugin itself is about 1.8 MB of code (excluding portable OpenOCD). After getting the source from GitHub, prepare OpenOCD first (the repo does not commit the ~7.6 MB third-party binary):

powershell -ExecutionPolicy Bypass -File backend\scripts\fetch-openocd.ps1

The script downloads from the official xPack release and verifies sha256; generally it only needs to run once.

Install into DSH using the plugin manager command (replace the path with the absolute path where you placed this plugin on your machine):

plugin_manager: install_bundle target=<absolute path where you placed this plugin>

The README emphasizes: after modifying plugin code you must restart DSH; the loader does not hot-swap already-loaded package generations, and client resources may also require a page refresh.

Expected after it takes effect:

  • A “STM32 Workbench” appears at the bottom of the sidebar;
  • A “MCU mode” appears in the mode selector (registered by the plugin).

Environment requirement: engines.node in package.json is >=22. Cross-machine installation, prerequisites, and data-directory notes are in the repo’s PORTING.md.

Disable/rollback:

plugin_manager: set_bundle enabled=false target=dsh-plugin-stm32-workbench

Typical Usage

Enter an MCU Session from the Entry Point

  1. Click “STM32 Workbench” at the bottom of the sidebar.
  2. Select the directory containing the Keil project (or the plugin’s bundled test-project directory) as the workspace.
  3. After entering the new session, confirm the agent preset is “MCU mode” (mcu).
  4. In the session view’s workbench, build, flash, and observe serial; or in the conversation, let the agent call mcu tool actions such as build, flash, status.

Verify Keil Build Consistency (Reproducible Idea from the Repo)

The README suggests doing a reference build with Keil UV4 on a temporary copy, then comparing hex with the plugin’s output: if entries unique to Keil / unique to the plugin / byte differences at common addresses are all 0, the content is consistent. To locate differences, use the repo’s scripts/keil-param-experiment.js and scripts/keil-symdiff.js.

Where Data Lands

Runtime data is not written into the plugin installation directory (design goal: copying the plugin directory away should yield a clean copy):

  • Project-related: <Keil project directory>/.dsh-mcu/ (build cache, logs, backups, etc.; if the project is read-only it falls back to ~/.dsh/mcu/projects/<path hash>/).
  • Cross-project memory: ~/.dsh/mcu/recent.json (default DSH_HOME is ~/.dsh).

Use Cases and Notes

Who it’s for: Those already using DSH for embedded work or course/graduation STM32 projects (the README focuses on the STM32F103 ecosystem), who want the workbench, serial, and agent toolchain unified, and are willing to install Keil AC5, ST-Link, and download OpenOCD on demand locally.

Permissions and security: The plugin runs the backend with the current DSH process’s privileges (builds, writes side-by-side dirs next to the project, accesses debuggers). Before installing, read the repo source, the MIT License, and THIRD_PARTY_NOTICES.md (including CMSIS, ST Standard Peripheral Library, GPLv2 xPack OpenOCD, etc.).

Tested limitations (the README’s “to be verified” section records these faithfully): Without an ST-Link, the UI will show no device detected; flashing and serial require real-device verification. If there is no sidebar entry or the workbench does not mount, check the browser console for conversation.view slot crashes or [stm32-workbench] warnings.

Ecosystem note: The DSH community plugin directory is at SkillHub, with no official affiliation with DeepSeek / 幻方 (Hunyuan); facts in this article are based on the repo README and package.json.

Conclusion

dsh-plugin-stm32-workbench brings STM32 compilation, flashing, pins, and serial into DSH sessions and the mcu tool, reducing the “one set for UI, another for agent” fragmentation. Directory page: SkillHub - dsh-plugin-stm32-workbench; source and full documentation: GitHub - Airls-bubble/dsh-plugin-stm32-workbench.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye