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

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 (185) hide show
  1. package/README.md +22 -47
  2. package/dist/as-built.d.ts +33 -0
  3. package/dist/as-built.js +188 -0
  4. package/dist/async/timer-polyfill.js +1 -1
  5. package/dist/boardgen.d.ts +128 -0
  6. package/dist/boardgen.js +1366 -0
  7. package/dist/chips/board-overrides.d.ts +7 -0
  8. package/dist/chips/board-overrides.js +11 -0
  9. package/dist/chips/esp32s3.js +49 -0
  10. package/dist/chips/index.d.ts +6 -12
  11. package/dist/chips/index.js +18 -34
  12. package/dist/chips/resolve.d.ts +16 -2
  13. package/dist/chips/resolve.js +267 -10
  14. package/dist/chips/soc/.d.ts +2 -0
  15. package/dist/chips/soc/.js +129 -0
  16. package/dist/chips/soc/esp32.d.ts +2 -0
  17. package/dist/chips/soc/esp32.js +120 -0
  18. package/dist/chips/soc/esp32c3.d.ts +2 -0
  19. package/dist/chips/soc/esp32c3.js +90 -0
  20. package/dist/chips/soc/esp32c6.d.ts +2 -0
  21. package/dist/chips/soc/esp32c6.js +109 -0
  22. package/dist/chips/soc/esp32s3.d.ts +2 -0
  23. package/dist/chips/soc/esp32s3.js +189 -0
  24. package/dist/chips/soc/index.d.ts +2 -0
  25. package/dist/chips/soc/index.js +23 -0
  26. package/dist/chips/soc/nrf52840.d.ts +2 -0
  27. package/dist/chips/soc/nrf52840.js +130 -0
  28. package/dist/chips/soc/rp2040.d.ts +2 -0
  29. package/dist/chips/soc/rp2040.js +141 -0
  30. package/dist/chips/soc/rp2350a.d.ts +2 -0
  31. package/dist/chips/soc/rp2350a.js +145 -0
  32. package/dist/chips/soc/samd21g18a.d.ts +2 -0
  33. package/dist/chips/soc/samd21g18a.js +143 -0
  34. package/dist/chips/soc/stm32f411xe.d.ts +2 -0
  35. package/dist/chips/soc/stm32f411xe.js +251 -0
  36. package/dist/chips/types.d.ts +319 -0
  37. package/dist/chips/xiao-ble.js +21 -0
  38. package/dist/display/profiles.js +1 -1
  39. package/dist/doctor.js +38 -4
  40. package/dist/dt-config/custom-board.d.ts +23 -0
  41. package/dist/dt-config/custom-board.js +227 -0
  42. package/dist/dt-config/kconfig.d.ts +72 -1
  43. package/dist/dt-config/kconfig.js +115 -26
  44. package/dist/dt-config/overlay.js +548 -28
  45. package/dist/framework.manifest.d.ts +3 -3
  46. package/dist/framework.manifest.js +122 -185
  47. package/dist/index.d.ts +4 -1
  48. package/dist/index.js +8 -2
  49. package/dist/lowering/adc.d.ts +20 -2
  50. package/dist/lowering/adc.js +121 -29
  51. package/dist/lowering/ble.js +31 -28
  52. package/dist/lowering/dac.js +9 -9
  53. package/dist/lowering/fs.js +18 -10
  54. package/dist/lowering/gpio.d.ts +2 -0
  55. package/dist/lowering/gpio.js +82 -5
  56. package/dist/lowering/http.js +39 -14
  57. package/dist/lowering/hwtimer.d.ts +4 -0
  58. package/dist/lowering/hwtimer.js +35 -10
  59. package/dist/lowering/i2c.js +46 -54
  60. package/dist/lowering/index.d.ts +5 -5
  61. package/dist/lowering/index.js +15 -16
  62. package/dist/lowering/interrupts.d.ts +22 -5
  63. package/dist/lowering/interrupts.js +104 -22
  64. package/dist/lowering/mqtt.js +3 -5
  65. package/dist/lowering/power.js +0 -4
  66. package/dist/lowering/preferences.js +49 -77
  67. package/dist/lowering/pulse.js +0 -31
  68. package/dist/lowering/pwm.d.ts +12 -1
  69. package/dist/lowering/pwm.js +78 -14
  70. package/dist/lowering/random.js +3 -3
  71. package/dist/lowering/sensor.d.ts +37 -0
  72. package/dist/lowering/sensor.js +119 -0
  73. package/dist/lowering/spi.d.ts +12 -0
  74. package/dist/lowering/spi.js +65 -40
  75. package/dist/lowering/thread.d.ts +14 -0
  76. package/dist/lowering/thread.js +55 -0
  77. package/dist/lowering/timing.js +20 -46
  78. package/dist/lowering/tone.js +16 -4
  79. package/dist/lowering/uart.d.ts +13 -0
  80. package/dist/lowering/uart.js +72 -51
  81. package/dist/lowering/usb.d.ts +34 -0
  82. package/dist/lowering/usb.js +206 -0
  83. package/dist/lowering/wdt.d.ts +1 -1
  84. package/dist/lowering/wdt.js +17 -7
  85. package/dist/lowering/wifi.d.ts +3 -2
  86. package/dist/lowering/wifi.js +97 -111
  87. package/dist/sdk/board-catalog-sync.d.ts +16 -0
  88. package/dist/sdk/board-catalog-sync.js +41 -0
  89. package/dist/sdk/board-data.generated.d.ts +2 -0
  90. package/dist/sdk/board-data.generated.js +4 -0
  91. package/dist/sdk/catalog-walker.d.ts +90 -0
  92. package/dist/sdk/catalog-walker.js +682 -0
  93. package/dist/sdk/dts-reader.d.ts +83 -0
  94. package/dist/sdk/dts-reader.js +596 -0
  95. package/dist/strategy.d.ts +136 -17
  96. package/dist/strategy.js +839 -222
  97. package/dist/toolchain/bossac-touch.d.ts +18 -0
  98. package/dist/toolchain/bossac-touch.js +88 -0
  99. package/dist/toolchain/compat.d.ts +2 -2
  100. package/dist/toolchain/compat.js +8 -3
  101. package/dist/toolchain/debug-config.d.ts +21 -26
  102. package/dist/toolchain/debug-config.js +226 -76
  103. package/dist/toolchain/env-check.d.ts +4 -4
  104. package/dist/toolchain/env-check.js +5 -5
  105. package/dist/toolchain/index.d.ts +115 -1
  106. package/dist/toolchain/index.js +680 -71
  107. package/dist/toolchain/scaffold.js +39 -7
  108. package/dist/toolchain/west-discover.d.ts +4 -0
  109. package/dist/toolchain/west-discover.js +17 -6
  110. package/installer/CHANGELOG.md +473 -0
  111. package/installer/README.md +328 -0
  112. package/installer/environment.yml +46 -0
  113. package/installer/etc/conda/activate.d/zephyr.bat +7 -0
  114. package/installer/etc/conda/activate.d/zephyr.ps1 +12 -0
  115. package/installer/etc/conda/activate.d/zephyr.sh +20 -0
  116. package/installer/etc/conda/deactivate.d/zephyr.bat +6 -0
  117. package/installer/etc/conda/deactivate.d/zephyr.ps1 +6 -0
  118. package/installer/etc/conda/deactivate.d/zephyr.sh +4 -0
  119. package/installer/install.mjs +580 -0
  120. package/installer/install.ps1 +619 -0
  121. package/installer/install.sh +310 -0
  122. package/installer/lib/detect-platform.sh +62 -0
  123. package/installer/lib/fetch-sdk.sh +304 -0
  124. package/installer/lib/init-workspace.sh +153 -0
  125. package/installer/lib/write-activation.sh +76 -0
  126. package/installer/patches/tfm-c-include-separators.patch +19 -0
  127. package/installer/patches/zephyr-tfm-nordic-zephyr-include.patch +24 -0
  128. package/installer/templates/project/.typecad/activate-zephyr.ps1 +31 -0
  129. package/installer/templates/project/.typecad/activate-zephyr.sh +31 -0
  130. package/installer/templates/project/.vscode/settings.json +30 -0
  131. package/installer/templates/project/README.md +58 -0
  132. package/installer/versions.env +110 -0
  133. package/package.json +15 -15
  134. package/src/as-built.ts +206 -0
  135. package/src/boardgen.ts +1428 -0
  136. package/src/chips/index.ts +35 -54
  137. package/src/chips/resolve.ts +285 -10
  138. package/src/chips/types.ts +325 -1
  139. package/src/display/profiles.ts +1 -1
  140. package/src/doctor.ts +110 -77
  141. package/src/dt-config/custom-board.ts +325 -0
  142. package/src/dt-config/kconfig.ts +165 -18
  143. package/src/dt-config/overlay.ts +537 -25
  144. package/src/framework.manifest.ts +123 -185
  145. package/src/index.ts +57 -41
  146. package/src/lowering/adc.ts +222 -118
  147. package/src/lowering/ble.ts +32 -28
  148. package/src/lowering/dac.ts +82 -82
  149. package/src/lowering/fs.ts +18 -10
  150. package/src/lowering/gpio.ts +242 -155
  151. package/src/lowering/http.ts +512 -488
  152. package/src/lowering/hwtimer.ts +139 -101
  153. package/src/lowering/i2c.ts +116 -126
  154. package/src/lowering/index.ts +91 -93
  155. package/src/lowering/interrupts.ts +113 -21
  156. package/src/lowering/mqtt.ts +3 -5
  157. package/src/lowering/preferences.ts +327 -354
  158. package/src/lowering/pwm.ts +167 -99
  159. package/src/lowering/random.ts +3 -3
  160. package/src/lowering/sensor.ts +155 -0
  161. package/src/lowering/spi.ts +164 -124
  162. package/src/lowering/thread.ts +63 -0
  163. package/src/lowering/timing.ts +46 -72
  164. package/src/lowering/uart.ts +73 -51
  165. package/src/lowering/usb.ts +221 -0
  166. package/src/lowering/wdt.ts +95 -84
  167. package/src/lowering/wifi.ts +97 -112
  168. package/src/sdk/board-catalog-sync.ts +62 -0
  169. package/src/strategy.ts +848 -237
  170. package/src/toolchain/bossac-touch.ts +112 -0
  171. package/src/toolchain/compat.ts +8 -3
  172. package/src/toolchain/debug-config.ts +676 -522
  173. package/src/toolchain/env-check.ts +9 -9
  174. package/src/toolchain/index.ts +1359 -645
  175. package/src/toolchain/scaffold.ts +38 -7
  176. package/src/toolchain/west-discover.ts +19 -6
  177. package/src/async/timer-polyfill.ts +0 -107
  178. package/src/chips/esp32.ts +0 -74
  179. package/src/chips/esp32s3.ts +0 -57
  180. package/src/chips/xiao-ble.ts +0 -82
  181. package/src/lowering/power.ts +0 -70
  182. package/src/lowering/pulse.ts +0 -93
  183. package/src/lowering/tone.ts +0 -60
  184. package/src/lowering/worker-backing.ts +0 -94
  185. package/src/lowering/worker.ts +0 -17
@@ -1,4 +1,32 @@
1
1
  import type { ToolchainOptions, CompileResult, UploadResult } from '@typecad/cuttlefish/api/shared';
2
+ import type { ZephyrChipDescriptor } from '../chips/types.js';
3
+ /**
4
+ * Distinct DT-bound sensors the emitted sources reference — the lowering's
5
+ * state blocks name each one `__tc_sensor_<part>_i2c<N>_0x<addr>_dev`
6
+ * (lowering/sensor.ts sensorNames), so var-presence is the authoritative
7
+ * signal. Feeds the overlay's DT child nodes; the part group is greedy so a
8
+ * compatible containing '_i2c<N>_' still resolves to the longest part match.
9
+ */
10
+ export interface ScannedSensorPart {
11
+ part: string;
12
+ busIndex: number;
13
+ port: number;
14
+ busKind: 'i2c' | 'spi';
15
+ spiHz: number;
16
+ spiMode: number;
17
+ alertPin: number;
18
+ }
19
+ export interface ScannedSpiTarget {
20
+ busIndex: number;
21
+ cs: number;
22
+ hz: number;
23
+ mode: number;
24
+ }
25
+ /** Scan the emitted source for thin SPI targets (hal/spi-target.ts): the
26
+ * spi_dt_spec state block's tc-spit-cfg comment carries the construction
27
+ * facts, the same channel tc-sensor-cfg uses. */
28
+ export declare function scanSpiTargets(src: string): ScannedSpiTarget[];
29
+ export declare function scanSensorParts(src: string): ScannedSensorPart[];
2
30
  /**
3
31
  * Derive the Zephyr project root from the cuttlefish-emitted source path.
4
32
  *
@@ -26,7 +54,83 @@ export declare function projectRootFromOptions(o: ToolchainOptions): string;
26
54
  * Exported (pure) so the runner-selection contract is unit-testable without
27
55
  * spawning west.
28
56
  */
29
- export declare function buildFlashArgs(buildDir: string, board: string, userRunner: string | undefined, port: string | undefined, runnerArgs?: readonly string[]): string[];
57
+ /**
58
+ * Resolve HOW this build attaches to the board for flashing OR debugging:
59
+ * the friendly `zephyr.probe` id from the board's probeMethods table (quirks
60
+ * included), or the raw `zephyr.runner` escape hatch. Exported (pure) so the
61
+ * selection contract is unit-testable without spawning west.
62
+ *
63
+ * Rules:
64
+ * - `probe` + `runner` together is an error (two ways of saying it — pick one).
65
+ * - An unknown `probe` id is an error listing what the board supports; a board
66
+ * with no probeMethods table gets a hint to use `runner` directly.
67
+ * - purpose 'debug': the chosen method must be debug-capable (`debug` is not
68
+ * false — a bootloader is not a debugger). Non-capable or unknown ids list
69
+ * the debug-capable methods.
70
+ * - User `runnerArgs` are appended AFTER the method's args, so they can
71
+ * override the method's baked-in flags (argparse takes the last value).
72
+ */
73
+ export type ProbeResolution = {
74
+ ok: true;
75
+ runner?: string;
76
+ args: string[];
77
+ } | {
78
+ ok: false;
79
+ error: string;
80
+ };
81
+ export declare function resolveProbeMethod(zc: Record<string, unknown> | undefined, chip: ZephyrChipDescriptor, purpose?: 'flash' | 'debug'): ProbeResolution;
82
+ /**
83
+ * Run an openocd session against the board's probe config — the shared
84
+ * engine for the pre-flash quiesce and the post-flash SYSRESETREQ (see the
85
+ * call sites in upload()). The config is the probe method's verbatim
86
+ * debugCfg from the board catalog (the same lines `west debug` uses);
87
+ * `commands` are appended after `-f <cfg> -c init`. Returns a flash note on
88
+ * success, undefined when skipped or failed (best-effort by design).
89
+ */
90
+ /**
91
+ * Resolve the openocd binary (plus script search dirs) for the probe session.
92
+ *
93
+ * Resolution order mirrors how west's own openocd runner finds the binary, so
94
+ * the session and `west flash` drive the SAME openocd:
95
+ * 1. $OPENOCD — the variable Zephyr's CMake reads into the build cache.
96
+ * 2. A Zephyr-SDK-hosted install ($ZEPHYR_SDK_INSTALL_DIR, else the
97
+ * discovered west install's SDK). Layout differs by SDK generation —
98
+ * hosttools/openocd/share/openocd/scripts vs hosttools/openocd/scripts —
99
+ * so both script dirs are collected.
100
+ * 3. PATH — Linux distro / conda / micromamba installs (a micromamba-env
101
+ * openocd is the common Linux setup; the SDK layout check alone made the
102
+ * deterministic probe session unreachable there, silently dropping every
103
+ * Linux flash to the racy `west flash` fallback).
104
+ *
105
+ * A non-SDK binary resolves with no explicit -s dirs: it finds its own
106
+ * interface/target scripts via its compiled-in search path. Returns undefined
107
+ * when no openocd can be found (the caller then uses the west fallback).
108
+ *
109
+ * Exported (pure) so the resolution contract is unit-testable without
110
+ * spawning openocd.
111
+ */
112
+ export interface SessionOpenOcd {
113
+ readonly exe: string;
114
+ readonly searchDirs: readonly string[];
115
+ }
116
+ export declare function resolveSessionOpenOcd(env?: {
117
+ OPENOCD?: string | undefined;
118
+ ZEPHYR_SDK_INSTALL_DIR?: string | undefined;
119
+ PATH?: string | undefined;
120
+ }, sdkInstallDir?: string): SessionOpenOcd | undefined;
121
+ /**
122
+ * Whether a flash runner carries the upload over a serial port. Runner-gated,
123
+ * never board-name-gated: esptool and bossac are the only runners
124
+ * `buildFlashArgs` forwards `--port` to, so they are the only ones that
125
+ * cannot flash without one. Probe runners (openocd, jlink) and USB flows
126
+ * (dfu-util, uf2 mass storage) need no port — a missing `--port` must not
127
+ * block them.
128
+ *
129
+ * Exported (pure) so the port-requirement contract is unit-testable without
130
+ * spawning west.
131
+ */
132
+ export declare function uploadRequiresPort(runner: string | undefined): boolean;
133
+ export declare function buildFlashArgs(buildDir: string, userRunner: string | undefined, port: string | undefined, flashRunner?: string, runnerArgs?: readonly string[]): string[];
30
134
  /**
31
135
  * Classify a `west flash` result as success/failure.
32
136
  *
@@ -46,6 +150,16 @@ export declare function buildFlashArgs(buildDir: string, board: string, userRunn
46
150
  * Exported (pure) so the classification is unit-testable without spawning west.
47
151
  */
48
152
  export declare function classifyUploadResult(runner: string | undefined, status: number | null, output: string): boolean;
153
+ /**
154
+ * Whether a `west flash` (openocd) output carries one of the known
155
+ * target-ignored-SWD signatures — the DAP connect failing ("init mode
156
+ * failed (unable to connect to the target)", i.e. the DPIDR read never
157
+ * succeeded) or a reset/halt never landing ("timed out while waiting for
158
+ * target halted" / "TARGET: <name> - Not halted"). Both mean the board (or
159
+ * probe) needs a power-cycle or the SWD-free DFU path, not a retry of the
160
+ * same command. Centralized so the upload hint stays testable.
161
+ */
162
+ export declare function isTargetSwdFailure(output: string): boolean;
49
163
  /**
50
164
  * Cleanse the `west flash` output shown to the user.
51
165
  *