@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
@@ -0,0 +1,251 @@
1
+ // Hand-maintained descriptor table — mechanically migrated from the
2
+ // board-blackpill-f411ce + mcu-stm32f411 package data (the exact flatten+reconstruct the build
3
+ // performed). Curated additions: tier/pinNaming/excludedPins. Regenerate
4
+ // only alongside a descriptor-type change (edit this file; the original
5
+ // migration script was never committed).
6
+ export const STM32F411XE_SOC = {
7
+ "id": "blackpill_f411ce/stm32f411xe",
8
+ "soc": "stm32f411xe",
9
+ "gpioController": "gpioa",
10
+ "gpioControllers": [
11
+ {
12
+ "nodelabel": "gpioa",
13
+ "minPin": 0,
14
+ "maxPin": 15
15
+ },
16
+ {
17
+ "nodelabel": "gpiob",
18
+ "minPin": 16,
19
+ "maxPin": 31
20
+ },
21
+ {
22
+ "nodelabel": "gpioc",
23
+ "minPin": 32,
24
+ "maxPin": 47
25
+ }
26
+ ],
27
+ "gpio": {
28
+ "dtSpecs": [
29
+ {
30
+ "pin": 45,
31
+ "dtSpec": "led0"
32
+ },
33
+ {
34
+ "pin": 0,
35
+ "dtSpec": "sw0"
36
+ }
37
+ ],
38
+ "interruptPins": [
39
+ {
40
+ "pin": 0,
41
+ "dtSpec": "sw0"
42
+ }
43
+ ]
44
+ },
45
+ "i2c": {
46
+ "controllers": [
47
+ {
48
+ "nodeLabel": "i2c1"
49
+ }
50
+ ]
51
+ },
52
+ "spi": {
53
+ "controllers": [
54
+ {
55
+ "nodeLabel": "spi1"
56
+ }
57
+ ]
58
+ },
59
+ "uart": {
60
+ "controllers": [
61
+ {
62
+ "nodeLabel": "usart1"
63
+ }
64
+ ]
65
+ },
66
+ "pwm": {
67
+ "specs": [
68
+ {
69
+ "pin": 22,
70
+ "controller": "pwm4",
71
+ "channel": 1,
72
+ "periodNs": 20000000,
73
+ "pinctrl": "tim4_ch1_pb6"
74
+ },
75
+ {
76
+ "pin": 23,
77
+ "controller": "pwm4",
78
+ "channel": 2,
79
+ "periodNs": 20000000,
80
+ "pinctrl": "tim4_ch2_pb7"
81
+ }
82
+ ],
83
+ "clockHz": 96000000,
84
+ "maxFrequencyHz": 50000000,
85
+ "resolutionBits": 16
86
+ },
87
+ "adc": {
88
+ "nodeLabel": "adc1",
89
+ "resolution": 12,
90
+ "vrefMv": 3300,
91
+ "channels": [
92
+ {
93
+ "pin": 0,
94
+ "channel": 0,
95
+ "pinctrl": "adc1_in0_pa0"
96
+ },
97
+ {
98
+ "pin": 1,
99
+ "channel": 1,
100
+ "pinctrl": "adc1_in1_pa1"
101
+ },
102
+ {
103
+ "pin": 2,
104
+ "channel": 2,
105
+ "pinctrl": "adc1_in2_pa2"
106
+ },
107
+ {
108
+ "pin": 3,
109
+ "channel": 3,
110
+ "pinctrl": "adc1_in3_pa3"
111
+ },
112
+ {
113
+ "pin": 4,
114
+ "channel": 4,
115
+ "pinctrl": "adc1_in4_pa4"
116
+ },
117
+ {
118
+ "pin": 5,
119
+ "channel": 5,
120
+ "pinctrl": "adc1_in5_pa5"
121
+ },
122
+ {
123
+ "pin": 6,
124
+ "channel": 6,
125
+ "pinctrl": "adc1_in6_pa6"
126
+ },
127
+ {
128
+ "pin": 7,
129
+ "channel": 7,
130
+ "pinctrl": "adc1_in7_pa7"
131
+ },
132
+ {
133
+ "pin": 16,
134
+ "channel": 8,
135
+ "pinctrl": "adc1_in8_pb0"
136
+ },
137
+ {
138
+ "pin": 17,
139
+ "channel": 9,
140
+ "pinctrl": "adc1_in9_pb1"
141
+ }
142
+ ],
143
+ "gain": "ADC_GAIN_1",
144
+ "reference": "ADC_REF_INTERNAL"
145
+ },
146
+ "wdt": {
147
+ "nodeLabel": "iwdg"
148
+ },
149
+ "storage": {
150
+ "offset": 262144,
151
+ "size": 262144
152
+ },
153
+ "usb": {
154
+ "controller": "zephyr_udc0",
155
+ "cdcInstances": 1,
156
+ "vid": "0x2FE3",
157
+ "pid": "0x0002"
158
+ },
159
+ "consoleDescription": "usart1 on PA9 (TX) / PA10 (RX)",
160
+ "probeMethods": [
161
+ {
162
+ "id": "stlink",
163
+ "runner": "openocd",
164
+ "args": [
165
+ "--cmd-pre-init=reset_config none"
166
+ ],
167
+ "description": "ST-Link or any SWD probe openocd supports (no BOOT0 needed)",
168
+ "debug": true,
169
+ "debugInterface": "swd",
170
+ "debugCfg": [
171
+ "reset_config none"
172
+ ],
173
+ "debugCfgSource": [
174
+ "interface/stlink.cfg",
175
+ "target/stm32f4x.cfg"
176
+ ]
177
+ },
178
+ {
179
+ "id": "stlink-srst",
180
+ "runner": "openocd",
181
+ "args": [
182
+ "--cmd-pre-init=reset_config srst_only srst_nogate connect_assert_srst"
183
+ ],
184
+ "description": "ST-Link with the RST/SRST line wired — connect under reset (recovers wedged targets)",
185
+ "debug": true,
186
+ "debugInterface": "swd",
187
+ "debugCfg": [
188
+ "reset_config srst_only srst_nogate connect_assert_srst"
189
+ ],
190
+ "debugCfgSource": [
191
+ "interface/stlink.cfg",
192
+ "target/stm32f4x.cfg"
193
+ ]
194
+ },
195
+ {
196
+ "id": "dfu",
197
+ "runner": "dfu-util",
198
+ "description": "Built-in USB bootloader: hold BOOT0, tap reset",
199
+ "debug": false
200
+ },
201
+ {
202
+ "id": "jlink",
203
+ "runner": "jlink",
204
+ "description": "J-Link probe (SWD)",
205
+ "debug": true,
206
+ "debugInterface": "swd",
207
+ "debugDevice": "STM32F411CE"
208
+ }
209
+ ],
210
+ "customBoard": {
211
+ "socs": [
212
+ "stm32f411xe"
213
+ ],
214
+ "dtsIncludes": [
215
+ "st/f4/stm32f411Xe.dtsi",
216
+ "st/f4/stm32f411c(c-e)ux-pinctrl.dtsi"
217
+ ],
218
+ "console": {
219
+ "nodeLabel": "usart1",
220
+ "tx": "usart1_tx_pa9",
221
+ "rx": "usart1_rx_pa10",
222
+ "speed": 115200
223
+ },
224
+ "clocks": {
225
+ "hseMHz": 25,
226
+ "pll": {
227
+ "divM": 25,
228
+ "mulN": 192,
229
+ "divP": 2,
230
+ "divQ": 4
231
+ },
232
+ "sysMHz": 96,
233
+ "ahbPrescaler": 1,
234
+ "apb1Prescaler": 2,
235
+ "apb2Prescaler": 1
236
+ },
237
+ "usbNode": "usbotg_fs",
238
+ "usbPinctrl": [
239
+ "usb_otg_fs_dm_pa11",
240
+ "usb_otg_fs_dp_pa12"
241
+ ],
242
+ "adcNode": {
243
+ "nodeLabel": "adc1",
244
+ "clockSource": "SYNC",
245
+ "prescaler": 2,
246
+ "pinctrl": "adc1_in1_pa1"
247
+ }
248
+ },
249
+ "tier": "validated",
250
+ "pinNaming": "stm32-port"
251
+ };
@@ -43,6 +43,49 @@ export interface ZephyrGpioController {
43
43
  export interface ZephyrBusController {
44
44
  /** Devicetree nodelabel, e.g. 'i2c1', 'spi2', 'uart0'. */
45
45
  readonly nodeLabel: string;
46
+ /**
47
+ * Counter child form only: the labeled TIMER PARENT's nodelabel (ESP32
48
+ * timer0-3). The counter device is an unlabeled `counter {}` child; the
49
+ * nodeLabel above is a label the generated overlay defines on that child,
50
+ * and this field tells the overlay which parent to attach it to.
51
+ */
52
+ readonly counterParent?: string;
53
+ /**
54
+ * Synthesized pinctrl group, for controllers whose board DT ships no
55
+ * default group (e.g. uart1 on rpi_pico/rpi_pico2 — the mainline board DT
56
+ * only pins uart0). When present, the overlay generator emits the group
57
+ * under `&pinctrl` and wires `pinctrl-0`/`pinctrl-names` onto the
58
+ * controller when enabling it. RP2xxx pinmux is fully muxable per pad, so
59
+ * the group is pure data: which pads carry the signals.
60
+ */
61
+ readonly pinctrl?: {
62
+ /** Pinmux header to #include (token definitions). */
63
+ readonly include: string;
64
+ /** Output-signal pinmux tokens (emitted as group1). */
65
+ readonly pinmux: readonly string[];
66
+ /** Input-signal pinmux tokens (emitted as group2 with input-enable). */
67
+ readonly inputPinmux?: readonly string[];
68
+ /**
69
+ * `#define` lines emitted (ifndef-guarded) BEFORE the include — for
70
+ * upstream header bugs where a token's macro body references an
71
+ * undefined helper (e.g. RP2_PINCTRL_GPIO_FUNC_UART_ALT in Zephyr's
72
+ * rp2350 pinctrl headers, unreferenced by mainline so never noticed).
73
+ */
74
+ readonly defines?: readonly string[];
75
+ };
76
+ /**
77
+ * Reference an EXISTING pinctrl group (defined in the board's pinctrl
78
+ * dtsi but not attached to the node) instead of synthesizing one — e.g.
79
+ * uart1_default on esp32s3_devkitc. The overlay wires
80
+ * `pinctrl-0 = <&<group>>` when enabling the controller.
81
+ */
82
+ readonly pinctrlRef?: string;
83
+ /**
84
+ * Raw devicetree property lines emitted inside the enable block — for
85
+ * bindings with required properties the board DTS only sets on its own
86
+ * wired-up nodes (e.g. `current-speed` on the Picos' PL011 UARTs).
87
+ */
88
+ readonly props?: readonly string[];
46
89
  }
47
90
  /**
48
91
  * A PWM channel described as a devicetree spec.
@@ -78,6 +121,44 @@ export interface ZephyrPwmSpec {
78
121
  readonly periodNs?: number;
79
122
  /** Synthesized form: PWM polarity flag. Default PWM_POLARITY_NORMAL. */
80
123
  readonly polarity?: string;
124
+ /**
125
+ * SoC pinctrl dtsi token muxing this channel's pin to the timer (e.g.
126
+ * 'tim4_ch1_pb6' on STM32). Required on custom boards — the st,stm32-pwm
127
+ * binding demands pinctrl-0 on an enabled node and only a board DTS (or
128
+ * the custom-board generator, fed by this token) can provide it. Also
129
+ * gates the generated board's `pwmN: pwm { }` label declaration: the
130
+ * overlay references `&<controller>`, a label that otherwise exists only
131
+ * when a board DTS defines it.
132
+ */
133
+ readonly pinctrl?: string;
134
+ }
135
+ /**
136
+ * A "PWM matrix" controller: any listed pin can carry any channel, routed by
137
+ * the SoC's GPIO matrix rather than a fixed timer-channel↔pad map.
138
+ *
139
+ * ESP32 LEDC is the shape (espressif,esp32-ledc): 8 channels, each routable
140
+ * to (almost) any pad via a pinctrl pinmux token (`LEDC_CH<ch>_GPIO<pin>`).
141
+ * A static `specs` list cannot express this — two arbitrary pins would
142
+ * collide on a statically assigned channel — so the channel assignment is
143
+ * made at build time: the pins the program actually drives are assigned
144
+ * channels 0..N-1 (ascending pin order, capped at `channelCount`), and the
145
+ * overlay generator emits the pinctrl group + per-channel child nodes the
146
+ * espressif,esp32-ledc binding requires. The emitted C++ is channel-blind:
147
+ * it addresses each pin via the same `DT_ALIAS(tc-pwm<pin>)` the synthesized
148
+ * static form uses, so the two paths share the lowering.
149
+ */
150
+ export interface ZephyrPwmMatrix {
151
+ /** PWM controller DT nodelabel, e.g. 'ledc0'. */
152
+ readonly controller: string;
153
+ /** Channels the controller exposes (ESP32-S3 LEDC: 8). */
154
+ readonly channelCount: number;
155
+ /**
156
+ * HAL pins usable as PWM outputs. This is the safety filter as much as the
157
+ * capability list — on the ESP32-S3 it excludes the boot-strap pin, the
158
+ * USB D+/D− pads, the flash/PSRAM pins (GPIO 26–32), the octal-PSRAM pins
159
+ * (GPIO 33–37), and the console UART pads (GPIO 43/44).
160
+ */
161
+ readonly pins: readonly number[];
81
162
  }
82
163
  /**
83
164
  * A GPIO pin usable as an interrupt source.
@@ -103,6 +184,14 @@ export interface ZephyrAdcChannel {
103
184
  readonly pin: number;
104
185
  /** ADC channel index (nRF SAADC AIN0–AIN7; STM32 ADC1_IN0–IN9). */
105
186
  readonly channel: number;
187
+ /**
188
+ * ADC device node label that OWNS this channel when the SoC has more than
189
+ * one ADC controller (STM32 adc1/adc2, ESP32 units), e.g. 'adc2'. Omitted
190
+ * for channels on the descriptor's primary controller (`adc.nodeLabel`) —
191
+ * a single-controller manifest is unchanged. Channel indices are unique
192
+ * only WITHIN a controller; the pair (controller, channel) is the key.
193
+ */
194
+ readonly controller?: string;
106
195
  /**
107
196
  * Pinctrl node label that muxes this pin to analog mode, e.g.
108
197
  * 'adc1_in0_pa0' (STM32). When present, the overlay generator rewrites the
@@ -123,6 +212,8 @@ export interface ZephyrDacChannel {
123
212
  readonly channel: number;
124
213
  /** DAC resolution in bits (ESP32 DAC is 8-bit). */
125
214
  readonly resolution: number;
215
+ /** Pinctrl node name routing the channel to its pad (STM32 harvest). */
216
+ readonly pinctrl?: string;
126
217
  }
127
218
  /**
128
219
  * Pure-data descriptor for a Zephyr board + its SoC's peripheral layout.
@@ -132,6 +223,33 @@ export interface ZephyrChipDescriptor {
132
223
  readonly id: string;
133
224
  /** SoC family, e.g. 'nrf52840'. */
134
225
  readonly soc: string;
226
+ /**
227
+ * How confident the framework is in this descriptor's facts.
228
+ * - 'validated' — the soc is part of the hardware-tested set; every field
229
+ * was verified against the pinned Zephyr tree and real hardware.
230
+ * - 'derived' — reconstructed from data (board/MCU packages, DTS reading)
231
+ * but never hardware-verified; capability errors may be less precise.
232
+ */
233
+ readonly tier?: 'validated' | 'derived';
234
+ /**
235
+ * Datasheet pin-naming convention — how a controller/pin pair becomes the
236
+ * schematic-facing name the generated board module exports (the
237
+ * `Pin.fromPort()` identity). One of:
238
+ * - 'esp32-gpio' — flat numbering, `GPION` (esp32, esp32s3, esp32c*)
239
+ * - 'stm32-port' — one controller per port, `P<port><bit>` (PA5, PB12)
240
+ * - 'nrf-port' — P0.28 / P1.11 style (`P<port>.<bit>`)
241
+ * - 'rp-gpio' — `GP<n>` flat numbering
242
+ * - 'samd-port' — PA/PB ports like stm32-port
243
+ * Absent on tier-3 socs with no known convention (the generated board
244
+ * exposes only connector/alias pins + LED/BUTTON).
245
+ */
246
+ readonly pinNaming?: 'esp32-gpio' | 'stm32-port' | 'nrf-port' | 'rp-gpio' | 'samd-port';
247
+ /**
248
+ * Pins that exist in the controller ranges but must NOT be exported as
249
+ * usable GPIOs — strapping pads, flash/PSRAM, USB D+/-. The generated
250
+ * board module's pin list subtracts these.
251
+ */
252
+ readonly excludedPins?: readonly number[];
135
253
  /**
136
254
  * Default GPIO controller nodelabel for the raw-pin fallback. Pins not in
137
255
  * `gpio.dtSpecs` are addressed via
@@ -176,9 +294,68 @@ export interface ZephyrChipDescriptor {
176
294
  readonly uart?: {
177
295
  readonly controllers: readonly ZephyrBusController[];
178
296
  };
297
+ /**
298
+ * USB device (CDC-ACM serial) capability. Zephyr "next" USB device stack:
299
+ * the UDC controller node (uniformly `zephyr_udc0` on every USB-capable
300
+ * board) plus `cdcInstances` CDC-ACM class child nodes, both composed in
301
+ * the generated overlay. The lowering addresses instance N as
302
+ * DT_NODELABEL(cdc_acm_uart<N>) — a UART-class device driven with the
303
+ * plain uart_* API. Boards without USB device support omit this field;
304
+ * usb.* HAL ops then fail with a clear "board does not expose USB" error.
305
+ */
306
+ readonly usb?: {
307
+ /** UDC controller nodelabel (convention: 'zephyr_udc0'). */
308
+ readonly controller: string;
309
+ /** How many CDC-ACM serial instances to compose (≥1). */
310
+ readonly cdcInstances: number;
311
+ /** USB vendor ID for the device descriptor ('0x2fe3' Zephyr-test default). */
312
+ readonly vid?: string;
313
+ /** USB product ID for the device descriptor ('0x0001' default). */
314
+ readonly pid?: string;
315
+ /**
316
+ * 1200-baud touch-to-reset (BOSSA-bootloader boards, e.g. SAM D21).
317
+ *
318
+ * Present = two things happen automatically:
319
+ * - Device side: the emitted USB shim registers a usbd message callback;
320
+ * when the host sets the CDC baud rate to 1200, the shim writes the
321
+ * bootloader's "stay resident" magic to the flag address and reboots —
322
+ * the board lands in the bootloader with no button press.
323
+ * - Host side: the bossac upload path opens the app's console port at
324
+ * 1200 baud to trigger the above, waits for the bootloader's USB
325
+ * identity, and points bossac at that port.
326
+ * Omit on boards without a cooperative bootloader (probe- or
327
+ * UF2-flashed boards don't need it).
328
+ */
329
+ readonly touchReset?: {
330
+ /** RAM address of the bootloader's stay-resident flag word
331
+ * (SAMD21G18A: 0x20007FFC — the last word of the 32 KB SRAM). */
332
+ readonly flagAddress: number;
333
+ /** Magic word the bootloader checks there (Arduino SAMD: 0x07738135). */
334
+ readonly magic: number;
335
+ /** Bootloader USB vendor id, hex string ('0x2341') — host-side watch. */
336
+ readonly bootloaderVid?: string;
337
+ /** Bootloader USB product id, hex string ('0x0057') — host-side watch. */
338
+ readonly bootloaderPid?: string;
339
+ };
340
+ };
179
341
  /** PWM channels with DT specs. */
180
342
  readonly pwm?: {
181
343
  readonly specs: readonly ZephyrPwmSpec[];
344
+ /**
345
+ * Matrix PWM capability (ESP32 LEDC) — channels assigned to the driven
346
+ * pins at build time instead of enumerated statically. `specs` may be
347
+ * empty when only the matrix is declared.
348
+ */
349
+ readonly matrix?: ZephyrPwmMatrix;
350
+ /**
351
+ * Timer input clock (Hz) for the synthesized specs' controllers — the
352
+ * number the 16-bit overflow check divides by (STM32: APB clock × the
353
+ * timer multiplier; blackpill TIM4 = 96 MHz). When set, the overlay
354
+ * generator derives an `st,prescaler` for the timers node so slow
355
+ * periods (servo 20 ms) fit the 16-bit ARR — without it pwm_stm32
356
+ * rejects the channel ("period cycles exceeds 16-bit timer limit").
357
+ */
358
+ readonly clockHz?: number;
182
359
  };
183
360
  /** ADC: the ADC device node label + the pin→channel map. */
184
361
  readonly adc?: {
@@ -215,6 +392,25 @@ export interface ZephyrChipDescriptor {
215
392
  readonly wdt?: {
216
393
  readonly nodeLabel: string;
217
394
  };
395
+ /**
396
+ * Storage partition to synthesize when the board DTS ships none. Boards
397
+ * with an MCUboot-style partition map (most STM32s) define boot/slot
398
+ * partitions but no `storage_partition`, which the Preferences/FS backends
399
+ * (ZMS/littlefs) require. Present = "the overlay generator must declare
400
+ * this partition under &flash0"; boards whose DTS already carries one
401
+ * (ESP32 devkits) omit it — the overlay only adds the /chosen pointer.
402
+ * The region must cover ≥2 flash pages (ZMS minimum) and stay clear of
403
+ * the linked application image.
404
+ */
405
+ readonly storage?: {
406
+ /** Partition start offset in flash, page-aligned. */
407
+ readonly offset: number;
408
+ /** Partition size in bytes, a multiple of the flash page size. */
409
+ readonly size: number;
410
+ /** True when the board's own DTS already declares this partition — the
411
+ * overlay must only point /chosen at it, never redeclare the node. */
412
+ readonly preexisting?: boolean;
413
+ };
218
414
  /**
219
415
  * Hardware timers exposed as Zephyr counter devices. `instance` (the HAL
220
416
  * hwtimer.* op's instance index) maps to `controllers[instance].nodeLabel`.
@@ -232,4 +428,127 @@ export interface ZephyrChipDescriptor {
232
428
  readonly wifi?: {
233
429
  readonly supported: true;
234
430
  };
431
+ /**
432
+ * Probe methods the board supports, in user-facing terms. Each entry maps a
433
+ * friendly id (`stlink`, `dfu`, `jlink`, …) to the west runner it drives
434
+ * plus any args the method always needs — the hardware quirks (e.g. openocd
435
+ * needing `reset_config none` when the SRST line is unwired) live here,
436
+ * verified with the board, instead of in user configs. One probe method
437
+ * serves BOTH flashing and debugging (the same attach session); entries
438
+ * that cannot debug (bootloaders) set `debug: false`. Users select one via
439
+ * `zephyr.probe` in cuttlefish.config.ts or `--probe` on the CLI;
440
+ * `zephyr.runner`/`runnerArgs` remain the raw escape hatch underneath.
441
+ */
442
+ readonly probeMethods?: readonly ZephyrProbeMethod[];
443
+ /**
444
+ * Silicon-level inputs for the custom-board generator — present when the
445
+ * chip was resolved from an MCU package's `zephyr` block (an MCU-only
446
+ * config with no board package). The generator emits an out-of-tree Zephyr
447
+ * board (`boards/typecad/<name>/` in the project) from exactly this data:
448
+ * SoC name, devicetree includes, the default console mux, and the default
449
+ * clock plan. Absent on board-resolved chips (their board already exists).
450
+ */
451
+ readonly customBoard?: ZephyrCustomBoardData;
452
+ }
453
+ /**
454
+ * Everything the custom-board generator needs from the silicon to emit a
455
+ * minimal, buildable out-of-tree board for a chip with no board package.
456
+ */
457
+ export interface ZephyrCustomBoardData {
458
+ /** Zephyr SoC name(s) for board.yml + the Kconfig SOC_* selection. */
459
+ readonly socs: readonly string[];
460
+ /** Devicetree includes for the generated board DTS root (SoC + pinctrl). */
461
+ readonly dtsIncludes: readonly string[];
462
+ /** The default console the generated board enables. */
463
+ readonly console: {
464
+ /** Controller nodelabel, e.g. 'usart1'. */
465
+ readonly nodeLabel: string;
466
+ /** TX pinctrl token from the SoC's pinctrl dtsi, e.g. 'usart1_tx_pa9'. */
467
+ readonly tx: string;
468
+ /** RX pinctrl token, e.g. 'usart1_rx_pa10'. */
469
+ readonly rx: string;
470
+ /** Baud rate (the DT `current-speed`). */
471
+ readonly speed: number;
472
+ };
473
+ /**
474
+ * Default clock plan — the numbers the generated DTS writes into the SoC's
475
+ * clock nodes (HSE crystal frequency, PLL dividers, bus prescalers). A
476
+ * board package overrides with its own crystal/plan; a custom board uses
477
+ * this silicon default.
478
+ */
479
+ readonly clocks: {
480
+ /** HSE crystal frequency in MHz. */
481
+ readonly hseMHz: number;
482
+ /** PLL divider/multiplier plan. */
483
+ readonly pll: {
484
+ readonly divM: number;
485
+ readonly mulN: number;
486
+ readonly divP: number;
487
+ readonly divQ: number;
488
+ };
489
+ /** System clock frequency in MHz (the &rcc clock-frequency). */
490
+ readonly sysMHz: number;
491
+ readonly ahbPrescaler: number;
492
+ readonly apb1Prescaler: number;
493
+ readonly apb2Prescaler: number;
494
+ };
495
+ /**
496
+ * Silicon USB node to alias as `usb.controller` in the generated DTS
497
+ * (e.g. 'usbotg_fs' aliased as 'zephyr_udc0'). Omit when usb is absent.
498
+ */
499
+ readonly usbNode?: string;
500
+ /**
501
+ * Pinctrl tokens muxing the USB node's pins (e.g.
502
+ * 'usb_otg_fs_dm_pa11'/'usb_otg_fs_dp_pa12'). The st,stm32-otgfs binding
503
+ * requires pinctrl-0 on an enabled node, so the generated board pre-enables
504
+ * the USB node with exactly these (the blackpill shape). Omit when the
505
+ * SoC's USB needs no board-side muxing.
506
+ */
507
+ readonly usbPinctrl?: readonly string[];
508
+ /**
509
+ * ADC node the generated board must pre-enable with the SoC driver's
510
+ * required properties — e.g. the STM32 F4 binding rejects an enabled adc
511
+ * node without `st,adc-clock-source`/`st,adc-prescaler` (upstream boards
512
+ * set them in their DTS; a custom board has none, so the generator emits
513
+ * them from this data). The baseline pinctrl satisfies the binding's
514
+ * pinctrl-0 requirement; the usage-driven overlay rewrites it to the
515
+ * channels the program actually reads. Omit on SoCs whose ADC needs no
516
+ * board-side enabling.
517
+ */
518
+ readonly adcNode?: {
519
+ readonly nodeLabel: string;
520
+ /** The binding's clock-source property value (e.g. 'SYNC'). */
521
+ readonly clockSource: string;
522
+ /** The binding's prescaler property value (e.g. 2). */
523
+ readonly prescaler: number;
524
+ /** Baseline pinctrl token (e.g. 'adc1_in1_pa1'). */
525
+ readonly pinctrl: string;
526
+ };
527
+ }
528
+ /**
529
+ * A named way to attach a probe to a board — what the user picks, and what
530
+ * flashing/debugging lower to.
531
+ */
532
+ export interface ZephyrProbeMethod {
533
+ /** User-facing id, stable per board (`stlink`, `dfu`, `jlink`, `uf2`, …). */
534
+ readonly id: string;
535
+ /** The west runner this method drives (flash and debug). */
536
+ readonly runner: string;
537
+ /** Args always passed with this method (before any user runnerArgs). */
538
+ readonly args?: readonly string[];
539
+ /** One-line human description for the wizard, doctor, and error messages. */
540
+ readonly description?: string;
541
+ /** Whether this method can debug (default true — SWD/JTAG probes can,
542
+ * bootloaders cannot and set this false explicitly). */
543
+ readonly debug?: boolean;
544
+ /** cortex-debug: the wire protocol (default 'swd'; esp_usb_jtag is 'jtag'). */
545
+ readonly debugInterface?: 'swd' | 'jtag';
546
+ /** cortex-debug servertype=jlink: the J-Link device name (e.g. 'STM32F411CE'). */
547
+ readonly debugDevice?: string;
548
+ /** Raw OpenOCD cfg lines for the debug server config (e.g. 'reset_config
549
+ * none') — the cfg-file form of the quirks `args` carry for west. */
550
+ readonly debugCfg?: readonly string[];
551
+ /** OpenOCD cfg `source [find …]` lines for the debug server (interface +
552
+ * target configs). Omitted entries fall back to the framework default. */
553
+ readonly debugCfgSource?: readonly string[];
235
554
  }
@@ -52,6 +52,15 @@ export const XIAO_BLE = {
52
52
  uart: {
53
53
  controllers: [{ nodeLabel: 'uart0' }],
54
54
  },
55
+ // nRF52840 native USB device (USBD). The board DTS carries `zephyr_udc0`
56
+ // (the nRF USBD driver node); the overlay enables it + composes one CDC-ACM
57
+ // instance when a program uses USB0. (The console on this board is already
58
+ // USB-CDC via the board's own chosen cdc_acm_uart0 — this field exposes the
59
+ // same peripheral to usb.* HAL ops.)
60
+ usb: {
61
+ controller: 'zephyr_udc0',
62
+ cdcInstances: 1,
63
+ },
55
64
  pwm: {
56
65
  // pwm-led0 drives the board PWM LED (PWM_OUT0 on P0.17, inverted).
57
66
  specs: [{ pin: 17, dtSpec: 'pwm-led0' }],
@@ -76,4 +85,16 @@ export const XIAO_BLE = {
76
85
  // Verified against the nRF52840 SoC dtsi (rtc0/rtc1 nodes). The kernel uses
77
86
  // RTC0 for the system tick; RTC1 is available for application use.
78
87
  hwtimer: { controllers: [{ nodeLabel: 'rtc1' }] },
88
+ // Mirror of board-xiao-nrf52840's probeMethods (registry fallback parity —
89
+ // the board package's zephyr field wins when board constants are present).
90
+ probeMethods: [
91
+ { id: 'jlink', runner: 'jlink', description: 'J-Link probe (SWD)',
92
+ debug: true, debugInterface: 'swd', debugDevice: 'nRF52840_xxAA' },
93
+ { id: 'openocd', runner: 'openocd',
94
+ description: 'Any SWD probe openocd supports (CMSIS-DAP, cheap clones)',
95
+ debug: true, debugInterface: 'swd',
96
+ debugCfgSource: ['interface/stlink.cfg', 'target/nrf52.cfg'] },
97
+ { id: 'uf2', runner: 'uf2', description: 'Bootloader UF2 drag-and-drop: double-tap reset',
98
+ debug: false },
99
+ ],
79
100
  };
@@ -40,7 +40,7 @@ export const ZEPHYR_DISPLAY_PROFILES = {
40
40
  // ST7796S SPI TFT, 320x480 RGB565 mounted landscape (effective 480x320).
41
41
  // Same DT nodelabel convention as the ILI9341 — the board's devicetree
42
42
  // carries the `display0` node bound to the ST7796 driver; the overlay
43
- // enables it via status="okay". Effective dims match the Arduino
43
+ // enables it via status="okay". Effective dims match the display
44
44
  // st7796-spi profile (480x320 landscape, rotation 1).
45
45
  driver: 'st7796-zephyr',
46
46
  dtLabel: 'display0',