Introduction

In DSH (DeepSeek Harness)’s plugin ecosystem, the development workflow for 51 microcontrollers typically involves Keil C51 compilation, Proteus simulation, and manual verification of LED states. Manual verification relies on vision models, can be affected by pin numbering drift, and produces unstable results. The dsh-mcu-lab plugin integrates this workflow into DSH sessions and provides deterministic verification signals (e.g., whether the build outputs a HEX file, whether CPU usage increases, or whether failure marker text appears), allowing the AI to complete the development loop directly within the conversation.

What Is It

This is a collection consisting of a DSH plugin (lib/index.js) and a command-line kernel (kernel/mcu_lab.py). The plugin layer is responsible for registering 5 tools with DSH, receiving AI parameters, and invoking the kernel; the kernel layer is written in Python and handles compilation, simulation, and verification logic.

The problem it solves is specific: it packages the operations that normally require manual decomposition—building HEX, copying it into the circuit, running the simulation, and inspecting results—into tools that the AI can directly call, outputting PASS/FAIL and the supporting verification evidence.

Core Features

This plugin provides the following core capabilities:

  1. 5 tools: mcu_run (default entry point), mcu_build (build only), mcu_sim (screenshot), mcu_verify (re-validation), mcu_list (index circuits).
  2. Command-line kernel: kernel/mcu_lab.py, supporting six subcommands: check, list, build, run, verify, and sim.
  3. Compiler support: supports Keil C51 and the free open-source SDCC.
  4. Simulation and verification: integrates Proteus ISIS simulation and provides a deterministic verification backend (without requiring a vision model).

Installation and Enablement

Method 1: Install into DSH (obtain the 5 tools)

  1. Place the repository: Put this repository in DSH’s profile module directory; the directory name must match the package name:
    <DSH_HOME>\profiles\node_modules\dsh-mcu-lab\
(`<DSH_HOME>` defaults to `%USERPROFILE%\.dsh`)
  1. Add the loading line: Add the following to the end of cordis.patch.yml for the corresponding profile:
    - insert:
      - id: mcu-lab
        name: 'dsh-mcu-lab'
  1. Restart DSH: After running dsh web to restart, the 5 tools will appear in the session.

Method 2: Use only the command-line kernel (no DSH dependency)

If you do not need DSH’s plugin layer, you can run the kernel script directly:

python kernel/mcu_lab.py check
python kernel/mcu_lab.py list
python kernel/mcu_lab.py build examples\led_blink.c
python kernel/mcu_lab.py run  examples\led_blink.c <你的电路.DSN> --wait 6
python kernel/mcu_lab.py verify <你的电路.DSN> --wait 6
python kernel/mcu_lab.py sim <你的电路.DSN> --seconds 8 --shot out.png

Typical Usage

Call tools directly in a session, for example:

Run examples/led_blink.c on this circuit and tell me whether it passes.

The corresponding command-line operations are:

  • Check the environment:
    python kernel/mcu_lab.py check
  • List available circuits:
    python kernel/mcu_lab.py list
  • Compile source code:
    python kernel/mcu_lab.py build examples\led_blink.c
  • Run simulation and verify:
    python kernel/mcu_lab.py run  examples\led_blink.c <你的电路.DSN> --wait 6
  • Verify circuit state only:
    python kernel/mcu_lab.py verify <你的电路.DSN> --wait 6
  • Generate simulation screenshot:
    python kernel/mcu_lab.py sim <你的电路.DSN> --seconds 8 --shot out.png

Prerequisites and Dependencies

This plugin targets Windows and requires the following conditions to be satisfied:

  • Operating system: Windows 11 (tested by the author); other platforms are not verified.
  • Compiler: Keil C51 (or SDCC). Keil-specific keywords need to be rewritten manually when using SDCC.
  • Simulation software: Proteus ISIS (the installation path should preferably be pure English; Chinese paths can cause crashes).
  • Python environment:
    • Recommended version: Python 3.13.15 (tested by the author).
    • Dependencies: build-only commands (check/list/build) use the standard library; simulation and verification commands (run/verify/sim) require pywin32 and Pillow.
  • Environment variables:
    • DSH_MCU_LAB_KEIL: points to C51.exe.
    • DSH_MCU_LAB_ISIS: points to ISIS.EXE.
    • DSH_MCU_LAB_IFACE: points to the interface script directory (default is kernel/iface/ in the repository).

Notes

  1. Directory naming: During installation, the directory name placed under node_modules must match the package name dsh-mcu-lab.
  2. Source code encoding: C51 source code must be pure ASCII; including Chinese comments will trigger a C141 syntax error.
  3. Deterministic verification: The verification logic relies on deterministic indicators such as whether the simulation process’s CPU usage increases, rather than reading screenshot pixels, so the results are stable.
  4. Unverified items: Specific version requirements for Keil C51 and Proteus ISIS have not been strictly verified; only the author’s tested environment is C51 9.00 and Proteus 7.08 SP2.