dsh-stm32 0.1.2 → 0.1.3
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 +59 -21
- package/README_EN.md +59 -21
- package/docs/development-notes.md +374 -3
- package/docs/reading-guide.md +87 -66
- package/lib/data/chips.js +38 -51
- package/lib/data/cmsis-sources.js +27 -1
- package/lib/data/device-facts.js +201 -0
- package/lib/data/stm32f1.js +94 -150
- package/lib/data/svd.js +627 -0
- package/lib/engine/assets.js +924 -0
- package/lib/engine/breakpoints.js +242 -0
- package/lib/engine/debug-session.js +153 -5
- package/lib/engine/debug.js +75 -41
- package/lib/engine/doctor.js +2 -2
- package/lib/engine/flash.js +31 -59
- package/lib/engine/ioc-plan.js +5 -5
- package/lib/engine/probe-error.js +212 -0
- package/lib/engine/probe-session.js +311 -0
- package/lib/engine/register-template.js +32 -8
- package/lib/engine/regs.js +2 -0
- package/lib/engine/rtt.js +600 -0
- package/lib/index.js +8 -0
- package/lib/tools/assets.js +341 -0
- package/lib/tools/cache.js +8 -0
- package/lib/tools/debug-session.js +40 -5
- package/lib/tools/debug.js +41 -11
- package/lib/tools/doctor.js +11 -0
- package/lib/tools/flash.js +15 -6
- package/lib/tools/generate.js +3 -0
- package/lib/tools/ioc-apply.js +2 -0
- package/lib/tools/ioc-inspect.js +2 -0
- package/lib/tools/ioc-plan.js +3 -0
- package/lib/tools/project-create.js +24 -0
- package/lib/tools/regs.js +453 -61
- package/lib/tools/route-plan.js +3 -0
- package/lib/tools/rtt.js +347 -0
- package/package.json +1 -1
- package/templates/register/CMakeLists.txt +7 -1
- package/templates/register/Core/Inc/rtt.h +103 -0
- package/templates/register/Core/Src/main.c +25 -0
- package/templates/register/Core/Src/rtt.c +297 -0
- package/templates/scaffold/RTT.md +86 -0
- package/templates/scaffold/cmake/user/CMakeLists.txt +7 -0
- package/lib/data/f1-ram.generated.js +0 -34
package/lib/engine/debug.js
CHANGED
|
@@ -11,7 +11,9 @@ import { dirname, isAbsolute, resolve } from "node:path";
|
|
|
11
11
|
import { resolveSearchConfig } from "../data/search-roots.js";
|
|
12
12
|
import { detectBuildDir, elfSelectionNote, findElf } from "./build.js";
|
|
13
13
|
import { usbDiagnosis } from "./doctor.js";
|
|
14
|
-
import {
|
|
14
|
+
import { defaultConfigs, findProjectConfig, quoteForDisplay, toOpenOcdPath } from "./flash.js";
|
|
15
|
+
import { collectBreakpointRequests, planBreakpoints, quotaOf, resolveBreakpointBudget } from "./breakpoints.js";
|
|
16
|
+
import { classifyProbeFailure, firstProblemLine, probeMissingLines, usbNoteFor } from "./probe-error.js";
|
|
15
17
|
import { resolveToolIn } from "./probe.js";
|
|
16
18
|
import { runStreaming } from "./subprocess-runner.js";
|
|
17
19
|
const sleep = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
@@ -131,39 +133,50 @@ function keyLogTail(lines, maxLines) {
|
|
|
131
133
|
kept.add(index);
|
|
132
134
|
return [...kept].sort((left, right) => left - right).map((index) => lines[index]).join("\n");
|
|
133
135
|
}
|
|
134
|
-
/** errorCode → 一句给人看的下一步。 */
|
|
135
|
-
function debugHintFor(code) {
|
|
136
|
-
if (code === "no-probe")
|
|
137
|
-
return HINT_PROBE;
|
|
138
|
-
if (code === "probe-busy")
|
|
139
|
-
return HINT_BUSY;
|
|
140
|
-
if (code === "swd-locked")
|
|
141
|
-
return HINT_DP;
|
|
142
|
-
if (code === "no-power")
|
|
143
|
-
return "目标板可能没供电:检查 3V3/GND 与 BOOT 跳线。";
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
/** 日志里第一条真正说明问题的行(给 message 用,避免只报"起不来")。 */
|
|
147
|
-
function firstProblemLine(lines) {
|
|
148
|
-
const hit = lines.find((line) => /^Error|unable to find|no device found|couldn't bind|cannot open|invalid/i.test(line));
|
|
149
|
-
return (hit ?? lines[lines.length - 1] ?? "").trim();
|
|
150
|
-
}
|
|
151
136
|
export async function runDebugRun(subprocess, request) {
|
|
152
137
|
const projectDir = resolve(request.projectDir);
|
|
153
138
|
const config = resolveSearchConfig(process.env, request.binDirs === undefined ? {} : { binDirs: request.binDirs });
|
|
154
139
|
const startedAt = Date.now();
|
|
155
140
|
const notes = [];
|
|
156
141
|
const errors = [];
|
|
142
|
+
// B4:断点预算先算清楚(纯计算 + 读 .ioc/chips.json,不碰探针),下面所有报告共用同一份配额。
|
|
143
|
+
const budgetInfo = resolveBreakpointBudget(projectDir);
|
|
144
|
+
const collected = collectBreakpointRequests({
|
|
145
|
+
...(request.breakAt === undefined ? {} : { breakAt: request.breakAt }),
|
|
146
|
+
...(request.breakpoints === undefined ? {} : { breakpoints: request.breakpoints }),
|
|
147
|
+
...(request.preCommands === undefined ? {} : { preCommands: request.preCommands }),
|
|
148
|
+
});
|
|
149
|
+
const plan = planBreakpoints(collected.requested, budgetInfo.budget);
|
|
157
150
|
const empty = {
|
|
158
151
|
ok: false, projectDir, elfPath: "", port: 0, breakAt: request.breakAt ?? "main",
|
|
159
152
|
hitBreakpoint: false, location: "", registers: [], backtrace: [], locals: [],
|
|
160
|
-
gdbCommand: "", gdbOutput: "", openOcdLogTail: "", durationMs: 0,
|
|
153
|
+
gdbCommand: "", gdbOutput: "", openOcdLogTail: "", durationMs: 0,
|
|
154
|
+
breakpoints: quotaOf(plan.used.code, plan.budget.code),
|
|
155
|
+
watchpoints: quotaOf(plan.used.data, plan.budget.data),
|
|
156
|
+
// 还没走到探针那一步(找不到 .elf / 缺工具链)就不算探针故障。
|
|
157
|
+
probeError: null,
|
|
158
|
+
errors, message: "", notes,
|
|
161
159
|
};
|
|
162
160
|
const elfPath = resolveElfPath(projectDir, request);
|
|
163
161
|
if (elfPath === null) {
|
|
164
162
|
errors.push("找不到 .elf(先跑 stm32_build)");
|
|
165
163
|
return { ...empty, message: "没调试:找不到 .elf", durationMs: Date.now() - startedAt };
|
|
166
164
|
}
|
|
165
|
+
// B4:超预算就到此为止——不 spawn openocd(探针不动),也不让 gdb 报一串
|
|
166
|
+
// "Cannot insert breakpoint" 再把整次调试带崩。文案直接给"超了几个"和"删哪个/换什么"。
|
|
167
|
+
if (!plan.ok) {
|
|
168
|
+
errors.push("断点超预算:" + plan.detail);
|
|
169
|
+
notes.push(...collected.notes);
|
|
170
|
+
notes.push(budgetInfo.note);
|
|
171
|
+
notes.push(plan.suggestion);
|
|
172
|
+
return {
|
|
173
|
+
...empty,
|
|
174
|
+
elfPath,
|
|
175
|
+
message: "没调试:断点超预算(硬件断点 " + String(plan.used.code) + "/" + String(plan.budget.code)
|
|
176
|
+
+ ",观察点 " + String(plan.used.data) + "/" + String(plan.budget.data) + ")",
|
|
177
|
+
durationMs: Date.now() - startedAt,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
167
180
|
const selectionNote = elfSelectionNote(dirname(elfPath));
|
|
168
181
|
if (selectionNote !== "")
|
|
169
182
|
notes.push(selectionNote);
|
|
@@ -208,26 +221,31 @@ export async function runDebugRun(subprocess, request) {
|
|
|
208
221
|
// F2:旧版只回"openocd 起不来"+15 行尾巴,真正的 adapter init 失败常被挤掉。
|
|
209
222
|
// 现在先归类(与 flash 同一套规则),再把有信息量的行留下,并顺手做一次 USB 形态诊断。
|
|
210
223
|
const lines = listening.text.split(/\r?\n/u).filter((line) => line.trim() !== "");
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
notes.push(hint);
|
|
215
|
-
if (probeMissingLines(lines).length > 0) {
|
|
224
|
+
// 此时 openocd 还没结算,退出码未知(给 null);归类规则与 flash 完全同一份。
|
|
225
|
+
const probeError = classifyProbeFailure({ lines, exitCode: null, stage: "debug" });
|
|
226
|
+
if (probeError.kind !== "unknown")
|
|
227
|
+
notes.push(probeError.hint);
|
|
228
|
+
if (probeError.kind === "no-probe" && probeMissingLines(lines).length > 0) {
|
|
216
229
|
const usb = await usbDiagnosis(subprocess, request.signal);
|
|
217
230
|
const extra = usbNoteFor(usb.kind, usb.detail);
|
|
218
231
|
if (extra !== null)
|
|
219
232
|
notes.push(extra);
|
|
220
233
|
}
|
|
221
234
|
const problem = firstProblemLine(lines);
|
|
222
|
-
errors.push("openocd
|
|
223
|
-
(problem === "" ? "15 s 内没开始监听 " + String(port) : problem));
|
|
235
|
+
errors.push("openocd 起不来:" + (problem === "" ? "15 s 内没开始监听 " + String(port) : problem));
|
|
224
236
|
return {
|
|
225
|
-
...empty, elfPath, port, openOcdLogTail: keyLogTail(lines, 40),
|
|
226
|
-
message: "没调试:openocd 起不来"
|
|
237
|
+
...empty, elfPath, port, openOcdLogTail: keyLogTail(lines, 40), probeError,
|
|
238
|
+
message: "没调试:openocd 起不来",
|
|
227
239
|
durationMs: Date.now() - startedAt,
|
|
228
240
|
};
|
|
229
241
|
}
|
|
230
242
|
const breakAt = request.breakAt ?? "main";
|
|
243
|
+
// B4:显式的额外断点(breakAt 已经单独处理;这里只补 breakpoints 参数里的)。
|
|
244
|
+
const explicit = collectBreakpointRequests({
|
|
245
|
+
...(request.breakpoints === undefined ? {} : { breakpoints: request.breakpoints }),
|
|
246
|
+
}).requested;
|
|
247
|
+
// breakAt=none 但有额外断点时也要 continue,否则那些断点永远不会命中。
|
|
248
|
+
const shouldContinue = (breakAt !== "none" && breakAt !== "") || explicit.length > 0;
|
|
231
249
|
const gdbArgs = [gdb, "-q", "-batch", "-nx"];
|
|
232
250
|
const ex = (command) => {
|
|
233
251
|
gdbArgs.push("-ex", command);
|
|
@@ -240,9 +258,11 @@ export async function runDebugRun(subprocess, request) {
|
|
|
240
258
|
ex("monitor reset halt");
|
|
241
259
|
if (breakAt !== "none" && breakAt !== "")
|
|
242
260
|
ex("break " + breakAt);
|
|
261
|
+
for (const bp of explicit)
|
|
262
|
+
ex((bp.kind === "data" ? "watch " : "break ") + bp.location);
|
|
243
263
|
for (const command of request.preCommands ?? [])
|
|
244
264
|
ex(command);
|
|
245
|
-
if (
|
|
265
|
+
if (shouldContinue)
|
|
246
266
|
ex("continue");
|
|
247
267
|
ex("info registers pc sp lr xpsr");
|
|
248
268
|
ex("bt");
|
|
@@ -250,7 +270,7 @@ export async function runDebugRun(subprocess, request) {
|
|
|
250
270
|
for (const command of request.postCommands ?? ["monitor reset run", "detach"])
|
|
251
271
|
ex(command);
|
|
252
272
|
const gdbCommand = gdbArgs.map(quoteForDisplay).join(" ");
|
|
253
|
-
request.onProgress?.("gdb:" + breakAt + (
|
|
273
|
+
request.onProgress?.("gdb:" + breakAt + (shouldContinue ? " 断点" : ""));
|
|
254
274
|
const gdbOutcome = await runStreaming(subprocess, {
|
|
255
275
|
argv: gdbArgs,
|
|
256
276
|
cwd: projectDir,
|
|
@@ -277,22 +297,34 @@ export async function runDebugRun(subprocess, request) {
|
|
|
277
297
|
&& !gdbOutcome.timedOut
|
|
278
298
|
&& gdbOutcome.exitCode === 0
|
|
279
299
|
&& probe.errors.length === 0
|
|
280
|
-
&& (
|
|
300
|
+
&& (!shouldContinue || probe.hitBreakpoint);
|
|
281
301
|
if (ok)
|
|
282
302
|
notes.push("已在 " + (probe.location === "" ? breakAt : probe.location) + " 停住并抓过快照;收尾是 monitor reset run + detach,芯片现在自由运行,探针已释放");
|
|
283
303
|
if (!ok && probe.hitBreakpoint)
|
|
284
304
|
notes.push("命中了断点,但收尾阶段有问题");
|
|
285
|
-
if (
|
|
286
|
-
|
|
305
|
+
if (shouldContinue && !probe.hitBreakpoint && errors.length === 0) {
|
|
306
|
+
const where = breakAt !== "none" && breakAt !== "" ? breakAt : "这 " + String(explicit.length) + " 个断点";
|
|
307
|
+
errors.push("没有停在 " + where + ":可能是复位后没跑到这里,或符号对不上(.elf 与板上的固件不一致)");
|
|
308
|
+
}
|
|
309
|
+
// B4:只要这次真设了断点,就把预算和来源写进 notes(6/4 是芯片事实,不是插件随手定的)。
|
|
310
|
+
if (collected.requested.length > 0) {
|
|
311
|
+
notes.push(...collected.notes);
|
|
312
|
+
notes.push("断点预算:" + String(plan.used.code) + "/" + String(plan.budget.code) + " 个硬件断点、"
|
|
313
|
+
+ String(plan.used.data) + "/" + String(plan.budget.data) + " 个观察点(" + budgetInfo.note + ")");
|
|
287
314
|
}
|
|
288
|
-
//
|
|
289
|
-
let
|
|
315
|
+
// B2:失败时只归一次类(成功时 probeError 是 null,报告里不带噪音)。
|
|
316
|
+
let probeError = null;
|
|
290
317
|
if (!ok) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
318
|
+
probeError = classifyProbeFailure({
|
|
319
|
+
lines: allLines,
|
|
320
|
+
exitCode: gdbOutcome.exitCode,
|
|
321
|
+
stage: "debug",
|
|
322
|
+
timedOut: gdbOutcome.timedOut,
|
|
323
|
+
spawnError: gdbOutcome.spawnError,
|
|
324
|
+
});
|
|
325
|
+
if (probeError.kind !== "unknown")
|
|
326
|
+
notes.push(probeError.hint);
|
|
327
|
+
if (probeError.kind === "no-probe" && probeMissingLines(allLines).length > 0) {
|
|
296
328
|
const usb = await usbDiagnosis(subprocess, request.signal);
|
|
297
329
|
const extra = usbNoteFor(usb.kind, usb.detail);
|
|
298
330
|
if (extra !== null)
|
|
@@ -313,7 +345,9 @@ export async function runDebugRun(subprocess, request) {
|
|
|
313
345
|
gdbCommand,
|
|
314
346
|
gdbOutput: gdbText,
|
|
315
347
|
openOcdLogTail: keyLogTail(allLines, 40),
|
|
316
|
-
|
|
348
|
+
breakpoints: quotaOf(plan.used.code, plan.budget.code),
|
|
349
|
+
watchpoints: quotaOf(plan.used.data, plan.budget.data),
|
|
350
|
+
probeError,
|
|
317
351
|
durationMs: Date.now() - startedAt,
|
|
318
352
|
errors,
|
|
319
353
|
message: ok
|
package/lib/engine/doctor.js
CHANGED
|
@@ -267,7 +267,7 @@ export function findLinkerScript(projectDir) {
|
|
|
267
267
|
* ② 启动文件/芯片 ↔ cmake 源清单里的设备宏;
|
|
268
268
|
* ③ 链接脚本 MEMORY 的 FLASH/RAM ↔ 芯片真实容量(大了致命,小了只浪费);
|
|
269
269
|
* ④ .elf 实际大小 ↔ Flash 容量。
|
|
270
|
-
* 另外把引脚表来源(本机 db
|
|
270
|
+
* 另外把引脚表来源(本机 db 还是 unknown、有没有校验过)写进 notes。
|
|
271
271
|
*/
|
|
272
272
|
export function checkChipConsistency(input) {
|
|
273
273
|
const blockers = [];
|
|
@@ -372,7 +372,7 @@ export function checkChipConsistency(input) {
|
|
|
372
372
|
notes.push(".elf 已用 " + String(Math.round((elfUsed / flashLimit) * 100)) + "% Flash(" + kib(elfUsed) + " / " + kib(flashLimit) + "),快满了");
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
// 引脚表 ↔ .ioc 用到的引脚(只有真拿到本机 db
|
|
375
|
+
// 引脚表 ↔ .ioc 用到的引脚(只有真拿到本机 db 时才比:没有内置表可退,没 db 就不判引脚存在性)
|
|
376
376
|
const iocPins = [...new Set((input.iocPins ?? []).map((pin) => normalizeIocPin(pin)).filter((pin) => pin !== ""))];
|
|
377
377
|
if (pins.kind === "db" && iocPins.length > 0) {
|
|
378
378
|
const unknown = iocPins.filter((pin) => !pins.pins.includes(pin));
|
package/lib/engine/flash.js
CHANGED
|
@@ -9,6 +9,7 @@ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
|
9
9
|
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
10
10
|
import { describeSearchScope, resolveSearchConfig } from "../data/search-roots.js";
|
|
11
11
|
import { usbDiagnosis } from "./doctor.js";
|
|
12
|
+
import { classifyProbeFailure, probeMissingLines, usbNoteFor } from "./probe-error.js";
|
|
12
13
|
import { detectBuildDir, elfSelectionNote, findElf } from "./build.js";
|
|
13
14
|
import { findIocFile } from "./generate.js";
|
|
14
15
|
import { summarizeIoc } from "./ioc.js";
|
|
@@ -158,30 +159,11 @@ export function resolveElf(projectDir, request) {
|
|
|
158
159
|
return { elf: null, buildDir, note: "构建目录里没有 .elf(先跑 stm32_build)" };
|
|
159
160
|
return { elf: elfInfo.path, buildDir, note: "" };
|
|
160
161
|
}
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return "no-probe";
|
|
167
|
-
if (/adapter speed could not be limited|target is openocd and must be halted/.test(line))
|
|
168
|
-
return "probe-busy";
|
|
169
|
-
// 真板子取证(2026-10-28):两个 openocd 同时抓同一个 CMSIS-DAP 时,openocd 不会报"忙",
|
|
170
|
-
// 而是两边交替收发导致 DAP 事务错位——满屏 transfer count mismatch / command mismatch。
|
|
171
|
-
if (/cmsis-dap (transfer count mismatch|command mismatch)|cmsis-dap command cmd_\w+ failed|libusb_error_busy/.test(line))
|
|
172
|
-
return "probe-busy";
|
|
173
|
-
if (/error connecting dp|cannot read idr|ap lock|sticky error/.test(line))
|
|
174
|
-
return "swd-locked";
|
|
175
|
-
if (/flash programming|write protected|read protected|memory protected/.test(line))
|
|
176
|
-
return "flash-protected";
|
|
177
|
-
if (/target voltage may be too low|no power/.test(line))
|
|
178
|
-
return "no-power";
|
|
179
|
-
if (/device id|cannot identify|unexpected idcode/.test(line))
|
|
180
|
-
return "target-mismatch";
|
|
181
|
-
}
|
|
182
|
-
return "unknown";
|
|
183
|
-
}
|
|
184
|
-
/** 认 openocd 的 ** Programming Finished ** / ** Verified OK ** 与 Error: 行。 */
|
|
162
|
+
/**
|
|
163
|
+
* 认 openocd 的 ** Programming Finished ** / ** Verified OK ** 与 Error: 行。
|
|
164
|
+
* 归类不在这里做:失败原因要连退出码/超时/启动失败一起看,统一走 probe-error.ts 的
|
|
165
|
+
* classifyProbeFailure(B2 之后只有这一个分类入口,避免两份规则漂移)。
|
|
166
|
+
*/
|
|
185
167
|
export function parseFlashLog(text) {
|
|
186
168
|
const programmed = /\*\*\s*Programming Finished\s*\*\*/u.test(text);
|
|
187
169
|
const verified = /\*\*\s*Verified OK\s*\*\*/u.test(text);
|
|
@@ -210,22 +192,7 @@ export function parseFlashLog(text) {
|
|
|
210
192
|
else
|
|
211
193
|
errors.push(line);
|
|
212
194
|
}
|
|
213
|
-
|
|
214
|
-
const errorCode = succeeded ? "" : errorCodeOfLines(flat.length === 0 ? [text] : flat);
|
|
215
|
-
return { programmed, verified, errors, noise, errorCode };
|
|
216
|
-
}
|
|
217
|
-
export const HINT_DP = "连不上芯片(Error connecting DP):固件里可能关了 SWD(__HAL_AFIO_REMAP_SWJ_DISABLE),需要 BOOT0=1 重启进系统 bootloader 再烧,或按住复位键在连接瞬间松开。";
|
|
218
|
-
export const HINT_PROBE = "找不到 CMSIS-DAP 探针:检查 USB、是否被 openocd/调试会话占用(先停掉正在跑的调试)。";
|
|
219
|
-
export const HINT_BUSY = "探针被别的进程同时访问(两个 openocd 抢同一个 CMSIS-DAP 时不会报错,而是满屏 transfer count mismatch):先关掉调试会话或另一个 openocd,再烧一次。";
|
|
220
|
-
/** openocd 报"找不到设备"的那几行错误行(2a 的判定基准,纯函数便于单测)。 */
|
|
221
|
-
export function probeMissingLines(errors) {
|
|
222
|
-
return errors.filter((line) => /CMSIS-DAP device|no device found/iu.test(line));
|
|
223
|
-
}
|
|
224
|
-
/** USB 形态诊断的结论该以什么 note 呈现(unknown 静默:诊断失败不能把失败报告搞得更吵)。 */
|
|
225
|
-
export function usbNoteFor(kind, detail) {
|
|
226
|
-
if (kind === "unknown")
|
|
227
|
-
return null;
|
|
228
|
-
return "USB 形态:" + detail;
|
|
195
|
+
return { programmed, verified, errors, noise };
|
|
229
196
|
}
|
|
230
197
|
export async function runFlash(subprocess, request) {
|
|
231
198
|
const projectDir = resolve(request.projectDir);
|
|
@@ -237,6 +204,7 @@ export async function runFlash(subprocess, request) {
|
|
|
237
204
|
return {
|
|
238
205
|
ok: false, projectDir, elfPath: "", elfSize: 0, command: "", args: [], configs: [],
|
|
239
206
|
durationMs: Date.now() - startedAt, programmed: false, verified: false,
|
|
207
|
+
probeError: null,
|
|
240
208
|
errors: [elfResolved.note], message: "没烧:找不到要烧的 .elf", logTail: "", notes,
|
|
241
209
|
};
|
|
242
210
|
}
|
|
@@ -254,6 +222,8 @@ export async function runFlash(subprocess, request) {
|
|
|
254
222
|
return {
|
|
255
223
|
ok: false, projectDir, elfPath, elfSize, command: "", args: [], configs: [],
|
|
256
224
|
durationMs: Date.now() - startedAt, programmed: false, verified: false,
|
|
225
|
+
// 守卫拒绝不是探针故障:这次连 openocd 都没起,probeError 保持 null。
|
|
226
|
+
probeError: null,
|
|
257
227
|
errors: guard.errors, message: "没烧:.ioc 里没启用 Serial Wire(SWD 会被关掉)",
|
|
258
228
|
logTail: "", notes: [...notes, ...guard.notes], guard: "no-debug",
|
|
259
229
|
};
|
|
@@ -265,6 +235,7 @@ export async function runFlash(subprocess, request) {
|
|
|
265
235
|
return {
|
|
266
236
|
ok: false, projectDir, elfPath, elfSize, command: "", args: [], configs: [],
|
|
267
237
|
durationMs: Date.now() - startedAt, programmed: false, verified: false,
|
|
238
|
+
probeError: null,
|
|
268
239
|
errors: ["找不到 openocd"],
|
|
269
240
|
message: "没烧:找不到 openocd(msys64 里 pacman -S mingw-w64-ucrt-x86_64-openocd);查过 " +
|
|
270
241
|
describeSearchScope(config.binDirs, "PATH"),
|
|
@@ -313,11 +284,25 @@ export async function runFlash(subprocess, request) {
|
|
|
313
284
|
notes.push("openocd 成功路径上的 " + String(verdict.noise.length) + " 条 Error: 行按噪声处理(首条:" +
|
|
314
285
|
(verdict.noise[0] ?? "") + ")");
|
|
315
286
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
notes.push(
|
|
287
|
+
const ok = outcome.exitCode === 0 && outcome.spawnError === null && !outcome.timedOut && verdict.programmed && errors.length === 0;
|
|
288
|
+
if (!ok && verdict.programmed && !verdict.verified)
|
|
289
|
+
notes.push("写入成功但校验没过,建议重试或降低 adapter speed");
|
|
290
|
+
if (ok)
|
|
291
|
+
notes.push("产物:" + basename(elfPath) + "(" + String(elfSize) + " B)已写入并复位运行,探针已释放");
|
|
292
|
+
// B2:失败时只归一次类。模型按 kind 分支、按 hint 动手,不用自己解析中文 message。
|
|
293
|
+
// unknown 不往 notes 里推 hint:没有依据的"下一步"只会盖住真正的根因。
|
|
294
|
+
const probeError = ok
|
|
295
|
+
? null
|
|
296
|
+
: classifyProbeFailure({
|
|
297
|
+
lines: [...errors, ...verdict.noise],
|
|
298
|
+
exitCode: outcome.exitCode,
|
|
299
|
+
stage: "flash",
|
|
300
|
+
timedOut: outcome.timedOut,
|
|
301
|
+
spawnError: outcome.spawnError,
|
|
302
|
+
});
|
|
303
|
+
if (probeError !== null && probeError.kind !== "unknown")
|
|
304
|
+
notes.push(probeError.hint);
|
|
305
|
+
if (probeError !== null && probeError.kind === "no-probe" && probeMissingLines(errors).length > 0) {
|
|
321
306
|
// 2a:找不到设备时顺手做一次 USB 形态诊断——"没插"与"这台机器根本没 USB"是两种答案。
|
|
322
307
|
// 诊断失败静默(unknown 不进 notes),绝不能让诊断把失败报告搞得更吵。
|
|
323
308
|
const usb = await usbDiagnosis(subprocess, request.signal);
|
|
@@ -325,28 +310,15 @@ export async function runFlash(subprocess, request) {
|
|
|
325
310
|
if (extra !== null)
|
|
326
311
|
notes.push(extra);
|
|
327
312
|
}
|
|
328
|
-
const ok = outcome.exitCode === 0 && outcome.spawnError === null && !outcome.timedOut && verdict.programmed && errors.length === 0;
|
|
329
|
-
if (!ok && verdict.programmed && !verdict.verified)
|
|
330
|
-
notes.push("写入成功但校验没过,建议重试或降低 adapter speed");
|
|
331
|
-
if (ok)
|
|
332
|
-
notes.push("产物:" + basename(elfPath) + "(" + String(elfSize) + " B)已写入并复位运行,探针已释放");
|
|
333
313
|
const message = ok
|
|
334
314
|
? "烧录成功(" + ((Date.now() - startedAt) / 1000).toFixed(1) + " s" + (verdict.verified ? ",已校验" : "") + ")"
|
|
335
315
|
: "烧录失败:" + (errors[0] ?? "openocd 退出码 " + String(outcome.exitCode));
|
|
336
|
-
// 2d:errorCode 供模型分流(重试 / 换线 / 停会话 / 直接问人)。
|
|
337
|
-
let errorCode = verdict.errorCode;
|
|
338
|
-
if (!ok && (outcome.spawnError !== null || outcome.timedOut))
|
|
339
|
-
errorCode = "unknown";
|
|
340
|
-
if (!ok && errorCode === "swd-locked" && errors.some((line) => /Error connecting DP/u.test(line)))
|
|
341
|
-
errorCode = "swd-locked";
|
|
342
|
-
if (!ok && errorCode === "probe-busy")
|
|
343
|
-
notes.push(HINT_BUSY);
|
|
344
316
|
return {
|
|
345
317
|
ok, projectDir, elfPath, elfSize, command, args, configs,
|
|
346
318
|
durationMs: Date.now() - startedAt,
|
|
347
319
|
...(outcome.exitCode === null ? {} : { exitCode: outcome.exitCode }),
|
|
348
320
|
programmed: verdict.programmed, verified: verdict.verified,
|
|
349
|
-
|
|
321
|
+
probeError,
|
|
350
322
|
errors, message, logTail: log.split(/\r?\n/u).slice(-25).join("\n"), notes,
|
|
351
323
|
};
|
|
352
324
|
}
|
package/lib/engine/ioc-plan.js
CHANGED
|
@@ -140,7 +140,7 @@ function writePinOrder(entries, order) {
|
|
|
140
140
|
entries.delete("Mcu.Pin" + String(position));
|
|
141
141
|
entries.set("Mcu.PinsNb", String(order.length));
|
|
142
142
|
}
|
|
143
|
-
function addPin(table, request
|
|
143
|
+
function addPin(table, request) {
|
|
144
144
|
const pin = request.pin.trim();
|
|
145
145
|
if (pin === "") {
|
|
146
146
|
table.errors.push("pins 里有空引脚名");
|
|
@@ -150,8 +150,9 @@ function addPin(table, request, chip) {
|
|
|
150
150
|
table.errors.push("引脚 " + pin + " 已经在 .ioc 里配置过了(要改请用 entries 直接设置对应键)");
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
-
if (!isKnownPin(
|
|
154
|
-
table.errors.push("
|
|
153
|
+
if (!isKnownPin(pin)) {
|
|
154
|
+
table.errors.push("引脚名 " + pin + " 不是合法的 STM32 GPIO 引脚(形如 PA0..PG15,或 VP_ 开头的虚拟引脚);" +
|
|
155
|
+
"插件不再内置引脚表,这个封装到底有没有这根脚请用 stm32_doctor 对着本机 CubeMX db 校验");
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
158
|
const label = (request.label ?? "").trim();
|
|
@@ -249,12 +250,11 @@ export function planIocChanges(request) {
|
|
|
249
250
|
const before = parseIocEntries(source);
|
|
250
251
|
// 深拷贝成可写 Map(parseIocEntries 返回的就是新 Map,直接改即可)。
|
|
251
252
|
const after = new Map(before);
|
|
252
|
-
const chipCpn = before.get("Mcu.CPN") ?? "";
|
|
253
253
|
const pinTable = readPinTable(after, errors, warnings);
|
|
254
254
|
// 先记下原始引脚表:只有真的变了才重写 Mcu.PinN,顺序没变就一个字节都不碰。
|
|
255
255
|
const originalOrder = [...pinTable.order];
|
|
256
256
|
for (const pin of request.pins ?? [])
|
|
257
|
-
addPin(pinTable, pin
|
|
257
|
+
addPin(pinTable, pin);
|
|
258
258
|
if (request.serialWire === true)
|
|
259
259
|
ensureSerialWire(pinTable);
|
|
260
260
|
// 引脚表变化过才重写 Mcu.PinN。
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* B2:结构化探针错误 —— flash / debug / session 三条路径共用一份分类。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有它:2d 的错误码只是一张枚举,失败时模型还得去读中文 message 才知道下一步。
|
|
5
|
+
* 现在一次分类就给全五样东西:
|
|
6
|
+
* - kind:契约字段(模型可以按它分支),旧错误码字段直接删掉,不做兼容别名(用户已定);
|
|
7
|
+
* - cause:一句话根因,给人看也够;
|
|
8
|
+
* - hint:可执行的下一步(四类真机验过的故障各自有专属文案);
|
|
9
|
+
* - evidence:原始日志行,逐字保留,别让模型凭二手转述猜;
|
|
10
|
+
* - retryable:照 hint 弄完再调一次同一个工具有没有意义(true=值得重试)。
|
|
11
|
+
*
|
|
12
|
+
* 归类顺序敏感:先 no-probe 再 probe-busy —— 把"被占用"读成"没插"会让人白拔线。
|
|
13
|
+
* 同一套规则同时服务 flash(openocd program)与 debug(openocd + gdb),改一处两边一起变。
|
|
14
|
+
*/
|
|
15
|
+
/** 枚举的运行时形态(工具 schema 的 enum 也用它,避免第二个真相)。 */
|
|
16
|
+
export const PROBE_ERROR_KINDS = [
|
|
17
|
+
"no-probe",
|
|
18
|
+
"probe-busy",
|
|
19
|
+
"swd-locked",
|
|
20
|
+
"flash-protected",
|
|
21
|
+
"no-power",
|
|
22
|
+
"target-mismatch",
|
|
23
|
+
"timeout",
|
|
24
|
+
"unknown",
|
|
25
|
+
];
|
|
26
|
+
// ── 文案:hint 是给用户的下一步,cause 是一句话根因 ────────────────────────────────
|
|
27
|
+
export const HINT_PROBE = "找不到 CMSIS-DAP 探针:检查 USB、是否被 openocd/调试会话占用(先停掉正在跑的调试),必要时换一根数据线再试。";
|
|
28
|
+
export const HINT_BUSY = "探针被别的进程同时访问(两个 openocd 抢同一个 CMSIS-DAP 时不会报错,而是满屏 transfer count mismatch):先关掉调试会话或另一个 openocd,再烧一次。";
|
|
29
|
+
export const HINT_DP = "连不上芯片(Error connecting DP):固件里可能关了 SWD(__HAL_AFIO_REMAP_SWJ_DISABLE),需要 BOOT0=1 重启进系统 bootloader 再烧,或按住复位键在连接瞬间松开。";
|
|
30
|
+
export const HINT_FLASH_PROTECTED = "Flash 被写保护/读保护挡住:先做一次全片擦除(openocd 的 stm32f1x mass_erase)或解除读保护(RDP)再烧;量产片上确实要保持保护时,这次烧录就不可能成功,别再原地重试。";
|
|
31
|
+
export const HINT_NO_POWER = "目标板没供电:量一下 3V3/GND,检查 BOOT0/BOOT1 跳线与杜邦线接触,USB 供电不足时换独立电源再试。";
|
|
32
|
+
export const HINT_TARGET_MISMATCH = "连上的不是目标芯片:openocd 的 target 配置(stm32f1x)与实测 device id 不符——确认板上确实是 STM32F103 系列,或把 .ioc / 芯片型号参数改对再试。";
|
|
33
|
+
export const HINT_TIMEOUT = "超时:目标没在等(断点没命中、程序跑飞)或探针链路太慢——先把 adapter speed 降到 1000 或 100,确认固件真的会跑到断点,再适度加大 timeoutMs 重试。";
|
|
34
|
+
export const HINT_UNKNOWN = "日志里没有能归类的特征:把 evidence 或日志尾部贴出来核对,并用 stm32_doctor 看探针占用与工具链状态,别盲目重试。";
|
|
35
|
+
const HINT_BY_KIND = {
|
|
36
|
+
"no-probe": HINT_PROBE,
|
|
37
|
+
"probe-busy": HINT_BUSY,
|
|
38
|
+
"swd-locked": HINT_DP,
|
|
39
|
+
"flash-protected": HINT_FLASH_PROTECTED,
|
|
40
|
+
"no-power": HINT_NO_POWER,
|
|
41
|
+
"target-mismatch": HINT_TARGET_MISMATCH,
|
|
42
|
+
timeout: HINT_TIMEOUT,
|
|
43
|
+
unknown: HINT_UNKNOWN,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* retryable 的判据只有一个:「照 hint 处理完,再调一次同一个工具有没有意义」。
|
|
47
|
+
* 需要换流程/换芯片/改工程配置才能过的,一律 false——否则模型会拿同一条命令空转。
|
|
48
|
+
*/
|
|
49
|
+
const RETRYABLE_BY_KIND = {
|
|
50
|
+
"no-probe": true, // 插好线 / 停掉占用就能再烧
|
|
51
|
+
"probe-busy": true, // 让出探针即可重试
|
|
52
|
+
"swd-locked": true, // 按 hint 用 BOOT0 进 bootloader 后同一条命令能成
|
|
53
|
+
"flash-protected": false, // 要先解保护,不属于"再试一次"
|
|
54
|
+
"no-power": true, // 供电接好就能再烧
|
|
55
|
+
"target-mismatch": false, // 芯片或配置不对,重试只会得到同样的报错
|
|
56
|
+
timeout: true, // 降速/加大超时是有效调整
|
|
57
|
+
unknown: false, // 没有依据,重试等于赌
|
|
58
|
+
};
|
|
59
|
+
const CAUSE_TIMEOUT = {
|
|
60
|
+
flash: "烧录超时:openocd 没在 timeoutMs 内跑完 program",
|
|
61
|
+
debug: "调试超时:gdb 没在 timeoutMs 内命中断点或没能收尾",
|
|
62
|
+
session: "会话超时:openocd 没在超时前开始监听 gdb 端口",
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 日志特征表(顺序即优先级):判据全部沿用 2d 的那套正则,一条都没改,
|
|
66
|
+
* 只是从"返回枚举"变成"带根因的有序表"。
|
|
67
|
+
*/
|
|
68
|
+
const MATCHERS = [
|
|
69
|
+
{
|
|
70
|
+
kind: "no-probe",
|
|
71
|
+
cause: "openocd 找不到 CMSIS-DAP 探针(没插好 / 被占用 / 本机没认到 USB 设备)",
|
|
72
|
+
re: /unable to find a matching cmsis-dap device|no device found/u,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
kind: "probe-busy",
|
|
76
|
+
cause: "探针被另一个进程攥着(adapter 初始化没抢到)",
|
|
77
|
+
re: /adapter speed could not be limited|target is openocd and must be halted/u,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
// 真板子取证(2026-10-28):两个 openocd 同时抓同一个 CMSIS-DAP 时,openocd 不会报"忙",
|
|
81
|
+
// 而是两边交替收发导致 DAP 事务错位——满屏 transfer count mismatch / command mismatch。
|
|
82
|
+
kind: "probe-busy",
|
|
83
|
+
cause: "探针被另一个进程同时访问(CMSIS-DAP 的收发包错位)",
|
|
84
|
+
re: /cmsis-dap (transfer count mismatch|command mismatch)|cmsis-dap command cmd_\w+ failed|libusb_error_busy/u,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
kind: "swd-locked",
|
|
88
|
+
cause: "芯片侧 SWD 连不上(固件关了调试口 / 调试访问口被锁)",
|
|
89
|
+
re: /error connecting dp|cannot read idr|ap lock|sticky error/u,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
kind: "flash-protected",
|
|
93
|
+
cause: "Flash 被写保护/读保护挡住",
|
|
94
|
+
re: /flash programming|write protected|read protected|memory protected/u,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
kind: "no-power",
|
|
98
|
+
cause: "目标芯片供电不足或没供电",
|
|
99
|
+
re: /target voltage may be too low|no power/u,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
kind: "target-mismatch",
|
|
103
|
+
cause: "连上的芯片 ID 与 target 配置(stm32f1x)不一致",
|
|
104
|
+
re: /device id|cannot identify|unexpected idcode/u,
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
/** 一条"看起来像根因"的行;只用于 unknown / 超时的 evidence 兜底。 */
|
|
108
|
+
const PROBLEM_LINE_RE = /error|unable to find|no device found|couldn't bind|cannot open|invalid/u;
|
|
109
|
+
const MAX_EVIDENCE = 4;
|
|
110
|
+
function nonEmpty(lines) {
|
|
111
|
+
return lines.filter((line) => line.trim() !== "");
|
|
112
|
+
}
|
|
113
|
+
/** 命中同一特征的所有原始行(逐字保留,去重,最多 MAX_EVIDENCE 条)。 */
|
|
114
|
+
function evidenceOf(lines, re) {
|
|
115
|
+
const kept = [];
|
|
116
|
+
const seen = new Set();
|
|
117
|
+
for (const line of lines) {
|
|
118
|
+
if (!re.test(line.toLowerCase()))
|
|
119
|
+
continue;
|
|
120
|
+
if (seen.has(line))
|
|
121
|
+
continue;
|
|
122
|
+
seen.add(line);
|
|
123
|
+
kept.push(line);
|
|
124
|
+
if (kept.length >= MAX_EVIDENCE)
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return kept;
|
|
128
|
+
}
|
|
129
|
+
/** 日志里第一条真正说明问题的行(给 message 用,避免只报"起不来")。 */
|
|
130
|
+
export function firstProblemLine(lines) {
|
|
131
|
+
const hit = lines.find((line) => /^Error|unable to find|no device found|couldn't bind|cannot open|invalid/i.test(line));
|
|
132
|
+
return (hit ?? lines[lines.length - 1] ?? "").trim();
|
|
133
|
+
}
|
|
134
|
+
/** openocd 报"找不到设备"的那几行错误行(2a 的判定基准,纯函数便于单测)。 */
|
|
135
|
+
export function probeMissingLines(errors) {
|
|
136
|
+
return errors.filter((line) => /CMSIS-DAP device|no device found/iu.test(line));
|
|
137
|
+
}
|
|
138
|
+
/** USB 形态诊断的结论该以什么 note 呈现(unknown 静默:诊断失败不能把失败报告搞得更吵)。 */
|
|
139
|
+
export function usbNoteFor(kind, detail) {
|
|
140
|
+
if (kind === "unknown")
|
|
141
|
+
return null;
|
|
142
|
+
return "USB 形态:" + detail;
|
|
143
|
+
}
|
|
144
|
+
/** 每一类的默认根因(调用方没给更准的说法时用它,避免出现"未知原因"这种废话)。 */
|
|
145
|
+
const CAUSE_BY_KIND = {
|
|
146
|
+
"no-probe": "找不到 CMSIS-DAP 探针(没插好 / 被占用 / 本机没认到 USB 设备)",
|
|
147
|
+
"probe-busy": "探针或探针口被另一个进程占着",
|
|
148
|
+
"swd-locked": "芯片侧 SWD 连不上(固件关了调试口 / 调试访问口被锁)",
|
|
149
|
+
"flash-protected": "Flash 被写保护/读保护挡住",
|
|
150
|
+
"no-power": "目标芯片供电不足或没供电",
|
|
151
|
+
"target-mismatch": "连上的芯片 ID 与 target 配置(stm32f1x)不一致",
|
|
152
|
+
timeout: "超时",
|
|
153
|
+
unknown: "有失败但日志特征都不命中,分不出是哪一类原因",
|
|
154
|
+
};
|
|
155
|
+
export function buildProbeError(kind, cause, evidence) {
|
|
156
|
+
return { kind, cause, hint: HINT_BY_KIND[kind], evidence, retryable: RETRYABLE_BY_KIND[kind] };
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 直接按类构造一条 ProbeError(B3 端口被占这种"没有 openocd 日志可归类"的场景用)。
|
|
160
|
+
* hint / retryable 仍然只有一份真相:都来自同一张表。
|
|
161
|
+
*/
|
|
162
|
+
export function makeProbeError(kind, detail = {}) {
|
|
163
|
+
return buildProbeError(kind, detail.cause ?? CAUSE_BY_KIND[kind], detail.evidence ?? []);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 把一次失败归到 8 类之一(B2 的唯一分类入口)。
|
|
167
|
+
*
|
|
168
|
+
* 判定顺序:日志特征(MATCHERS,先见者优先)→ 超时 → 进程没起来 → unknown。
|
|
169
|
+
* 具体特征优先于超时:既打印了 "Error connecting DP" 又超时的,说"锁片"比说"超时"有用。
|
|
170
|
+
*/
|
|
171
|
+
export function classifyProbeFailure(input) {
|
|
172
|
+
const lines = nonEmpty(input.lines);
|
|
173
|
+
for (const matcher of MATCHERS) {
|
|
174
|
+
const evidence = evidenceOf(lines, matcher.re);
|
|
175
|
+
if (evidence.length > 0)
|
|
176
|
+
return buildProbeError(matcher.kind, matcher.cause, evidence);
|
|
177
|
+
}
|
|
178
|
+
if (input.timedOut === true) {
|
|
179
|
+
const timeoutLines = evidenceOf(lines, /timed out|timeout/u);
|
|
180
|
+
const evidence = timeoutLines.length > 0 ? timeoutLines : lines.slice(-1);
|
|
181
|
+
return buildProbeError("timeout", CAUSE_TIMEOUT[input.stage], evidence);
|
|
182
|
+
}
|
|
183
|
+
const spawnError = input.spawnError ?? "";
|
|
184
|
+
if (spawnError.trim() !== "") {
|
|
185
|
+
return buildProbeError("unknown", input.stage === "flash" ? "openocd 启动失败:" + spawnError.trim() : "调试进程启动失败:" + spawnError.trim(), [spawnError.trim()]);
|
|
186
|
+
}
|
|
187
|
+
const problems = evidenceOf(lines, PROBLEM_LINE_RE);
|
|
188
|
+
const evidence = problems.length > 0 ? problems : lines.slice(-MAX_EVIDENCE);
|
|
189
|
+
const exitText = input.exitCode === undefined || input.exitCode === null ? "" : "(退出码 " + String(input.exitCode) + ")";
|
|
190
|
+
return buildProbeError("unknown", "有失败但日志特征都不命中,分不出是哪一类原因" + exitText, evidence);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 工具层 output schema 里的 probeError 片段:flash / debug(以及后续会话)共用同一份,
|
|
194
|
+
* 加一个 kind 只改这里。**不进 required** —— 成功路径引擎给 null,而宿主不接受 null,
|
|
195
|
+
* 工具层会用 flashReportForHost / debugReportForHost 把 null 摘掉再交给宿主。
|
|
196
|
+
*/
|
|
197
|
+
export const PROBE_ERROR_SCHEMA = {
|
|
198
|
+
type: "object",
|
|
199
|
+
additionalProperties: false,
|
|
200
|
+
properties: {
|
|
201
|
+
kind: { type: "string", enum: [...PROBE_ERROR_KINDS] },
|
|
202
|
+
cause: { type: "string" },
|
|
203
|
+
hint: { type: "string" },
|
|
204
|
+
evidence: { type: "array", items: { type: "string" } },
|
|
205
|
+
retryable: { type: "boolean" },
|
|
206
|
+
},
|
|
207
|
+
required: ["kind", "cause", "hint", "evidence", "retryable"],
|
|
208
|
+
};
|
|
209
|
+
/** 报告卡片与 errors 摘要统一用这句:「错误:<kind> — <cause>;建议:<hint>」。 */
|
|
210
|
+
export function formatProbeError(error) {
|
|
211
|
+
return "错误:" + error.kind + " — " + error.cause + ";建议:" + error.hint;
|
|
212
|
+
}
|