@typecad/framework-zephyr 1.0.0-alpha.13 → 1.0.0-alpha.15

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 (191) hide show
  1. package/README.md +22 -35
  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/controllers.d.ts +28 -8
  10. package/dist/chips/controllers.js +49 -12
  11. package/dist/chips/esp32s3.js +49 -0
  12. package/dist/chips/index.d.ts +6 -12
  13. package/dist/chips/index.js +18 -34
  14. package/dist/chips/resolve.d.ts +16 -2
  15. package/dist/chips/resolve.js +298 -15
  16. package/dist/chips/soc/.d.ts +2 -0
  17. package/dist/chips/soc/.js +129 -0
  18. package/dist/chips/soc/esp32.d.ts +2 -0
  19. package/dist/chips/soc/esp32.js +120 -0
  20. package/dist/chips/soc/esp32c3.d.ts +2 -0
  21. package/dist/chips/soc/esp32c3.js +90 -0
  22. package/dist/chips/soc/esp32c6.d.ts +2 -0
  23. package/dist/chips/soc/esp32c6.js +109 -0
  24. package/dist/chips/soc/esp32s3.d.ts +2 -0
  25. package/dist/chips/soc/esp32s3.js +189 -0
  26. package/dist/chips/soc/index.d.ts +2 -0
  27. package/dist/chips/soc/index.js +23 -0
  28. package/dist/chips/soc/nrf52840.d.ts +2 -0
  29. package/dist/chips/soc/nrf52840.js +130 -0
  30. package/dist/chips/soc/rp2040.d.ts +2 -0
  31. package/dist/chips/soc/rp2040.js +141 -0
  32. package/dist/chips/soc/rp2350a.d.ts +2 -0
  33. package/dist/chips/soc/rp2350a.js +145 -0
  34. package/dist/chips/soc/samd21g18a.d.ts +2 -0
  35. package/dist/chips/soc/samd21g18a.js +143 -0
  36. package/dist/chips/soc/stm32f411xe.d.ts +2 -0
  37. package/dist/chips/soc/stm32f411xe.js +251 -0
  38. package/dist/chips/types.d.ts +382 -12
  39. package/dist/chips/xiao-ble.js +33 -0
  40. package/dist/display/profiles.js +1 -1
  41. package/dist/doctor.js +38 -4
  42. package/dist/dt-config/custom-board.d.ts +23 -0
  43. package/dist/dt-config/custom-board.js +227 -0
  44. package/dist/dt-config/kconfig.d.ts +83 -1
  45. package/dist/dt-config/kconfig.js +116 -27
  46. package/dist/dt-config/overlay.js +623 -18
  47. package/dist/framework.manifest.d.ts +20 -30
  48. package/dist/framework.manifest.js +124 -178
  49. package/dist/index.d.ts +4 -1
  50. package/dist/index.js +8 -2
  51. package/dist/lowering/adc.d.ts +26 -5
  52. package/dist/lowering/adc.js +137 -31
  53. package/dist/lowering/ble.js +31 -28
  54. package/dist/lowering/dac.js +9 -9
  55. package/dist/lowering/fs.js +18 -10
  56. package/dist/lowering/gpio.d.ts +2 -0
  57. package/dist/lowering/gpio.js +90 -10
  58. package/dist/lowering/http.js +39 -14
  59. package/dist/lowering/hwtimer.d.ts +4 -0
  60. package/dist/lowering/hwtimer.js +35 -10
  61. package/dist/lowering/i2c.js +46 -54
  62. package/dist/lowering/index.d.ts +5 -5
  63. package/dist/lowering/index.js +15 -16
  64. package/dist/lowering/interrupts.d.ts +22 -5
  65. package/dist/lowering/interrupts.js +104 -22
  66. package/dist/lowering/mqtt.js +12 -6
  67. package/dist/lowering/power.js +0 -4
  68. package/dist/lowering/preferences.js +49 -77
  69. package/dist/lowering/pulse.js +5 -36
  70. package/dist/lowering/pwm.d.ts +32 -3
  71. package/dist/lowering/pwm.js +105 -17
  72. package/dist/lowering/random.js +3 -3
  73. package/dist/lowering/sensor.d.ts +37 -0
  74. package/dist/lowering/sensor.js +119 -0
  75. package/dist/lowering/spi.d.ts +12 -0
  76. package/dist/lowering/spi.js +65 -40
  77. package/dist/lowering/thread.d.ts +14 -0
  78. package/dist/lowering/thread.js +55 -0
  79. package/dist/lowering/timing.js +20 -46
  80. package/dist/lowering/tone.js +18 -5
  81. package/dist/lowering/uart.d.ts +13 -0
  82. package/dist/lowering/uart.js +72 -51
  83. package/dist/lowering/usb.d.ts +34 -0
  84. package/dist/lowering/usb.js +206 -0
  85. package/dist/lowering/wdt.d.ts +1 -1
  86. package/dist/lowering/wdt.js +17 -7
  87. package/dist/lowering/wifi.d.ts +3 -2
  88. package/dist/lowering/wifi.js +120 -111
  89. package/dist/sdk/board-catalog-sync.d.ts +16 -0
  90. package/dist/sdk/board-catalog-sync.js +41 -0
  91. package/dist/sdk/board-data.generated.d.ts +2 -0
  92. package/dist/sdk/board-data.generated.js +4 -0
  93. package/dist/sdk/catalog-walker.d.ts +90 -0
  94. package/dist/sdk/catalog-walker.js +682 -0
  95. package/dist/sdk/dts-reader.d.ts +83 -0
  96. package/dist/sdk/dts-reader.js +596 -0
  97. package/dist/strategy.d.ts +136 -17
  98. package/dist/strategy.js +881 -212
  99. package/dist/toolchain/bossac-touch.d.ts +18 -0
  100. package/dist/toolchain/bossac-touch.js +88 -0
  101. package/dist/toolchain/compat.d.ts +2 -2
  102. package/dist/toolchain/compat.js +8 -3
  103. package/dist/toolchain/debug-config.d.ts +21 -26
  104. package/dist/toolchain/debug-config.js +212 -72
  105. package/dist/toolchain/env-check.d.ts +4 -4
  106. package/dist/toolchain/env-check.js +5 -5
  107. package/dist/toolchain/index.d.ts +66 -1
  108. package/dist/toolchain/index.js +713 -58
  109. package/dist/toolchain/scaffold.d.ts +9 -0
  110. package/dist/toolchain/scaffold.js +84 -7
  111. package/dist/toolchain/west-discover.d.ts +8 -1
  112. package/dist/toolchain/west-discover.js +19 -6
  113. package/dist/toolchain/west-spawn.js +17 -5
  114. package/installer/CHANGELOG.md +473 -0
  115. package/installer/README.md +328 -0
  116. package/installer/environment.yml +46 -0
  117. package/installer/etc/conda/activate.d/zephyr.bat +7 -0
  118. package/installer/etc/conda/activate.d/zephyr.ps1 +12 -0
  119. package/installer/etc/conda/activate.d/zephyr.sh +20 -0
  120. package/installer/etc/conda/deactivate.d/zephyr.bat +6 -0
  121. package/installer/etc/conda/deactivate.d/zephyr.ps1 +6 -0
  122. package/installer/etc/conda/deactivate.d/zephyr.sh +4 -0
  123. package/installer/install.mjs +580 -0
  124. package/installer/install.ps1 +619 -0
  125. package/installer/install.sh +310 -0
  126. package/installer/lib/detect-platform.sh +62 -0
  127. package/installer/lib/fetch-sdk.sh +304 -0
  128. package/installer/lib/init-workspace.sh +153 -0
  129. package/installer/lib/write-activation.sh +76 -0
  130. package/installer/patches/tfm-c-include-separators.patch +19 -0
  131. package/installer/patches/zephyr-tfm-nordic-zephyr-include.patch +24 -0
  132. package/installer/templates/project/.typecad/activate-zephyr.ps1 +31 -0
  133. package/installer/templates/project/.typecad/activate-zephyr.sh +31 -0
  134. package/installer/templates/project/.vscode/settings.json +30 -0
  135. package/installer/templates/project/README.md +58 -0
  136. package/installer/versions.env +110 -0
  137. package/package.json +16 -16
  138. package/src/as-built.ts +206 -0
  139. package/src/boardgen.ts +1428 -0
  140. package/src/chips/controllers.ts +61 -12
  141. package/src/chips/index.ts +35 -54
  142. package/src/chips/resolve.ts +316 -14
  143. package/src/chips/types.ts +388 -13
  144. package/src/display/profiles.ts +1 -1
  145. package/src/doctor.ts +110 -77
  146. package/src/dt-config/custom-board.ts +325 -0
  147. package/src/dt-config/kconfig.ts +177 -19
  148. package/src/dt-config/overlay.ts +1058 -450
  149. package/src/framework.manifest.ts +125 -178
  150. package/src/index.ts +57 -41
  151. package/src/lowering/adc.ts +222 -102
  152. package/src/lowering/ble.ts +32 -28
  153. package/src/lowering/dac.ts +82 -82
  154. package/src/lowering/fs.ts +18 -10
  155. package/src/lowering/gpio.ts +242 -152
  156. package/src/lowering/http.ts +512 -488
  157. package/src/lowering/hwtimer.ts +139 -101
  158. package/src/lowering/i2c.ts +116 -126
  159. package/src/lowering/index.ts +91 -93
  160. package/src/lowering/interrupts.ts +113 -21
  161. package/src/lowering/mqtt.ts +12 -6
  162. package/src/lowering/preferences.ts +327 -354
  163. package/src/lowering/pwm.ts +167 -74
  164. package/src/lowering/random.ts +3 -3
  165. package/src/lowering/sensor.ts +155 -0
  166. package/src/lowering/spi.ts +164 -124
  167. package/src/lowering/thread.ts +63 -0
  168. package/src/lowering/timing.ts +46 -72
  169. package/src/lowering/uart.ts +73 -51
  170. package/src/lowering/usb.ts +221 -0
  171. package/src/lowering/wdt.ts +95 -84
  172. package/src/lowering/wifi.ts +120 -111
  173. package/src/sdk/board-catalog-sync.ts +62 -0
  174. package/src/strategy.ts +888 -229
  175. package/src/toolchain/bossac-touch.ts +112 -0
  176. package/src/toolchain/compat.ts +8 -3
  177. package/src/toolchain/debug-config.ts +666 -522
  178. package/src/toolchain/env-check.ts +9 -9
  179. package/src/toolchain/index.ts +765 -44
  180. package/src/toolchain/scaffold.ts +81 -7
  181. package/src/toolchain/west-discover.ts +334 -316
  182. package/src/toolchain/west-spawn.ts +17 -5
  183. package/src/async/timer-polyfill.ts +0 -107
  184. package/src/chips/esp32.ts +0 -74
  185. package/src/chips/esp32s3.ts +0 -57
  186. package/src/chips/xiao-ble.ts +0 -70
  187. package/src/lowering/power.ts +0 -70
  188. package/src/lowering/pulse.ts +0 -93
  189. package/src/lowering/tone.ts +0 -60
  190. package/src/lowering/worker-backing.ts +0 -94
  191. package/src/lowering/worker.ts +0 -17
@@ -0,0 +1,7 @@
1
+ export interface BoardOverride {
2
+ /** LED pin name for boards whose user LED is not a gpio-leds node (the
3
+ * ESP32-S3 DevKitC's addressable RGB on GPIO48 — driven as plain GPIO,
4
+ * same as the deleted board package did). */
5
+ readonly led?: string;
6
+ }
7
+ export declare const BOARD_OVERRIDES: Readonly<Record<string, BoardOverride>>;
@@ -0,0 +1,11 @@
1
+ // ---------------------------------------------------------------------------
2
+ // board-overrides.ts — curated board-level facts the devicetree cannot
3
+ // express. The honest residue of the board-package deletion: things a board
4
+ // vendor documents in a datasheet but never encodes in DTS.
5
+ //
6
+ // Keyed by the bare board id (the first segment of the qualified target, so
7
+ // every variant/qualifier of the board inherits the override).
8
+ // ----------------------------------------------------------------------------
9
+ export const BOARD_OVERRIDES = {
10
+ esp32s3_devkitc: { led: 'GPIO48' },
11
+ };
@@ -1,4 +1,4 @@
1
- import type { ZephyrChipDescriptor } from './types.js';
1
+ import type { ZephyrChipDescriptor, ZephyrGpioController } from './types.js';
2
2
  /**
3
3
  * Resolve the devicetree nodelabel of the GPIO controller that owns `pin`.
4
4
  *
@@ -9,13 +9,33 @@ import type { ZephyrChipDescriptor } from './types.js';
9
9
  */
10
10
  export declare function controllerNodelabelForPin(chip: ZephyrChipDescriptor, pin: number): string;
11
11
  /**
12
- * Emit the C++ source for a runtime pin GPIO-device dispatcher.
12
+ * The owning controller range for a HAL pin, if the chip declares a split.
13
+ */
14
+ export declare function controllerRangeForPin(chip: ZephyrChipDescriptor, pin: number): ZephyrGpioController | undefined;
15
+ /**
16
+ * The PORT-RELATIVE pin index for the raw gpio_pin_*_raw() API — the Zephyr
17
+ * raw calls address the index WITHIN the controller, not the global HAL pin
18
+ * number. For split SoCs each controller's `minPin` is its base (STM32:
19
+ * gpiob minPin 16, so PB12 = pin 28 → raw 12); single-controller SoCs have
20
+ * no offset. Emitting the global number against a port driver would address
21
+ * a nonexistent port bit (STM32 gpiob is 0–15) and fail at runtime.
22
+ */
23
+ export declare function controllerRawPinForPin(chip: ZephyrChipDescriptor, pin: number): number;
24
+ /**
25
+ * Emit the C++ source for runtime pin → GPIO-device / port-relative-index
26
+ * dispatchers.
27
+ *
28
+ * Returns lines defining:
29
+ * - `static inline const struct device* __tc_gpio_dev(uint32_t pin)` — the
30
+ * owning controller's device, resolved via DEVICE_DT_GET(DT_NODELABEL(...))
31
+ * at compile time (the macro is evaluated per branch, so it is always
32
+ * statically valid); only `pin` is runtime.
33
+ * - `static inline gpio_pin_t __tc_gpio_pin(uint32_t pin)` — the
34
+ * port-relative index for gpio_pin_*_raw() (see controllerRawPinForPin).
35
+ * The runtime shim paths (UI pin-watch, safety voters) take a runtime pin,
36
+ * so they cannot bake the offset in at emit time.
13
37
  *
14
- * Returns lines defining `static inline const struct device* __tc_gpio_dev(uint32_t pin)`.
15
- * Each branch resolves its controller via `DEVICE_DT_GET(DT_NODELABEL(...))` at
16
- * compile time (the macro is evaluated per branch, so it is always statically
17
- * valid); only `pin` is runtime. For a single-controller SoC this collapses to
18
- * a one-liner returning that controller, so the existing XIAO nRF52840 behavior
19
- * is byte-for-byte unchanged.
38
+ * For a single-controller SoC both collapse to one-liners, so the existing
39
+ * XIAO nRF52840 behavior is byte-for-byte unchanged.
20
40
  */
21
41
  export declare function emitGpioDevDispatcher(chip: ZephyrChipDescriptor): string[];
@@ -27,23 +27,47 @@
27
27
  * for out-of-range pins (e.g. the manifest probe's synthetic pin 0).
28
28
  */
29
29
  export function controllerNodelabelForPin(chip, pin) {
30
+ const hit = controllerRangeForPin(chip, pin);
31
+ return hit ? hit.nodelabel : chip.gpioController;
32
+ }
33
+ /**
34
+ * The owning controller range for a HAL pin, if the chip declares a split.
35
+ */
36
+ export function controllerRangeForPin(chip, pin) {
30
37
  const ranges = chip.gpioControllers;
31
38
  if (ranges && ranges.length > 0) {
32
- const hit = ranges.find((r) => pin >= r.minPin && pin <= r.maxPin);
33
- if (hit)
34
- return hit.nodelabel;
39
+ return ranges.find((r) => pin >= r.minPin && pin <= r.maxPin);
35
40
  }
36
- return chip.gpioController;
41
+ return undefined;
37
42
  }
38
43
  /**
39
- * Emit the C++ source for a runtime pin GPIO-device dispatcher.
44
+ * The PORT-RELATIVE pin index for the raw gpio_pin_*_raw() API the Zephyr
45
+ * raw calls address the index WITHIN the controller, not the global HAL pin
46
+ * number. For split SoCs each controller's `minPin` is its base (STM32:
47
+ * gpiob minPin 16, so PB12 = pin 28 → raw 12); single-controller SoCs have
48
+ * no offset. Emitting the global number against a port driver would address
49
+ * a nonexistent port bit (STM32 gpiob is 0–15) and fail at runtime.
50
+ */
51
+ export function controllerRawPinForPin(chip, pin) {
52
+ const hit = controllerRangeForPin(chip, pin);
53
+ return pin - (hit?.minPin ?? 0);
54
+ }
55
+ /**
56
+ * Emit the C++ source for runtime pin → GPIO-device / port-relative-index
57
+ * dispatchers.
58
+ *
59
+ * Returns lines defining:
60
+ * - `static inline const struct device* __tc_gpio_dev(uint32_t pin)` — the
61
+ * owning controller's device, resolved via DEVICE_DT_GET(DT_NODELABEL(...))
62
+ * at compile time (the macro is evaluated per branch, so it is always
63
+ * statically valid); only `pin` is runtime.
64
+ * - `static inline gpio_pin_t __tc_gpio_pin(uint32_t pin)` — the
65
+ * port-relative index for gpio_pin_*_raw() (see controllerRawPinForPin).
66
+ * The runtime shim paths (UI pin-watch, safety voters) take a runtime pin,
67
+ * so they cannot bake the offset in at emit time.
40
68
  *
41
- * Returns lines defining `static inline const struct device* __tc_gpio_dev(uint32_t pin)`.
42
- * Each branch resolves its controller via `DEVICE_DT_GET(DT_NODELABEL(...))` at
43
- * compile time (the macro is evaluated per branch, so it is always statically
44
- * valid); only `pin` is runtime. For a single-controller SoC this collapses to
45
- * a one-liner returning that controller, so the existing XIAO nRF52840 behavior
46
- * is byte-for-byte unchanged.
69
+ * For a single-controller SoC both collapse to one-liners, so the existing
70
+ * XIAO nRF52840 behavior is byte-for-byte unchanged.
47
71
  */
48
72
  export function emitGpioDevDispatcher(chip) {
49
73
  const ranges = chip.gpioControllers;
@@ -53,14 +77,27 @@ export function emitGpioDevDispatcher(chip) {
53
77
  ` (void)pin;`,
54
78
  ` return DEVICE_DT_GET(DT_NODELABEL(${chip.gpioController}));`,
55
79
  '}',
80
+ 'static inline gpio_pin_t __tc_gpio_pin(uint32_t pin) {',
81
+ ` return (gpio_pin_t)pin;`,
82
+ '}',
56
83
  ];
57
84
  }
58
85
  const lines = [
59
86
  'static inline const struct device* __tc_gpio_dev(uint32_t pin) {',
60
87
  ];
88
+ const pinLines = [
89
+ 'static inline gpio_pin_t __tc_gpio_pin(uint32_t pin) {',
90
+ ];
61
91
  for (const r of ranges) {
62
92
  lines.push(` if (pin >= ${r.minPin} && pin <= ${r.maxPin}) { return DEVICE_DT_GET(DT_NODELABEL(${r.nodelabel})); }`);
93
+ if (r.minPin === 0) {
94
+ pinLines.push(` if (pin >= ${r.minPin} && pin <= ${r.maxPin}) { return (gpio_pin_t)pin; }`);
95
+ }
96
+ else {
97
+ pinLines.push(` if (pin >= ${r.minPin} && pin <= ${r.maxPin}) { return (gpio_pin_t)(pin - ${r.minPin}); }`);
98
+ }
63
99
  }
64
100
  lines.push(` return DEVICE_DT_GET(DT_NODELABEL(${chip.gpioController}));`, '}');
65
- return lines;
101
+ pinLines.push(` return (gpio_pin_t)pin;`, '}');
102
+ return [...lines, ...pinLines];
66
103
  }
@@ -51,4 +51,53 @@ export const ESP32S3_DEVKITC = {
51
51
  // WiFi: the ESP32-S3 has a 2.4GHz radio; conn_mgr + the esp32 wifi driver
52
52
  // (CONFIG_WIFI_ESP32) provide connectivity. Omitted on radioless targets.
53
53
  wifi: { supported: true },
54
+ // User buses, mirroring the devkit's verified facts (the
55
+ // board-constants path is authoritative in real builds; this registry
56
+ // entry is the fallback when board constants are absent — e.g. the
57
+ // transpile test harness). uart1 (not uart0 — the console) with the
58
+ // pinctrl group + current-speed the esp32-uart binding requires; i2c0;
59
+ // spi2/spi3.
60
+ i2c: { controllers: [{ nodeLabel: 'i2c0' }] },
61
+ spi: { controllers: [{ nodeLabel: 'spi2' }, { nodeLabel: 'spi3' }] },
62
+ uart: {
63
+ controllers: [
64
+ {
65
+ nodeLabel: 'uart1',
66
+ pinctrlRef: 'uart1_default',
67
+ props: ['current-speed = <115200>;'],
68
+ },
69
+ ],
70
+ },
71
+ // USB CDC-ACM over the S3's native USB-OTG (D-/D+ on the dedicated GPIO19/20
72
+ // pads, no GPIO matrix). The board DTS already aliases the DWC2 controller
73
+ // node and enables it (`zephyr_udc0: &usb_otg { status = "okay"; }` —
74
+ // esp32s3_devkitc_procpu.dts), and the UDC DWC2 driver is DT-default-on, so
75
+ // declaring it here is all usb.* needs: the overlay composes one CDC-ACM
76
+ // instance child and the kconfig resolver enables the "next" USB stack.
77
+ // Console stays on uart0 (the devkit's USB-serial bridge) unless
78
+ // `console.output: 'usb'` rebinds zephyr,console to the CDC port.
79
+ usb: { controller: 'zephyr_udc0', cdcInstances: 1, vid: '0x2FE3', pid: '0x0006' },
80
+ // PWM: the LEDC controller (ledc0 in esp32s3_common.dtsi) — 8 channels, each
81
+ // routable to nearly any pad through the GPIO matrix, so this is a matrix
82
+ // (channels assigned to the driven pins at build time), not a static spec
83
+ // list. Pin selection excludes: GPIO0 (boot strap / BOOT button), GPIO19/20
84
+ // (USB D-/D+), GPIO26–32 (SPI flash/PSRAM), GPIO33–37 (octal PSRAM on OPI
85
+ // modules), GPIO43/44 (uart0 console pads). The driver
86
+ // (CONFIG_PWM_LED_ESP32, DT-default-on) requires a pinctrl group routing
87
+ // each used channel (LEDC_CH<ch>_GPIO<pin> pinmux tokens, all 8×46 pairs in
88
+ // esp32s3-pinctrl.h) plus per-channel child nodes (reg + timer) — both
89
+ // emitted by the overlay generator (dt-config/overlay.ts emitPwmNodes).
90
+ pwm: {
91
+ specs: [],
92
+ matrix: {
93
+ controller: 'ledc0',
94
+ channelCount: 8,
95
+ pins: [
96
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
97
+ 21,
98
+ 38, 39, 40, 41, 42,
99
+ 45, 46, 47, 48,
100
+ ],
101
+ },
102
+ },
54
103
  };
@@ -1,15 +1,9 @@
1
1
  import type { ZephyrChipDescriptor } from './types.js';
2
- import { XIAO_BLE } from './xiao-ble.js';
3
- import { ESP32S3_DEVKITC } from './esp32s3.js';
4
- import { ESP32_DEVKITC } from './esp32.js';
5
- export { XIAO_BLE, ESP32S3_DEVKITC, ESP32_DEVKITC };
6
- export type { ZephyrChipDescriptor, ZephyrGpioDtSpec } from './types.js';
7
- export declare function setActiveChip(d: ZephyrChipDescriptor): void;
8
- export declare function getActiveChip(): ZephyrChipDescriptor;
9
2
  /**
10
- * Resolve a chip descriptor from the Zephyr board target string
11
- * (frameworkData.buildTarget / frameworkData.target). Accepts the bare board
12
- * id ('xiao_ble', 'esp32s3_devkitc', 'esp32_devkitc') or a board/qualifier
13
- * path ('esp32s3_devkitc/esp32s3/procpu', 'esp32_devkitc/esp32/procpu').
3
+ * The no-board fallback: no controllers, no buses, no silicon facts. The
4
+ * lowering treats it as "unsupported operation" per subsystem, which is the
5
+ * honest answer when no board resolved.
14
6
  */
15
- export declare function chipForTarget(target?: string): ZephyrChipDescriptor;
7
+ export declare const NO_BOARD_CHIP: ZephyrChipDescriptor;
8
+ export declare function setActiveChip(d: ZephyrChipDescriptor): void;
9
+ export declare function getActiveChip(): ZephyrChipDescriptor;
@@ -1,45 +1,29 @@
1
1
  // ---------------------------------------------------------------------------
2
- // Chip descriptor registrymaps Zephyr board target ZephyrChipDescriptor
2
+ // Chip descriptor cachethe mechanism the strategy's lowering reads.
3
3
  //
4
- // Mirrors framework-esp32/src/chips/index.ts: a module-level activeChip,
5
- // setActiveChip/getActiveChip, and chipForTarget resolving from
6
- // frameworkData.buildTarget. The strategy calls setActiveChip during profile
7
- // resolution so the lowering reads a single cached descriptor.
4
+ // There is no curated descriptor registry: every board's chip view is
5
+ // reconstructed from its generated board manifest via resolveChipFromBoard
6
+ // (src/chips/resolve.ts). This module only caches that resolved descriptor
7
+ // for the process lifetime (setActiveChip during profile resolution, the
8
+ // lowering reads getActiveChip) and provides the empty fallback for
9
+ // contexts with no board at all.
8
10
  // ---------------------------------------------------------------------------
9
- import { XIAO_BLE } from './xiao-ble.js';
10
- import { ESP32S3_DEVKITC } from './esp32s3.js';
11
- import { ESP32_DEVKITC } from './esp32.js';
12
- export { XIAO_BLE, ESP32S3_DEVKITC, ESP32_DEVKITC };
13
11
  /**
14
- * Default chip used when no buildTarget is supplied. The XIAO nRF52840 is the
15
- * canonical MVP target; subsequent board additions extend the switch below.
12
+ * The no-board fallback: no controllers, no buses, no silicon facts. The
13
+ * lowering treats it as "unsupported operation" per subsystem, which is the
14
+ * honest answer when no board resolved.
16
15
  */
17
- const DEFAULT_CHIP = XIAO_BLE;
18
- let activeChip = DEFAULT_CHIP;
16
+ export const NO_BOARD_CHIP = {
17
+ id: 'no-board',
18
+ soc: '',
19
+ gpioController: 'gpio0',
20
+ gpio: { dtSpecs: [] },
21
+ probeMethods: [],
22
+ };
23
+ let activeChip = NO_BOARD_CHIP;
19
24
  export function setActiveChip(d) {
20
25
  activeChip = d;
21
26
  }
22
27
  export function getActiveChip() {
23
28
  return activeChip;
24
29
  }
25
- /**
26
- * Resolve a chip descriptor from the Zephyr board target string
27
- * (frameworkData.buildTarget / frameworkData.target). Accepts the bare board
28
- * id ('xiao_ble', 'esp32s3_devkitc', 'esp32_devkitc') or a board/qualifier
29
- * path ('esp32s3_devkitc/esp32s3/procpu', 'esp32_devkitc/esp32/procpu').
30
- */
31
- export function chipForTarget(target) {
32
- const t = (target ?? '').trim().toLowerCase();
33
- const boardId = t.split('/')[0];
34
- switch (boardId) {
35
- case 'xiao_ble':
36
- return XIAO_BLE;
37
- case 'esp32s3_devkitc':
38
- return ESP32S3_DEVKITC;
39
- case 'esp32_devkitc':
40
- return ESP32_DEVKITC;
41
- case '':
42
- default:
43
- return DEFAULT_CHIP;
44
- }
45
- }
@@ -1,9 +1,23 @@
1
1
  import type { BoardConstants } from '@typecad/cuttlefish/api/shared';
2
- import type { ZephyrChipDescriptor } from './types.js';
2
+ import type { ZephyrChipDescriptor, ZephyrPwmSpec } from './types.js';
3
3
  /**
4
4
  * Try to derive a ZephyrChipDescriptor from board/MCU package constants.
5
5
  *
6
6
  * Returns null when no zephyr info is available in the board constants
7
- * (the caller should fall back to the hardcoded chipForTarget registry).
7
+ * (the caller should treat the board as unresolved NO_BOARD_CHIP).
8
8
  */
9
9
  export declare function resolveChipFromBoard(bc: BoardConstants | undefined): ZephyrChipDescriptor | null;
10
+ /**
11
+ * Board-level PWM specs from the generated board manifest (zephyr.pwm.specs.*
12
+ * — the pwm-leds facts boardgen emits on virtual pins 8192+). The active
13
+ * chip's spec table is silicon-curated; these JOIN it (see mergeBoardPwmSpecs)
14
+ * so a board's own devicetree-aliased PWM LED is addressable without curation.
15
+ */
16
+ export declare function boardPwmSpecsFromConstants(bc: BoardConstants | undefined): ZephyrPwmSpec[];
17
+ /**
18
+ * Merge board-level PWM specs into a chip descriptor. Collision rule: a
19
+ * board spec whose pin OR dtSpec already exists in the chip's table is
20
+ * dropped (the curated entry wins — e.g. the XIAO's hand-tuned pwm-led0
21
+ * spec). Returns the chip unchanged when nothing joins.
22
+ */
23
+ export declare function mergeBoardPwmSpecs(chip: ZephyrChipDescriptor, boardSpecs: readonly ZephyrPwmSpec[]): ZephyrChipDescriptor;