@turingcode/cli 0.2.13 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cli/create-cli.d.ts +10 -0
- package/dist/cli/create-cli.js +12 -1
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +5 -1
- package/dist/core/bound-error.d.ts +10 -0
- package/dist/core/date.d.ts +12 -0
- package/dist/core/exact/expression.d.ts +49 -0
- package/dist/core/exact/fraction.d.ts +85 -0
- package/dist/core/files.d.ts +44 -0
- package/dist/core/files.js +46 -1
- package/dist/core/json-shape.d.ts +45 -0
- package/dist/core/mcp.d.ts +92 -0
- package/dist/core/mcp.js +56 -15
- package/dist/core/query.d.ts +69 -0
- package/dist/core/report.d.ts +11 -0
- package/dist/core/tables/csv.d.ts +18 -0
- package/dist/core/tables/markdown.d.ts +22 -0
- package/dist/core/tables/types.d.ts +25 -0
- package/dist/features/contract/check.d.ts +30 -0
- package/dist/features/contract/command.d.ts +12 -0
- package/dist/features/contract/command.js +64 -64
- package/dist/features/contract/describe.d.ts +22 -0
- package/dist/features/contract/diagnostics.d.ts +108 -0
- package/dist/features/contract/load.d.ts +58 -0
- package/dist/features/contract/model.d.ts +67 -0
- package/dist/features/contract/rules.d.ts +137 -0
- package/dist/features/debug/clear_breakpoint.d.ts +2 -0
- package/dist/features/debug/clear_breakpoint.js +24 -0
- package/dist/features/debug/command.d.ts +5 -0
- package/dist/features/debug/command.js +66 -0
- package/dist/features/debug/continue.d.ts +2 -0
- package/dist/features/debug/continue.js +22 -0
- package/dist/features/debug/debug_start.d.ts +2 -0
- package/dist/features/debug/debug_start.js +22 -0
- package/dist/features/debug/debug_stop.d.ts +2 -0
- package/dist/features/debug/debug_stop.js +11 -0
- package/dist/features/debug/evaluate.d.ts +2 -0
- package/dist/features/debug/evaluate.js +48 -0
- package/dist/features/debug/get_stack.d.ts +2 -0
- package/dist/features/debug/get_stack.js +14 -0
- package/dist/features/debug/get_variables.d.ts +2 -0
- package/dist/features/debug/get_variables.js +26 -0
- package/dist/features/debug/halt.d.ts +2 -0
- package/dist/features/debug/halt.js +16 -0
- package/dist/features/debug/set_breakpoint.d.ts +2 -0
- package/dist/features/debug/set_breakpoint.js +30 -0
- package/dist/features/debug/step.d.ts +2 -0
- package/dist/features/debug/step.js +23 -0
- package/dist/features/install-mods/command.d.ts +6 -0
- package/dist/features/install-mods/command.js +18 -0
- package/dist/features/install-mods/install.d.ts +23 -0
- package/dist/features/install-mods/install.js +48 -0
- package/dist/features/install-skills/command.d.ts +7 -0
- package/dist/features/install-skills/command.js +22 -0
- package/dist/features/install-skills/install.d.ts +13 -0
- package/dist/features/install-skills/install.js +29 -0
- package/dist/features/probe/command.d.ts +5 -0
- package/dist/features/probe/command.js +44 -0
- package/dist/features/probe/kill_all_debuggers.d.ts +2 -0
- package/dist/features/probe/kill_all_debuggers.js +50 -0
- package/dist/features/probe/list_probes.d.ts +2 -0
- package/dist/features/probe/list_probes.js +8 -0
- package/dist/features/probe/program_project.d.ts +2 -0
- package/dist/features/probe/program_project.js +29 -0
- package/dist/features/probe/read_fault_status.d.ts +2 -0
- package/dist/features/probe/read_fault_status.js +19 -0
- package/dist/features/probe/read_memory.d.ts +2 -0
- package/dist/features/probe/read_memory.js +36 -0
- package/dist/features/probe/read_peripheral.d.ts +2 -0
- package/dist/features/probe/read_peripheral.js +58 -0
- package/dist/features/probe/reset_probe_usb.d.ts +2 -0
- package/dist/features/probe/reset_probe_usb.js +17 -0
- package/dist/features/probe/reset_target.d.ts +2 -0
- package/dist/features/probe/reset_target.js +16 -0
- package/dist/features/probe/target_info.d.ts +2 -0
- package/dist/features/probe/target_info.js +34 -0
- package/dist/features/project/analysis_static.d.ts +2 -0
- package/dist/features/project/analysis_static.js +19 -0
- package/dist/features/project/analysis_syntax_check.d.ts +2 -0
- package/dist/features/project/analysis_syntax_check.js +21 -0
- package/dist/features/project/command.d.ts +5 -0
- package/dist/features/project/command.js +64 -0
- package/dist/features/project/project_build.d.ts +2 -0
- package/dist/features/project/project_build.js +22 -0
- package/dist/features/project/project_download_template.d.ts +2 -0
- package/dist/features/project/project_download_template.js +34 -0
- package/dist/features/project/project_regenerate.d.ts +2 -0
- package/dist/features/project/project_regenerate.js +20 -0
- package/dist/features/project/project_sync_from_server.d.ts +2 -0
- package/dist/features/project/project_sync_from_server.js +13 -0
- package/dist/features/project/project_sync_to_server.d.ts +2 -0
- package/dist/features/project/project_sync_to_server.js +51 -0
- package/dist/features/project/stm32_cubetools_download_drivers.d.ts +2 -0
- package/dist/features/project/stm32_cubetools_download_drivers.js +19 -0
- package/dist/features/status/command.d.ts +2 -0
- package/dist/features/status/command.js +6 -0
- package/dist/features/status/get_status.d.ts +2 -0
- package/dist/features/status/get_status.js +44 -0
- package/dist/features/table/check.d.ts +38 -0
- package/dist/features/table/command.d.ts +3 -0
- package/dist/features/table/read.d.ts +28 -0
- package/dist/features/tool/command.d.ts +35 -0
- package/dist/lib.d.ts +11 -0
- package/dist/lib.js +9 -0
- package/dist/stm32/actions/DebugAction.d.ts +63 -0
- package/dist/stm32/actions/DebugAction.js +105 -0
- package/dist/stm32/actions/DebugActionInfo.d.ts +7 -0
- package/dist/stm32/actions/DebugActionInfo.js +9 -0
- package/dist/stm32/actions/DebugActionListProbes.d.ts +9 -0
- package/dist/stm32/actions/DebugActionListProbes.js +10 -0
- package/dist/stm32/actions/DebugActionProgram.d.ts +28 -0
- package/dist/stm32/actions/DebugActionProgram.js +79 -0
- package/dist/stm32/actions/DebugActionRead.d.ts +38 -0
- package/dist/stm32/actions/DebugActionRead.js +59 -0
- package/dist/stm32/actions/DebugActionReset.d.ts +11 -0
- package/dist/stm32/actions/DebugActionReset.js +9 -0
- package/dist/stm32/actions/DebugActionServer.d.ts +7 -0
- package/dist/stm32/actions/DebugActionServer.js +9 -0
- package/dist/stm32/analysis.d.ts +19 -0
- package/dist/stm32/analysis.js +21 -0
- package/dist/stm32/build.d.ts +34 -0
- package/dist/stm32/build.js +79 -0
- package/dist/stm32/context.d.ts +23 -0
- package/dist/stm32/context.js +42 -0
- package/dist/stm32/daemon.d.ts +63 -0
- package/dist/stm32/daemon.js +202 -0
- package/dist/stm32/regen.d.ts +68 -0
- package/dist/stm32/regen.js +225 -0
- package/dist/stm32/session.d.ts +134 -0
- package/dist/stm32/session.js +374 -0
- package/dist/stm32/sync.d.ts +24 -0
- package/dist/stm32/sync.js +72 -0
- package/dist/stm32/tool.d.ts +43 -0
- package/dist/stm32/tool.js +20 -0
- package/dist/stm32/toolCommand.d.ts +50 -0
- package/dist/stm32/toolCommand.js +102 -0
- package/dist/stm32/utils/discover_tools.d.ts +24 -0
- package/dist/stm32/utils/discover_tools.js +121 -0
- package/dist/stm32/utils/downloadzip_utils.d.ts +57 -0
- package/dist/stm32/utils/downloadzip_utils.js +180 -0
- package/dist/stm32/utils/faultUtils.d.ts +14 -0
- package/dist/stm32/utils/faultUtils.js +69 -0
- package/dist/stm32/utils/findElf.d.ts +9 -0
- package/dist/stm32/utils/findElf.js +19 -0
- package/dist/stm32/utils/hash_utils.d.ts +19 -0
- package/dist/stm32/utils/hash_utils.js +28 -0
- package/dist/stm32/utils/listSyncFiles.d.ts +9 -0
- package/dist/stm32/utils/listSyncFiles.js +98 -0
- package/dist/stm32/utils/mcu_utils.d.ts +59 -0
- package/dist/stm32/utils/mcu_utils.js +99 -0
- package/dist/stm32/utils/project_utils.d.ts +54 -0
- package/dist/stm32/utils/project_utils.js +102 -0
- package/dist/stm32/utils/svdUtils.d.ts +31 -0
- package/dist/stm32/utils/svdUtils.js +30 -0
- package/dist/stm32/utils/truncate.d.ts +7 -0
- package/dist/stm32/utils/truncate.js +9 -0
- package/dist/stm32/utils/usb_utils.d.ts +5 -0
- package/dist/stm32/utils/usb_utils.js +23 -0
- package/dist/stm32/utils/user_code.d.ts +14 -0
- package/dist/stm32/utils/user_code.js +43 -0
- package/dist/stm32/utils/utils_mutex.d.ts +15 -0
- package/dist/stm32/utils/utils_mutex.js +93 -0
- package/dist/stm32/validate.d.ts +16 -0
- package/dist/stm32/validate.js +46 -0
- package/mods/claude/.claude-plugin/marketplace.json +8 -0
- package/mods/claude/turingcode-skills/.claude-plugin/plugin.json +5 -0
- package/mods/claude/turingcode-skills/skills/turingcode-cli/SKILL.md +50 -0
- package/mods/claude/turingcode-skills/skills/turingcode-cli/references/board-and-debug.md +22 -0
- package/mods/claude/turingcode-skills/skills/turingcode-cli/references/build-and-check.md +19 -0
- package/mods/claude/turingcode-skills/skills/turingcode-cli/references/new-project.md +9 -0
- package/mods/claude/turingcode-skills/skills/turingcode-firmware-code/SKILL.md +43 -0
- package/mods/claude/turingcode-skills/skills/turingcode-firmware-code/references/concurrency.md +42 -0
- package/mods/claude/turingcode-skills/skills/turingcode-firmware-code/references/init-and-timing.md +35 -0
- package/mods/claude/turingcode-skills/skills/turingcode-firmware-code/references/input-and-bounds.md +34 -0
- package/mods/claude/turingcode-skills/skills/turingcode-firmware-code/references/registers-and-units.md +35 -0
- package/package.json +11 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { callServer } from '../../stm32/context.js';
|
|
2
|
+
import { downloadAndUnzip, zipLink } from '../../stm32/utils/downloadzip_utils.js';
|
|
3
|
+
import { _defineTool } from '../../stm32/tool.js';
|
|
4
|
+
import { findStm32Project } from '../../stm32/utils/project_utils.js';
|
|
5
|
+
import { getMcuFromIoc } from '../../stm32/utils/mcu_utils.js';
|
|
6
|
+
// Restores the project's Drivers/ files from the server's copy for the .ioc's MCU; existing files are kept.
|
|
7
|
+
export default _defineTool({
|
|
8
|
+
name: 'stm32_cubetools_download_drivers',
|
|
9
|
+
description: 'Restore missing Drivers/ files (CMSIS, HAL) of your local stm32 project: downloads the complete Drivers/ folder ' +
|
|
10
|
+
'STM32CubeMX makes for the MCU in the .ioc and adds the files the project lacks; existing files are not overwritten. ' +
|
|
11
|
+
'The project is the folder with a .ioc or .mxproject file inside the project folder (the nearest folder holding .turingcode/ or a .ioc file, else the working directory); fails if there are several.',
|
|
12
|
+
run: async () => {
|
|
13
|
+
const project = await findStm32Project();
|
|
14
|
+
const mcu = await getMcuFromIoc(project.root);
|
|
15
|
+
const text = await callServer('stm32_cubetools_download_drivers', { mcu }, 125_000);
|
|
16
|
+
await downloadAndUnzip(zipLink(text), project.root, false); // throws with the server reply when it has no zip link
|
|
17
|
+
return `Restored missing Drivers/ files for ${mcu} into ${project.root}`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { toolCommand } from "../../stm32/toolCommand.js";
|
|
2
|
+
import getStatus from "./get_status.js";
|
|
3
|
+
const command = toolCommand({ command: "status", tool: getStatus, mode: "local", examples: [
|
|
4
|
+
["$0 status", "project, last build, debug session and installed debug tools"],
|
|
5
|
+
] });
|
|
6
|
+
export default command;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DEFAULT_URL } from "../../core/mcp.js";
|
|
2
|
+
import { cliVersion } from "../../stm32/context.js";
|
|
3
|
+
import { _defineTool } from "../../stm32/tool.js";
|
|
4
|
+
import { findElf } from "../../stm32/utils/findElf.js";
|
|
5
|
+
import { discover_system_tools } from "../../stm32/utils/discover_tools.js";
|
|
6
|
+
import { findProject, findStm32Project } from "../../stm32/utils/project_utils.js";
|
|
7
|
+
import { scanUserSections } from "../../stm32/utils/user_code.js";
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
// Reports the CLI, server token, project, its newest built ELF, debug session and hardware tool state.
|
|
11
|
+
export default _defineTool({
|
|
12
|
+
name: "get_status",
|
|
13
|
+
description: "Check the server token, project and hardware tool setup: current project and STM32 project, its newest .elf in build/, debug session, USER CODE section mismatches in Core/Src/main.c and Core/Inc/main.h, and the installed debug tools (probe-rs, STM32_Programmer_CLI, STM32CubeIDE, STM32CubeMX).",
|
|
14
|
+
run: async (_args, ctx) => {
|
|
15
|
+
const p = await findProject(ctx.cwd);
|
|
16
|
+
const stm = await findStm32Project(ctx.cwd).catch((e) => e);
|
|
17
|
+
const stmText = stm instanceof Error ? `none (${stm.message})` : `${stm.name} (${stm.root})`;
|
|
18
|
+
const elf = stm instanceof Error ? undefined : await findElf(stm.root);
|
|
19
|
+
const build = elf ? `${elf.path} (${elf.mtime.toISOString()})` : "none";
|
|
20
|
+
const tools = await discover_system_tools(true);
|
|
21
|
+
const userCode = await Promise.all(["Core/Src/main.c", "Core/Inc/main.h"].map(async (f) => {
|
|
22
|
+
const text = stm instanceof Error ? undefined : await readFile(join(stm.root, f), "utf8").catch(() => undefined);
|
|
23
|
+
if (text === undefined)
|
|
24
|
+
return ` ${f}: not found`;
|
|
25
|
+
const { sections, errors } = scanUserSections(text);
|
|
26
|
+
if (!errors.length)
|
|
27
|
+
return ` ${f}: ${sections.length} sections, ok`;
|
|
28
|
+
return [` ${f}: ${errors.length} mismatch(es)`, ...errors.map((e) => ` ${e}`)].join("\n");
|
|
29
|
+
}));
|
|
30
|
+
return [
|
|
31
|
+
`turingcode ${cliVersion()}`,
|
|
32
|
+
`Server: ${process.env.TURINGCODE_URL || DEFAULT_URL}`,
|
|
33
|
+
`Token: ${process.env.TURINGCODE_TOKEN?.trim() ? "set" : "missing, set TURINGCODE_TOKEN"}`,
|
|
34
|
+
`Project: ${p.name} (${p.root})`,
|
|
35
|
+
`STM32 project: ${stmText}`,
|
|
36
|
+
`Last build: ${build}`,
|
|
37
|
+
`Debug session: ${ctx.debugActive() ? `active (probe owned by the debug daemon, ${ctx.socketPath})` : "none"}`,
|
|
38
|
+
"USER CODE sections:",
|
|
39
|
+
...userCode,
|
|
40
|
+
`Debug tools: ${tools.length ? "" : "none found (install probe-rs from https://probe.rs, or STM32CubeProgrammer)"}`,
|
|
41
|
+
...tools.map((t) => ` ${t.id}: ${t.path}`),
|
|
42
|
+
].join("\n");
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Diagnostic } from "../contract/diagnostics.js";
|
|
2
|
+
export interface TableCheckInput {
|
|
3
|
+
/** Contract file. */
|
|
4
|
+
contract: string;
|
|
5
|
+
/** Markdown file, folder of `<Table>.csv`, or one `<Table>.csv`. */
|
|
6
|
+
tables: string;
|
|
7
|
+
/** Dependency alias -> its tables file. */
|
|
8
|
+
deps?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface TableCheckResult {
|
|
11
|
+
status: "PASS" | "FAIL" | "INVALID_CONTRACT" | "INVALID_INPUT" | "MISSING_DATA";
|
|
12
|
+
contract: string;
|
|
13
|
+
summary: {
|
|
14
|
+
tables: number;
|
|
15
|
+
rows: number;
|
|
16
|
+
fails: number;
|
|
17
|
+
warnings: number;
|
|
18
|
+
};
|
|
19
|
+
diagnostics: Diagnostic[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks tables against a contract: tables and columns, every cell's type,
|
|
23
|
+
* every column's `match`, then the rules.
|
|
24
|
+
*
|
|
25
|
+
* @param {TableCheckInput} input - Contract, tables and dependency tables.
|
|
26
|
+
* @returns {TableCheckResult} Status, summary and diagnostics.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* tableCheck({ contract: "orders.contract.json", tables: "orders.md" }).status; // "PASS"
|
|
30
|
+
*/
|
|
31
|
+
export declare function tableCheck(input: TableCheckInput): TableCheckResult;
|
|
32
|
+
/**
|
|
33
|
+
* Compact text for a table check result.
|
|
34
|
+
*
|
|
35
|
+
* @param {TableCheckResult} r - The result.
|
|
36
|
+
* @returns {string} Status line, then the diagnostics.
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatTableCheck(r: TableCheckResult): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TablesDoc } from "../../core/tables/types.js";
|
|
2
|
+
/** Most rows read from one table. */
|
|
3
|
+
export declare const MAX_TABLE_ROWS = 100000;
|
|
4
|
+
/** The files a format reads, for `expected`. */
|
|
5
|
+
export declare const FORMAT_FILES: {
|
|
6
|
+
readonly markdown: "a Markdown file";
|
|
7
|
+
readonly csv: "a .csv file or a folder of them";
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Why a path is in the wrong format for its contract, or null when it fits (or does not exist,
|
|
11
|
+
* which reading reports). Markdown parsing of CSV text finds no tables, so this must be checked
|
|
12
|
+
* first or a CSV dependency would silently look empty.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} path - The file or folder.
|
|
15
|
+
* @param {"markdown" | "csv"} format - The contract's format.
|
|
16
|
+
* @returns {string | null} The problem, or null.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatMismatch(path: string, format: "markdown" | "csv"): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Reads tables in a contract's format: a Markdown file, a folder of
|
|
21
|
+
* `<Table>.csv` files, or one `<Table>.csv` file.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} path - The file or folder.
|
|
24
|
+
* @param {"markdown" | "csv"} format - The contract's format.
|
|
25
|
+
* @returns {TablesDoc} The tables.
|
|
26
|
+
* @throws {Error} When the path cannot be read; BoundError when a table has too many rows.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readTables(path: string, format: "markdown" | "csv"): TablesDoc;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CommandModule } from "yargs";
|
|
2
|
+
import { ToolInfo } from "../../core/mcp.js";
|
|
3
|
+
/**
|
|
4
|
+
* Formats tools as one line each: name, then the first line of its description.
|
|
5
|
+
*
|
|
6
|
+
* @param {ToolInfo[]} tools - Tools from the gateway.
|
|
7
|
+
* @returns {string} The text, ending in a newline (empty for no tools).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* formatToolSummaries([{ name: "read_file", description: "Reads a file.\nMore." }]); // "read_file Reads a file.\n"
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatToolSummaries(tools: ToolInfo[]): string;
|
|
13
|
+
/**
|
|
14
|
+
* Formats tools with their full description and arguments, one `## <name>` section per tool.
|
|
15
|
+
*
|
|
16
|
+
* @param {ToolInfo[]} tools - Tools from the gateway.
|
|
17
|
+
* @returns {string} The text, ending in a newline (empty for no tools).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* formatToolDetails([{ name: "read_file", description: "Reads a file.",
|
|
21
|
+
* inputSchema: { properties: { path: { type: "string" } }, required: ["path"] } }]);
|
|
22
|
+
* // "## read_file\n\nReads a file.\n\nArguments:\n- path (string, required)\n"
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatToolDetails(tools: ToolInfo[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Picks the named tools, in the order given.
|
|
27
|
+
*
|
|
28
|
+
* @param {ToolInfo[]} tools - Tools from the gateway.
|
|
29
|
+
* @param {string[]} names - Tool names to pick.
|
|
30
|
+
* @returns {ToolInfo[]} The named tools.
|
|
31
|
+
* @throws {Error} When a name is not among the tools.
|
|
32
|
+
*/
|
|
33
|
+
export declare function pickTools(tools: ToolInfo[], names: string[]): ToolInfo[];
|
|
34
|
+
declare const command: CommandModule;
|
|
35
|
+
export default command;
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { callTool, callToolText, listTools, DEFAULT_URL } from "./core/mcp.js";
|
|
2
|
+
export type { ToolInfo, ToolResult } from "./core/mcp.js";
|
|
3
|
+
export { syncProjectFromServer, syncProjectToServer } from "./stm32/sync.js";
|
|
4
|
+
export { recordBaseline, regenerateProject } from "./stm32/regen.js";
|
|
5
|
+
export type { ServerCall } from "./stm32/sync.js";
|
|
6
|
+
export { buildProject, BUILD_PRESETS } from "./stm32/build.js";
|
|
7
|
+
export { analyzeProject, syntaxCheckProject } from "./stm32/analysis.js";
|
|
8
|
+
export type { BuildResult } from "./stm32/build.js";
|
|
9
|
+
export { downloadAndUnzip, zipLink } from "./stm32/utils/downloadzip_utils.js";
|
|
10
|
+
export { findStm32Project, findStm32ProjectIn } from "./stm32/utils/project_utils.js";
|
|
11
|
+
export type { Project } from "./stm32/tool.js";
|
package/dist/lib.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Library entry of @turingcode/cli, for the TuringCode VS Code extension: the server client and the STM32 project
|
|
2
|
+
// workflows the CLI commands run, without their command line parsing.
|
|
3
|
+
export { callTool, callToolText, listTools, DEFAULT_URL } from "./core/mcp.js";
|
|
4
|
+
export { syncProjectFromServer, syncProjectToServer } from "./stm32/sync.js";
|
|
5
|
+
export { recordBaseline, regenerateProject } from "./stm32/regen.js";
|
|
6
|
+
export { buildProject, BUILD_PRESETS } from "./stm32/build.js";
|
|
7
|
+
export { analyzeProject, syntaxCheckProject } from "./stm32/analysis.js";
|
|
8
|
+
export { downloadAndUnzip, zipLink } from "./stm32/utils/downloadzip_utils.js";
|
|
9
|
+
export { findStm32Project, findStm32ProjectIn } from "./stm32/utils/project_utils.js";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DiscoveredSystemTool, SystemToolId } from '../utils/discover_tools.js';
|
|
2
|
+
export type ActionParams = Record<string, string | number | boolean>;
|
|
3
|
+
export type CommandArg = string | {
|
|
4
|
+
if: string;
|
|
5
|
+
args: string[];
|
|
6
|
+
};
|
|
7
|
+
export interface ToolOutput {
|
|
8
|
+
tool: SystemToolId;
|
|
9
|
+
stdout: string;
|
|
10
|
+
stderr: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A debug operation (program, read memory, reset, ...) and the command line of each tool that can do it.
|
|
14
|
+
* The first installed tool in `commands` order runs it, with the placeholders filled from the action params.
|
|
15
|
+
* Everything is static: subclasses set the fields and are used without an instance (DebugActionRead.run_action(...)).
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class DebugAction {
|
|
18
|
+
static readonly title: string;
|
|
19
|
+
static readonly commands: Partial<Record<SystemToolId, CommandArg[]>>;
|
|
20
|
+
static readonly timeout: number;
|
|
21
|
+
static readonly exclusive: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Converts the action params to the placeholder values; override to add derived or formatted values.
|
|
24
|
+
* @param params action params
|
|
25
|
+
* @returns the placeholder values
|
|
26
|
+
*/
|
|
27
|
+
protected static values(params: ActionParams): ActionParams;
|
|
28
|
+
/**
|
|
29
|
+
* Picks the first installed tool that has a command line for this action.
|
|
30
|
+
* @returns the tool
|
|
31
|
+
*/
|
|
32
|
+
static pickSystemTool(): Promise<DiscoveredSystemTool>;
|
|
33
|
+
/**
|
|
34
|
+
* Builds the command line of a tool for this action.
|
|
35
|
+
* @param params action params
|
|
36
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
37
|
+
* @returns the tool and its arguments
|
|
38
|
+
*/
|
|
39
|
+
static build_command(params: ActionParams, tool?: DiscoveredSystemTool): Promise<{
|
|
40
|
+
tool: DiscoveredSystemTool;
|
|
41
|
+
args: string[];
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Runs the action's command line (no shell) and returns its full output.
|
|
45
|
+
* @param params action params
|
|
46
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
47
|
+
* @returns the tool that ran and its stdout and stderr
|
|
48
|
+
*/
|
|
49
|
+
static run_action(params: ActionParams, tool?: DiscoveredSystemTool): Promise<ToolOutput>;
|
|
50
|
+
/**
|
|
51
|
+
* Runs the action and returns the tail of its output, for tool replies.
|
|
52
|
+
* @param params action params
|
|
53
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
54
|
+
* @returns the last 1500 characters of stdout and stderr
|
|
55
|
+
*/
|
|
56
|
+
static run_action_get_tail(params: ActionParams, tool?: DiscoveredSystemTool): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the tail of a run's output, for tool replies.
|
|
59
|
+
* @param out output of exec
|
|
60
|
+
* @returns the last 1500 characters of stdout and stderr
|
|
61
|
+
*/
|
|
62
|
+
static tail(out: ToolOutput): string;
|
|
63
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Base of the debug actions: each one knows the command line of every tool that can run it.
|
|
2
|
+
//
|
|
3
|
+
import { execFile } from 'node:child_process';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { discover_system_tools, toolHint, } from '../utils/discover_tools.js';
|
|
6
|
+
import { claimProbe, releaseProbe } from '../utils/utils_mutex.js';
|
|
7
|
+
const run = promisify(execFile);
|
|
8
|
+
/**
|
|
9
|
+
* A debug operation (program, read memory, reset, ...) and the command line of each tool that can do it.
|
|
10
|
+
* The first installed tool in `commands` order runs it, with the placeholders filled from the action params.
|
|
11
|
+
* Everything is static: subclasses set the fields and are used without an instance (DebugActionRead.run_action(...)).
|
|
12
|
+
*/
|
|
13
|
+
export class DebugAction {
|
|
14
|
+
static title; // e.g. "Reading memory", for error messages
|
|
15
|
+
static commands;
|
|
16
|
+
static timeout = 30_000;
|
|
17
|
+
static exclusive = true; // the run opens the probe, so only one such run happens at a time
|
|
18
|
+
/**
|
|
19
|
+
* Converts the action params to the placeholder values; override to add derived or formatted values.
|
|
20
|
+
* @param params action params
|
|
21
|
+
* @returns the placeholder values
|
|
22
|
+
*/
|
|
23
|
+
static values(params) {
|
|
24
|
+
return params;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Picks the first installed tool that has a command line for this action.
|
|
28
|
+
* @returns the tool
|
|
29
|
+
*/
|
|
30
|
+
static async pickSystemTool() {
|
|
31
|
+
const ids = Object.keys(this.commands);
|
|
32
|
+
const first = async (refresh) => {
|
|
33
|
+
const installed = await discover_system_tools(refresh);
|
|
34
|
+
return ids.map((id) => installed.find((t) => t.id === id)).find((t) => t);
|
|
35
|
+
};
|
|
36
|
+
// Look again before failing, in case a tool was installed after the cached discovery
|
|
37
|
+
const tool = (await first(false)) ?? (await first(true));
|
|
38
|
+
if (!tool)
|
|
39
|
+
throw new Error(`${this.title} needs ${ids.map((id) => `${id} (${toolHint(id)})`).join(' or ')}`);
|
|
40
|
+
return tool;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Builds the command line of a tool for this action.
|
|
44
|
+
* @param params action params
|
|
45
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
46
|
+
* @returns the tool and its arguments
|
|
47
|
+
*/
|
|
48
|
+
static async build_command(params, tool) {
|
|
49
|
+
tool ??= await this.pickSystemTool();
|
|
50
|
+
const template = this.commands[tool.id];
|
|
51
|
+
if (!template)
|
|
52
|
+
throw new Error(`${this.title} is not supported by ${tool.id}`);
|
|
53
|
+
const values = this.values(params);
|
|
54
|
+
const fill = (arg) => arg.replace(/\{(\w+)\}/g, (_all, name) => {
|
|
55
|
+
if (!(name in values))
|
|
56
|
+
throw new Error(`${this.title}: no value for {${name}} in the ${tool.id} command`);
|
|
57
|
+
return String(values[name]);
|
|
58
|
+
});
|
|
59
|
+
const args = template.flatMap((a) => typeof a === 'string' ? [fill(a)] : values[a.if] === true ? a.args.map(fill) : []);
|
|
60
|
+
return { tool, args };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Runs the action's command line (no shell) and returns its full output.
|
|
64
|
+
* @param params action params
|
|
65
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
66
|
+
* @returns the tool that ran and its stdout and stderr
|
|
67
|
+
*/
|
|
68
|
+
static async run_action(params, tool) {
|
|
69
|
+
const cmd = await this.build_command(params, tool);
|
|
70
|
+
if (this.exclusive)
|
|
71
|
+
claimProbe(this.title);
|
|
72
|
+
try {
|
|
73
|
+
const { stdout, stderr } = await run(cmd.tool.path, cmd.args, {
|
|
74
|
+
timeout: this.timeout,
|
|
75
|
+
windowsHide: true,
|
|
76
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
77
|
+
});
|
|
78
|
+
return { tool: cmd.tool.id, stdout, stderr };
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
throw new Error(`${this.title} failed (${cmd.tool.id}): ${(`${e.stdout ?? ''}${e.stderr ?? ''}` || e.message).slice(-1500)}`);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
if (this.exclusive)
|
|
85
|
+
releaseProbe();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Runs the action and returns the tail of its output, for tool replies.
|
|
90
|
+
* @param params action params
|
|
91
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
92
|
+
* @returns the last 1500 characters of stdout and stderr
|
|
93
|
+
*/
|
|
94
|
+
static async run_action_get_tail(params, tool) {
|
|
95
|
+
return this.tail(await this.run_action(params, tool));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the tail of a run's output, for tool replies.
|
|
99
|
+
* @param out output of exec
|
|
100
|
+
* @returns the last 1500 characters of stdout and stderr
|
|
101
|
+
*/
|
|
102
|
+
static tail(out) {
|
|
103
|
+
return `${out.stdout}${out.stderr}`.slice(-1500);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DebugAction } from './DebugAction.js';
|
|
2
|
+
// Connects to the target without resetting it and reports what STM32_Programmer_CLI identifies
|
|
3
|
+
// (device ID, name, flash size, core). probe-rs cannot name a chip it is not told, so it has no command here.
|
|
4
|
+
export class DebugActionInfo extends DebugAction {
|
|
5
|
+
static title = 'Identifying the target';
|
|
6
|
+
static commands = {
|
|
7
|
+
STM32_Programmer_CLI: ['-c', 'port=SWD', 'mode=HOTPLUG'],
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DebugAction } from './DebugAction.js';
|
|
2
|
+
export declare class DebugActionListProbes extends DebugAction {
|
|
3
|
+
static readonly title = "Listing probes";
|
|
4
|
+
static readonly exclusive = false;
|
|
5
|
+
static readonly commands: {
|
|
6
|
+
'probe-rs': string[];
|
|
7
|
+
STM32_Programmer_CLI: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DebugAction } from './DebugAction.js';
|
|
2
|
+
// Lists the connected debug probes. Does not open a probe, so it skips the busy lock.
|
|
3
|
+
export class DebugActionListProbes extends DebugAction {
|
|
4
|
+
static title = 'Listing probes';
|
|
5
|
+
static exclusive = false;
|
|
6
|
+
static commands = {
|
|
7
|
+
'probe-rs': ['list'],
|
|
8
|
+
STM32_Programmer_CLI: ['--list'],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DebugAction, ToolOutput } from './DebugAction.js';
|
|
2
|
+
import { DiscoveredSystemTool } from '../utils/discover_tools.js';
|
|
3
|
+
export type ProgramParams = {
|
|
4
|
+
chip: string;
|
|
5
|
+
elf: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class DebugActionProgram extends DebugAction {
|
|
8
|
+
static readonly title = "Programming";
|
|
9
|
+
static readonly timeout = 180000;
|
|
10
|
+
static readonly commands: {
|
|
11
|
+
'probe-rs': (string | {
|
|
12
|
+
if: string;
|
|
13
|
+
args: string[];
|
|
14
|
+
})[];
|
|
15
|
+
STM32_Programmer_CLI: (string | {
|
|
16
|
+
if: string;
|
|
17
|
+
args: string[];
|
|
18
|
+
})[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Programs the ELF. If probe-rs fails on a dual-bank G47x/G48x part it has no algorithm for, retries once
|
|
22
|
+
* with the whole chip erased first, which also clears data kept in flash.
|
|
23
|
+
* @param p chip and ELF
|
|
24
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
25
|
+
* @returns the tool output, with a note at the end when the whole chip was erased
|
|
26
|
+
*/
|
|
27
|
+
static run_action(p: ProgramParams, tool?: DiscoveredSystemTool): Promise<ToolOutput>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DebugAction } from './DebugAction.js';
|
|
2
|
+
import { DebugActionRead } from './DebugActionRead.js';
|
|
3
|
+
import { hasSingleBankFlashAlgo } from '../utils/mcu_utils.js';
|
|
4
|
+
// STM32G4 FLASH_OPTR and its DBANK bit (dual-bank mode, 2 KB pages, bank 2 at 0x08040000).
|
|
5
|
+
const G4_FLASH_OPTR = 0x40022020;
|
|
6
|
+
const G4_OPTR_DBANK = 1 << 22;
|
|
7
|
+
/**
|
|
8
|
+
* Tells whether the target runs in a flash mode that probe-rs's per-sector erase gets wrong:
|
|
9
|
+
* a 128/256 KB STM32G47x/G48x with DBANK set, where probe-rs assumes the single-bank page layout.
|
|
10
|
+
* @param chip probe-rs target name (e.g. STM32G474CCTx)
|
|
11
|
+
* @returns true when the whole chip must be erased before programming
|
|
12
|
+
*/
|
|
13
|
+
async function needsChipErase(chip) {
|
|
14
|
+
if (!hasSingleBankFlashAlgo(chip))
|
|
15
|
+
return false;
|
|
16
|
+
const { words: [optr], } = await DebugActionRead.run_action({
|
|
17
|
+
chip,
|
|
18
|
+
address: G4_FLASH_OPTR,
|
|
19
|
+
width: 32,
|
|
20
|
+
count: 1,
|
|
21
|
+
});
|
|
22
|
+
return (optr & G4_OPTR_DBANK) !== 0;
|
|
23
|
+
}
|
|
24
|
+
// Writes an ELF over SWD, verifies it and resets the target.
|
|
25
|
+
// ponytail: uses the only connected probe
|
|
26
|
+
// (probe-rs --non-interactive fails if there are several);
|
|
27
|
+
// pin the probe once the sidebar has a probe picker
|
|
28
|
+
export class DebugActionProgram extends DebugAction {
|
|
29
|
+
static title = 'Programming';
|
|
30
|
+
static timeout = 180_000;
|
|
31
|
+
static commands = {
|
|
32
|
+
'probe-rs': [
|
|
33
|
+
'download',
|
|
34
|
+
'--chip',
|
|
35
|
+
'{chip}',
|
|
36
|
+
'--protocol',
|
|
37
|
+
'swd',
|
|
38
|
+
'--non-interactive',
|
|
39
|
+
'--disable-progressbars',
|
|
40
|
+
{ if: 'chipErase', args: ['--chip-erase'] },
|
|
41
|
+
'--verify',
|
|
42
|
+
'--reset',
|
|
43
|
+
'{elf}',
|
|
44
|
+
],
|
|
45
|
+
STM32_Programmer_CLI: [
|
|
46
|
+
'-c',
|
|
47
|
+
'port=SWD',
|
|
48
|
+
{ if: 'chipErase', args: ['-e', 'all'] },
|
|
49
|
+
'-w',
|
|
50
|
+
'{elf}',
|
|
51
|
+
'-v',
|
|
52
|
+
'-rst',
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Programs the ELF. If probe-rs fails on a dual-bank G47x/G48x part it has no algorithm for, retries once
|
|
57
|
+
* with the whole chip erased first, which also clears data kept in flash.
|
|
58
|
+
* @param p chip and ELF
|
|
59
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
60
|
+
* @returns the tool output, with a note at the end when the whole chip was erased
|
|
61
|
+
*/
|
|
62
|
+
static async run_action(p, tool) {
|
|
63
|
+
tool ??= await this.pickSystemTool();
|
|
64
|
+
try {
|
|
65
|
+
return await super.run_action({ ...p, chipErase: false }, tool);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
// A failed OPTR read (e.g. probe unplugged) means no retry, and the programming error is the one to report
|
|
69
|
+
if (tool.id !== 'probe-rs' || !(await needsChipErase(p.chip).catch(() => false)))
|
|
70
|
+
throw e;
|
|
71
|
+
const out = await super.run_action({ ...p, chipErase: true }, tool);
|
|
72
|
+
// appended to stderr so tail() keeps it
|
|
73
|
+
return {
|
|
74
|
+
...out,
|
|
75
|
+
stderr: `${out.stderr}\nDual-bank flash (DBANK=1): first attempt failed, erased the whole chip and programmed again. First error:\n${e.message.slice(-500)}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DebugAction, ToolOutput } from './DebugAction.js';
|
|
2
|
+
import { DiscoveredSystemTool } from '../utils/discover_tools.js';
|
|
3
|
+
export type ReadParams = {
|
|
4
|
+
chip: string;
|
|
5
|
+
address: number;
|
|
6
|
+
width: 8 | 16 | 32;
|
|
7
|
+
count: number;
|
|
8
|
+
};
|
|
9
|
+
export declare class DebugActionRead extends DebugAction {
|
|
10
|
+
static readonly title = "Reading memory";
|
|
11
|
+
static readonly commands: {
|
|
12
|
+
'probe-rs': string[];
|
|
13
|
+
STM32_Programmer_CLI: string[];
|
|
14
|
+
};
|
|
15
|
+
protected static values(p: ReadParams): {
|
|
16
|
+
chip: string;
|
|
17
|
+
width: 8 | 16 | 32;
|
|
18
|
+
count: number;
|
|
19
|
+
address: string;
|
|
20
|
+
bytes: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Reads target memory and parses the words from the tool output.
|
|
24
|
+
* @param p chip, address, width and word count
|
|
25
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
26
|
+
* @returns the tool output and the words read, in address order
|
|
27
|
+
*/
|
|
28
|
+
static run_action(p: ReadParams, tool?: DiscoveredSystemTool): Promise<ToolOutput & {
|
|
29
|
+
words: number[];
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Reads target memory and returns the whole tool output, not trimmed.
|
|
33
|
+
* @param p chip, address, width and word count
|
|
34
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
35
|
+
* @returns stdout and stderr
|
|
36
|
+
*/
|
|
37
|
+
static run_action_get_tail(p: ReadParams, tool?: DiscoveredSystemTool): Promise<string>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DebugAction } from './DebugAction.js';
|
|
2
|
+
// Reads target memory without halting the core. Never writes to the target.
|
|
3
|
+
export class DebugActionRead extends DebugAction {
|
|
4
|
+
static title = 'Reading memory';
|
|
5
|
+
static commands = {
|
|
6
|
+
'probe-rs': [
|
|
7
|
+
'read',
|
|
8
|
+
'--chip',
|
|
9
|
+
'{chip}',
|
|
10
|
+
'--protocol',
|
|
11
|
+
'swd',
|
|
12
|
+
'--non-interactive',
|
|
13
|
+
'b{width}',
|
|
14
|
+
'0x{address}',
|
|
15
|
+
'{count}',
|
|
16
|
+
],
|
|
17
|
+
STM32_Programmer_CLI: [
|
|
18
|
+
'-c',
|
|
19
|
+
'port=SWD',
|
|
20
|
+
'mode=HOTPLUG',
|
|
21
|
+
'-r{width}',
|
|
22
|
+
'0x{address}',
|
|
23
|
+
'{bytes}',
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
static values(p) {
|
|
27
|
+
return { ...p, address: p.address.toString(16), bytes: (p.count * p.width) / 8 };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reads target memory and parses the words from the tool output.
|
|
31
|
+
* @param p chip, address, width and word count
|
|
32
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
33
|
+
* @returns the tool output and the words read, in address order
|
|
34
|
+
*/
|
|
35
|
+
static async run_action(p, tool) {
|
|
36
|
+
const out = await super.run_action(p, tool);
|
|
37
|
+
// probe-rs prints the words, newer versions after an "40022020: " address prefix;
|
|
38
|
+
// STM32_Programmer_CLI prints "0x40022020 : FFEFF8AA ..." lines after its connection info
|
|
39
|
+
const data = out.tool === 'probe-rs'
|
|
40
|
+
? out.stdout.replace(/^\s*(0x)?[0-9a-fA-F]+\s*:/gm, '')
|
|
41
|
+
: [...out.stdout.matchAll(/^0x[0-9A-Fa-f]+\s*:(.*)$/gm)]
|
|
42
|
+
.map((m) => m[1])
|
|
43
|
+
.join(' ');
|
|
44
|
+
const words = data.match(new RegExp(`\\b[0-9a-fA-F]{${p.width / 4}}\\b`, 'g')) ?? [];
|
|
45
|
+
if (words.length !== p.count)
|
|
46
|
+
throw new Error(`Reading memory failed: expected ${p.count} words, got: ${out.stdout}`);
|
|
47
|
+
return { ...out, words: words.map((w) => parseInt(w, 16)) };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reads target memory and returns the whole tool output, not trimmed.
|
|
51
|
+
* @param p chip, address, width and word count
|
|
52
|
+
* @param tool tool to use, default the one pickSystemTool returns
|
|
53
|
+
* @returns stdout and stderr
|
|
54
|
+
*/
|
|
55
|
+
static async run_action_get_tail(p, tool) {
|
|
56
|
+
const out = await this.run_action(p, tool);
|
|
57
|
+
return `${out.stdout}${out.stderr}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DebugAction } from './DebugAction.js';
|
|
2
|
+
export type ResetParams = {
|
|
3
|
+
chip: string;
|
|
4
|
+
};
|
|
5
|
+
export declare class DebugActionReset extends DebugAction {
|
|
6
|
+
static readonly title = "Reset";
|
|
7
|
+
static readonly commands: {
|
|
8
|
+
'probe-rs': string[];
|
|
9
|
+
STM32_Programmer_CLI: string[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DebugAction } from './DebugAction.js';
|
|
2
|
+
// Resets the target through the only connected probe.
|
|
3
|
+
export class DebugActionReset extends DebugAction {
|
|
4
|
+
static title = 'Reset';
|
|
5
|
+
static commands = {
|
|
6
|
+
'probe-rs': ['reset', '--chip', '{chip}', '--protocol', 'swd', '--non-interactive'],
|
|
7
|
+
STM32_Programmer_CLI: ['-c', 'port=SWD', 'mode=HOTPLUG', '-rst'],
|
|
8
|
+
};
|
|
9
|
+
}
|