@typecad/framework-zephyr 1.0.0-alpha.16 → 1.0.0-alpha.18

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.
Files changed (132) hide show
  1. package/LICENSE +202 -21
  2. package/README.md +49 -87
  3. package/dist/as-built.d.ts +2 -2
  4. package/dist/as-built.js +2 -2
  5. package/dist/boardgen.d.ts +1 -9
  6. package/dist/boardgen.js +228 -45
  7. package/dist/chips/types.d.ts +1 -1
  8. package/dist/debug-codegen.js +1 -1
  9. package/dist/display/touch-adapter.js +1 -1
  10. package/dist/display/ui-adapter.js +549 -549
  11. package/dist/doctor.js +4 -4
  12. package/dist/dt-config/custom-board.js +2 -2
  13. package/dist/dt-config/kconfig.js +18 -12
  14. package/dist/dt-config/overlay.d.ts +2 -2
  15. package/dist/dt-config/overlay.js +2 -2
  16. package/dist/framework.manifest.d.ts +3 -3
  17. package/dist/framework.manifest.js +10 -7
  18. package/dist/index.js +5 -5
  19. package/dist/licenses.d.ts +2 -2
  20. package/dist/licenses.js +8 -8
  21. package/dist/lowering/fs.js +1 -1
  22. package/dist/lowering/gpio.js +0 -32
  23. package/dist/lowering/http.js +264 -32
  24. package/dist/lowering/i2c.js +0 -8
  25. package/dist/lowering/interrupts.js +6 -0
  26. package/dist/lowering/mqtt.js +110 -8
  27. package/dist/lowering/usb.js +11 -11
  28. package/dist/lowering/wdt.js +2 -29
  29. package/dist/sdk/board-catalog-sync.d.ts +1 -3
  30. package/dist/sdk/board-catalog-sync.js +4 -10
  31. package/dist/strategy.d.ts +22 -44
  32. package/dist/strategy.js +152 -155
  33. package/dist/tmp-probe.d.ts +2 -0
  34. package/dist/tmp-probe.js +9 -0
  35. package/dist/toolchain/debug-config.d.ts +50 -90
  36. package/dist/toolchain/debug-config.js +239 -510
  37. package/dist/toolchain/env-check.d.ts +1 -3
  38. package/dist/toolchain/env-check.js +2 -7
  39. package/dist/toolchain/index.d.ts +16 -2
  40. package/dist/toolchain/index.js +383 -35
  41. package/dist/toolchain/runners.d.ts +16 -0
  42. package/dist/toolchain/runners.js +75 -0
  43. package/dist/toolchain/scaffold.d.ts +1 -1
  44. package/dist/toolchain/scaffold.js +12 -12
  45. package/dist/toolchain/west-discover.d.ts +6 -0
  46. package/dist/toolchain/west-discover.js +36 -13
  47. package/dist/toolchain/west-spawn.js +8 -2
  48. package/installer/README.md +328 -328
  49. package/installer/install.sh +2 -2
  50. package/installer/templates/project/.typecad/activate-zephyr.ps1 +1 -1
  51. package/installer/templates/project/.typecad/activate-zephyr.sh +1 -1
  52. package/installer/templates/project/.vscode/settings.json +1 -1
  53. package/installer/templates/project/README.md +2 -2
  54. package/package.json +5 -5
  55. package/src/as-built.ts +206 -206
  56. package/src/boardgen.ts +214 -48
  57. package/src/chips/types.ts +567 -567
  58. package/src/display/touch-adapter.ts +204 -204
  59. package/src/display/ui-adapter.ts +781 -781
  60. package/src/doctor.ts +4 -4
  61. package/src/dt-config/custom-board.ts +2 -2
  62. package/src/dt-config/kconfig.ts +18 -12
  63. package/src/dt-config/overlay.ts +1058 -1058
  64. package/src/framework.manifest.ts +538 -535
  65. package/src/index.ts +5 -5
  66. package/src/licenses.ts +425 -425
  67. package/src/lowering/fs.ts +135 -135
  68. package/src/lowering/gpio.ts +0 -33
  69. package/src/lowering/http.ts +264 -32
  70. package/src/lowering/i2c.ts +0 -9
  71. package/src/lowering/interrupts.ts +6 -0
  72. package/src/lowering/mqtt.ts +109 -8
  73. package/src/lowering/usb.ts +221 -221
  74. package/src/lowering/wdt.ts +2 -25
  75. package/src/sdk/board-catalog-sync.ts +4 -25
  76. package/src/strategy.ts +2265 -2309
  77. package/src/toolchain/debug-config.ts +262 -522
  78. package/src/toolchain/env-check.ts +279 -285
  79. package/src/toolchain/index.ts +1703 -1359
  80. package/src/toolchain/runners.ts +80 -0
  81. package/src/toolchain/scaffold.ts +296 -296
  82. package/src/toolchain/west-discover.ts +35 -13
  83. package/src/toolchain/west-spawn.ts +174 -168
  84. package/dist/async/timer-polyfill.d.ts +0 -10
  85. package/dist/async/timer-polyfill.js +0 -95
  86. package/dist/chips/board-overrides.d.ts +0 -7
  87. package/dist/chips/board-overrides.js +0 -11
  88. package/dist/chips/esp32.d.ts +0 -2
  89. package/dist/chips/esp32.js +0 -71
  90. package/dist/chips/esp32s3.d.ts +0 -2
  91. package/dist/chips/esp32s3.js +0 -103
  92. package/dist/chips/soc/.d.ts +0 -2
  93. package/dist/chips/soc/.js +0 -129
  94. package/dist/chips/soc/esp32.d.ts +0 -2
  95. package/dist/chips/soc/esp32.js +0 -120
  96. package/dist/chips/soc/esp32c3.d.ts +0 -2
  97. package/dist/chips/soc/esp32c3.js +0 -90
  98. package/dist/chips/soc/esp32c6.d.ts +0 -2
  99. package/dist/chips/soc/esp32c6.js +0 -109
  100. package/dist/chips/soc/esp32s3.d.ts +0 -2
  101. package/dist/chips/soc/esp32s3.js +0 -189
  102. package/dist/chips/soc/index.d.ts +0 -2
  103. package/dist/chips/soc/index.js +0 -23
  104. package/dist/chips/soc/nrf52840.d.ts +0 -2
  105. package/dist/chips/soc/nrf52840.js +0 -130
  106. package/dist/chips/soc/rp2040.d.ts +0 -2
  107. package/dist/chips/soc/rp2040.js +0 -141
  108. package/dist/chips/soc/rp2350a.d.ts +0 -2
  109. package/dist/chips/soc/rp2350a.js +0 -145
  110. package/dist/chips/soc/samd21g18a.d.ts +0 -2
  111. package/dist/chips/soc/samd21g18a.js +0 -143
  112. package/dist/chips/soc/stm32f411xe.d.ts +0 -2
  113. package/dist/chips/soc/stm32f411xe.js +0 -251
  114. package/dist/chips/xiao-ble.d.ts +0 -2
  115. package/dist/chips/xiao-ble.js +0 -100
  116. package/dist/lowering/power.d.ts +0 -9
  117. package/dist/lowering/power.js +0 -60
  118. package/dist/lowering/pulse.d.ts +0 -7
  119. package/dist/lowering/pulse.js +0 -51
  120. package/dist/lowering/tone.d.ts +0 -10
  121. package/dist/lowering/tone.js +0 -63
  122. package/dist/lowering/worker-backing.d.ts +0 -14
  123. package/dist/lowering/worker-backing.js +0 -79
  124. package/dist/lowering/worker.d.ts +0 -6
  125. package/dist/lowering/worker.js +0 -14
  126. package/dist/sdk/board-data.generated.d.ts +0 -2
  127. package/dist/sdk/board-data.generated.js +0 -4
  128. package/dist/sdk/catalog-walker.d.ts +0 -90
  129. package/dist/sdk/catalog-walker.js +0 -682
  130. package/dist/sdk/dts-reader.d.ts +0 -83
  131. package/dist/sdk/dts-reader.js +0 -596
  132. package/src/debug-codegen.ts +0 -207
@@ -1,3 +1,10 @@
1
+ /** The gdb server port west's openocd/jlink runners default to. */
2
+ export declare const DEBUG_SERVER_PORT = 3333;
3
+ /** west's openocd tcl port — pinned in the debugserver invocation and used
4
+ * as the READINESS probe: its listener opens at the END of openocd's init
5
+ * (after the gdb listener and the startup halt), and probe connections
6
+ * there never consume the gdb server's single client slot. */
7
+ export declare const DEBUG_SERVER_TCL_PORT = 6333;
1
8
  export interface DebugConfigOptions {
2
9
  /** Absolute path to the Zephyr project root (contains CMakeLists.txt + src/). */
3
10
  projectRoot: string;
@@ -11,108 +18,61 @@ export interface DebugConfigOptions {
11
18
  buildDir: string;
12
19
  /** Absolute path to the emitted source map (*.thcppmap.json), if any. */
13
20
  sourceMapPath?: string;
21
+ /**
22
+ * Create-time best-effort gdb (from the SDK + the board's silicon) — used
23
+ * only when runners.yaml doesn't exist yet (pre-first-build). The first
24
+ * build's west-resolved gdb replaces it, and a mismatch triggers the
25
+ * artifact rewrite (debugArtifactsNeedRewrite).
26
+ */
27
+ starterGdbPath?: string;
14
28
  }
15
- /**
16
- * Resolve the GDB binary path for the target from the build cache, falling
17
- * back to a filesystem scan of known Zephyr SDK locations when no build
18
- * exists yet (the create-time starter artifacts path). Zephyr records
19
- * ZEPHYR_SDK_INSTALL_DIR in CMakeCache.txt at configure time, and the
20
- * xtensa GDB lives at <sdk>/xtensa-espressif_esp32s3_zephyr-elf/bin/... (note
21
- * the Zephyr-SDK naming, distinct from the ESP-IDF xtensa-esp32s3-elf-gdb).
22
- *
23
- * Returns the absolute gdb path on success, or undefined (the launch.json then
24
- * omits gdbPath and relies on Cortex-Debug's default resolution).
25
- */
26
- export declare function resolveGdbPath(buildDir: string, target: string): string | undefined;
27
- /** The GDB location inside a Zephyr SDK root, per target architecture:
28
- * ARM boards use the arm-zephyr-eabi toolchain (verified against
29
- * zephyr-sdk-0.17.4), Espressif the xtensa-espressif_esp32s3_zephyr-elf one.
30
- * Returns a forward-slash absolute path or undefined. */
31
- export declare function gdbPathFromSdkRoot(sdkRoot: string, target?: string): string | undefined;
32
- /**
33
- * Probe the well-known Zephyr SDK install locations, newest version first:
34
- * 1. $ZEPHYR_SDK_INSTALL_DIR (the var board.cmake reads)
35
- * 2. <MAMBA_ROOT_PREFIX | ~/micromamba>/zephyr-sdk/zephyr-sdk-<ver> — the
36
- * the bundled Zephyr installer layout
37
- * 3. ~/zephyr-sdk-<ver> — the standalone download layout
38
- *
39
- * Only roots that actually contain the esp32s3 GDB are useful to callers;
40
- * this returns candidate roots (gdbPathFromSdkRoot does the existence check)
41
- * so tests can inject home/env overrides.
42
- */
43
- export declare function discoverZephyrSdkRoots(opts?: {
44
- home?: string;
45
- env?: Record<string, string | undefined>;
46
- }): string[];
47
- /**
48
- * Resolve the OpenOCD binary path. The esp32s3 needs the Espressif OpenOCD
49
- * fork (openocd-esp32) — not the Zephyr SDK's openocd and not a
50
- * generic/GDB-stub build — because only it carries the Xtensa + esp_usb_jtag
51
- * support. ARM targets prefer the Zephyr SDK's own openocd (it ships the
52
- * interface/target cfgs boards reference); the Espressif fork is only
53
- * consulted for esp32 targets.
54
- *
55
- * Discovery order:
56
- * 1. ESPRESSIF_TOOLCHAIN_PATH env (the var board.cmake reads) — esp32
57
- * targets; its openocd-esp32/bin/openocd.exe.
58
- * 2. The standard ESP-IDF install layout: ~/.espressif/tools/openocd-esp32/
59
- * <version>/openocd-esp32/bin/openocd.exe (esp32 targets; newest first).
60
- * 3. A Zephyr SDK root (discoverZephyrSdkRoots) — its
61
- * tools/opt/openocd/bin/openocd(.exe), any target.
62
- * Returns undefined if not found (the launch.json then omits openOCDPath and
63
- * Cortex-Debug falls back to PATH / its openocdPath setting).
64
- */
65
- export declare function resolveOpenOcdPath(target?: string): string | undefined;
66
- /**
67
- * Resolve where to write the VS Code debug artifacts and how to express paths
68
- * in them.
69
- *
70
- * VS Code reads `.vscode/` from the folder the user has OPENED — and for a
71
- * cuttlefish project that is almost always the **cuttlefish project root**
72
- * (the directory containing `cuttlefish.config.ts`), NOT the git repo root.
73
- * The toolchain's `projectRoot` is the Zephyr *app* dir (e.g.
74
- * `<projectRoot>/src/out`), which sits below the cuttlefish config dir. So we
75
- * walk up from `projectRoot` to the nearest `cuttlefish.config.ts` and treat
76
- * THAT as the workspace root. This makes F5 work when a user opens the project
77
- * folder directly, and keeps launch.json paths relative to it.
78
- *
79
- * Returns { workspaceRoot, appRel } where workspaceRoot is the cuttlefish
80
- * project root (the `.vscode/` target) and appRel is the Zephyr app dir
81
- * (`projectRoot`) relative to it (e.g. 'src/out').
82
- */
29
+ /** Task labels (also the preLaunchTask/postDebugTask references in launch.json). */
30
+ export declare const DEBUG_BUILD_TASK = "typecad-hal: build + flash (debug)";
31
+ export declare const DEBUG_SERVER_TASK = "typecad-hal: debug server (west)";
32
+ export declare const DEBUG_SERVER_STOP_TASK = "typecad-hal: stop debug server";
83
33
  export declare function resolveDebugLocations(projectRoot: string): {
84
34
  workspaceRoot: string;
85
35
  appRel: string;
86
36
  };
87
37
  /**
88
- * Generate the GDB Python frame-filter that rewrites cuttlefish's hoisted
89
- * lambda frame names (`${prefix}_isr_N`) into readable `<lambda> @ file:line`
90
- * in the call stack. Only emitted when the source map references `_isr_N`
91
- * symbols; otherwise returns null (launch.json omits the `source` initCommand).
92
- *
93
- * Ported verbatim from the deleted framework-esp32/toolchain/gdb-script.ts —
94
- * the filter is cuttlefish-internal (lambda hoisting is framework-agnostic).
38
+ * Whether the workspace's gdb debug artifacts need rewriting: missing, still
39
+ * in an older (self-managed-server) shape, written before a build resolved
40
+ * the gdb path (the create-time starter omits gdbPath), or referencing an app
41
+ * root other than the current one (an outDir rename). Only OUR entries count
42
+ * (`TypeCAD Debug (Zephyr, …)`); user-authored ones are never judged.
95
43
  */
96
- export declare function generateGdbScript(sourceMapPath?: string): string | null;
97
- export declare function writeDebugConfig(o: DebugConfigOptions): void;
44
+ export declare function debugArtifactsNeedRewrite(workspaceRoot: string, appRel: string, currentGdb?: string): boolean;
98
45
  /**
99
- * Create-time starter debug artifacts. Called by the cuttlefish `create` flow
100
- * (via the package's `writeProjectDebugArtifacts` export) so a fresh project
101
- * has a working F5 before any build exists:
102
- *
103
- * The launch.json's preLaunchTask runs `cuttlefish build --compile --upload
104
- * --debug`, which builds + flashes AND rewrites this same launch entry (merged
105
- * by name) with the CMakeCache-resolved gdbPath — so the starter files upgrade
106
- * themselves on the first debug build.
107
- *
108
- * No-ops (returns []) for targets without native GDB support (debugMode() !==
109
- * 'gdb'); the gdb frame-filter script is skipped (no source map exists yet).
46
+ * Write the debug artifacts: the cortex-debug launch entry (merged by name)
47
+ * and the three tasks (merged by label). Returns the workspace-relative
48
+ * paths written, for CLI reporting.
49
+ */
50
+ export declare function writeDebugConfig(o: DebugConfigOptions): string[];
51
+ /**
52
+ * Create-time starter debug artifacts: the same west-driven launch entry and
53
+ * tasks, minus gdbPath (no build exists yet — runners.yaml is absent). The
54
+ * first build upgrades the entry (debugArtifactsNeedRewrite fires on the
55
+ * missing gdbPath), so F5 after a compile is fully resolved.
110
56
  *
111
- * Returns the workspace-relative paths written, for CLI reporting.
57
+ * No-ops (returns []) for targets without gdb debug facts (no debug-capable
58
+ * probe method in the board's table — printf instrumentation territory).
112
59
  */
113
60
  export declare function writeProjectDebugArtifacts(o: {
114
- /** Absolute path to the cuttlefish project root (contains cuttlefish.config.ts). */
61
+ /** Absolute path to the typecad-hal project root (contains typecad-hal.config.ts). */
115
62
  workspaceRoot: string;
116
63
  /** The Zephyr board id from the project config (frameworkData.buildTarget). */
117
64
  buildTarget?: string;
65
+ /**
66
+ * The scaffolded app dir, workspace-relative with forward slashes.
67
+ * Defaults to the standard layout ('src/out'); typecad-hal create passes
68
+ * its config's actual entry + outDir resolution so a non-standard scaffold
69
+ * still gets correct starter paths.
70
+ */
71
+ appRel?: string;
72
+ /**
73
+ * Create-time best-effort gdb from typecad-hal create (SDK + silicon) —
74
+ * see DebugConfigOptions.starterGdbPath. Plain JSON string.
75
+ */
76
+ gdbPath?: string;
118
77
  }): string[];
78
+ export declare function generateGdbScript(sourceMapPath?: string): string | null;