# lukenccode/vscodetostm32 architecture

> Architecture diagram of the GitHub repository lukenccode/vscodetostm32, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lukenccode/vscodetostm32
- Repository: https://github.com/lukenccode/vscodetostm32

## Overview

VscodeToStm32 is a VS Code extension for configuring, building, flashing, and debugging STM32 CMake projects. The main workflow starts with a user command: the extension loads project and machine settings, asks CMake Tools to build or locate firmware, then runs the selected probe backend; debugging instead writes a Cortex-Debug launch configuration and starts VS Code debugging. The graph includes documented chip selection and tool-path discovery. Some wiring is based on the README because the relevant source excerpts are incomplete.

Main entry points: [`extension.js`](https://github.com/lukenccode/vscodetostm32/blob/master/extension.js) (Command orchestration), [`src/backend.js`](https://github.com/lukenccode/vscodetostm32/blob/master/src/backend.js) (Probe dispatcher), [`src/probes.js`](https://github.com/lukenccode/vscodetostm32/blob/master/src/probes.js) (Probe commands), [`src/cmake.js`](https://github.com/lukenccode/vscodetostm32/blob/master/src/cmake.js) (CMake integration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Extension workflow"]
  node_extension["Command orchestration<br/>[extension.js]"]
end

subgraph group_configuration["Project configuration"]
  node_config["Config merge<br/>[config.js]"]
  node_project[("Project settings<br/>[project.js]")]
  node_devicepicker["Chip selection<br/>[devices.js]"]
  node_devicecatalog[("STM32 catalog<br/>[stm32-devices.json]")]
  node_toolpaths["Tool discovery<br/>[tools.js]"]
end

subgraph group_builddebug["Build and debug"]
  node_cmake["CMake integration<br/>[cmake.js]"]
  node_firmware["Build firmware"]
  node_staleness["Source freshness<br/>[staleness.js]"]
  node_launch["Debug config<br/>[launch.js]"]
end

subgraph group_probeops["Probe operations"]
  node_backend["Probe dispatcher<br/>[backend.js]"]
  node_probecommands["Probe commands<br/>[probes.js]"]
  node_targetlogic["Target mapping<br/>[target.js]"]
end

node_user(("User"))
node_jlink["J-Link tools"]
node_cube["CubeProgrammer"]
node_openocd["OpenOCD"]
node_vscode["VS Code APIs"]
node_cmaketools["CMake Tools"]
node_cortexdebug["Cortex-Debug"]

node_user -->|"runs commands"| node_extension
node_extension -->|"loads settings"| node_config
node_config -->|"reads project config"| node_project
node_extension -->|"writes project config"| node_project
node_extension -->|"selects chip"| node_devicepicker
node_devicepicker -->|"searches catalog"| node_devicecatalog
node_extension -->|"discovers tools"| node_toolpaths
node_extension -->|"builds and finds firmware"| node_cmake
node_cmake -->|"calls build API"| node_cmaketools
node_cmake -->|"produces or locates"| node_firmware
node_extension -->|"checks freshness"| node_staleness
node_extension -->|"dispatches probe action"| node_backend
node_extension -->|"passes firmware"| node_backend
node_backend -->|"resolves executable"| node_toolpaths
node_backend -->|"builds and runs commands"| node_probecommands
node_backend -->|"classifies probe output"| node_targetlogic
node_probecommands -->|"executes when selected"| node_jlink
node_probecommands -->|"executes when selected"| node_cube
node_probecommands -->|"executes when selected"| node_openocd
node_extension -->|"generates debug config"| node_launch
node_launch -->|"writes launch file"| node_project
node_extension -->|"starts debug session"| node_vscode
node_vscode -.->|"loads debug configuration"| node_cortexdebug

click node_extension "https://github.com/lukenccode/vscodetostm32/blob/master/extension.js"
click node_config "https://github.com/lukenccode/vscodetostm32/blob/master/src/config.js"
click node_project "https://github.com/lukenccode/vscodetostm32/blob/master/src/project.js"
click node_devicepicker "https://github.com/lukenccode/vscodetostm32/blob/master/src/devices.js"
click node_devicecatalog "https://github.com/lukenccode/vscodetostm32/blob/master/data/stm32-devices.json"
click node_toolpaths "https://github.com/lukenccode/vscodetostm32/blob/master/src/tools.js"
click node_cmake "https://github.com/lukenccode/vscodetostm32/blob/master/src/cmake.js"
click node_staleness "https://github.com/lukenccode/vscodetostm32/blob/master/src/staleness.js"
click node_launch "https://github.com/lukenccode/vscodetostm32/blob/master/src/launch.js"
click node_backend "https://github.com/lukenccode/vscodetostm32/blob/master/src/backend.js"
click node_probecommands "https://github.com/lukenccode/vscodetostm32/blob/master/src/probes.js"
click node_targetlogic "https://github.com/lukenccode/vscodetostm32/blob/master/src/target.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_extension,node_user toneBlue
class node_config,node_project,node_devicepicker,node_devicecatalog,node_toolpaths toneAmber
class node_cmake,node_firmware,node_staleness,node_launch,node_vscode toneMint
class node_backend,node_probecommands,node_targetlogic toneRose
class node_jlink,node_cube,node_openocd,node_cmaketools,node_cortexdebug toneIndigo
```

## Components

### Extension workflow

- [Command orchestration](https://github.com/lukenccode/vscodetostm32/blob/master/extension.js): `extension.js`

### Project configuration

- [Config merge](https://github.com/lukenccode/vscodetostm32/blob/master/src/config.js): `src/config.js`
- [Project settings](https://github.com/lukenccode/vscodetostm32/blob/master/src/project.js): `src/project.js`
- [Chip selection](https://github.com/lukenccode/vscodetostm32/blob/master/src/devices.js): `src/devices.js`
- [STM32 catalog](https://github.com/lukenccode/vscodetostm32/blob/master/data/stm32-devices.json): `data/stm32-devices.json`
- [Tool discovery](https://github.com/lukenccode/vscodetostm32/blob/master/src/tools.js): `src/tools.js`

### Build and debug

- [CMake integration](https://github.com/lukenccode/vscodetostm32/blob/master/src/cmake.js): `src/cmake.js`
- **Build firmware**
- [Source freshness](https://github.com/lukenccode/vscodetostm32/blob/master/src/staleness.js): `src/staleness.js`
- [Debug config](https://github.com/lukenccode/vscodetostm32/blob/master/src/launch.js): `src/launch.js`

### Probe operations

- [Probe dispatcher](https://github.com/lukenccode/vscodetostm32/blob/master/src/backend.js): `src/backend.js`
- [Probe commands](https://github.com/lukenccode/vscodetostm32/blob/master/src/probes.js): `src/probes.js`
- [Target mapping](https://github.com/lukenccode/vscodetostm32/blob/master/src/target.js): `src/target.js`

### Other components

- **User**
- **J-Link tools**
- **CubeProgrammer**
- **OpenOCD**
- **VS Code APIs**
- **CMake Tools**
- **Cortex-Debug**

## Connections

- User → Command orchestration: runs commands
- Command orchestration → Config merge: loads settings
- Config merge → Project settings: reads project config
- Command orchestration → Project settings: writes project config
- Command orchestration → Chip selection: selects chip
- Chip selection → STM32 catalog: searches catalog
- Command orchestration → Tool discovery: discovers tools
- Command orchestration → CMake integration: builds and finds firmware
- CMake integration → CMake Tools: calls build API
- CMake integration → Build firmware: produces or locates
- Command orchestration → Source freshness: checks freshness
- Command orchestration → Probe dispatcher: dispatches probe action
- Command orchestration → Probe dispatcher: passes firmware
- Probe dispatcher → Tool discovery: resolves executable
- Probe dispatcher → Probe commands: builds and runs commands
- Probe dispatcher → Target mapping: classifies probe output
- Probe commands → J-Link tools: executes when selected
- Probe commands → CubeProgrammer: executes when selected
- Probe commands → OpenOCD: executes when selected
- Command orchestration → Debug config: generates debug config
- Debug config → Project settings: writes launch file
- Command orchestration → VS Code APIs: starts debug session
- VS Code APIs → Cortex-Debug: loads debug configuration
