@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
@@ -0,0 +1,80 @@
1
+ // ---------------------------------------------------------------------------
2
+ // runners.ts — read west's resolved runner facts from a built Zephyr tree.
3
+ //
4
+ // After any successful `west build`, Zephyr writes build/zephyr/runners.yaml —
5
+ // the FULLY RESOLVED debug/flash configuration for the board: the arch gdb
6
+ // binary, the openocd binary + its script search dirs, the jlink device name,
7
+ // the board's declared default debug runner. It is the single source of debug
8
+ // truth west itself uses (`west debug` / `west debugserver` read the same
9
+ // file), so cuttlefish reads it instead of reconstructing any of this.
10
+ //
11
+ // The parser below is deliberately minimal: it understands exactly the shape
12
+ // west's run_common.py emits — top-level scalars, a list section whose items
13
+ // sit at column 0, and a nested config map — and ignores everything else
14
+ // (e.g. the args section). A general YAML dependency is not worth it for one
15
+ // machine-generated file.
16
+ // ---------------------------------------------------------------------------
17
+
18
+ import fs from 'node:fs';
19
+ import { join } from 'node:path';
20
+
21
+ export interface RunnersFacts {
22
+ /** The board's declared default debug runner (e.g. 'openocd', 'jlink'). */
23
+ readonly debugRunner?: string;
24
+ /** Absolute path to the arch gdb binary (config.gdb). */
25
+ readonly gdb?: string;
26
+ /** All runners the board configured. */
27
+ readonly runners: readonly string[];
28
+ }
29
+
30
+ /**
31
+ * Parse the subset of runners.yaml cuttlefish consumes. Exported for tests.
32
+ * Returns undefined on shapes it does not understand (callers treat as
33
+ * "no facts" — never crash a build over diagnostics data).
34
+ */
35
+ export function parseRunnersYaml(text: string): RunnersFacts | undefined {
36
+ const runners: string[] = [];
37
+ let debugRunner: string | undefined;
38
+ let gdb: string | undefined;
39
+ // Section state: '' = top level, 'runners' = the list, 'config' = the map.
40
+ let section: '' | 'runners' | 'config' = '';
41
+
42
+ for (const rawLine of text.split(/\r?\n/)) {
43
+ const trimmed = rawLine.trim();
44
+ if (trimmed.startsWith('#') || trimmed === '') continue;
45
+
46
+ // List items — west writes the runners list at column 0 and
47
+ // openocd_search indented; both belong to the last-opened section.
48
+ if (trimmed.startsWith('- ')) {
49
+ const item = trimmed.slice(2).trim();
50
+ if (section === 'runners') runners.push(item);
51
+ continue; // other sections' lists (openocd_search, args) are unused
52
+ }
53
+
54
+ const indent = rawLine.length - rawLine.trimStart().length;
55
+ const m = trimmed.match(/^([A-Za-z0-9_.-]+):\s*(.*)$/);
56
+ if (!m) continue; // e.g. west's empty-list `[]` lines — skip, don't bail
57
+
58
+ const [, key, value] = m;
59
+ if (indent === 0) {
60
+ if (key === 'runners') { section = 'runners'; continue; }
61
+ if (key === 'config') { section = 'config'; continue; }
62
+ section = '';
63
+ if (key === 'debug-runner' && value) debugRunner = value.trim();
64
+ continue;
65
+ }
66
+ if (section === 'config' && key === 'gdb' && value) {
67
+ gdb = value.trim().replace(/^['"]|['"]$/g, '');
68
+ }
69
+ }
70
+ return { runners, ...(debugRunner ? { debugRunner } : {}), ...(gdb ? { gdb } : {}) };
71
+ }
72
+
73
+ /** Read the resolved runner facts for a build dir. undefined when absent/unparseable. */
74
+ export function readRunnersFacts(buildDir: string): RunnersFacts | undefined {
75
+ try {
76
+ return parseRunnersYaml(fs.readFileSync(join(buildDir, 'zephyr', 'runners.yaml'), 'utf-8'));
77
+ } catch {
78
+ return undefined;
79
+ }
80
+ }