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

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 (210) 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/audit.d.ts +111 -0
  6. package/dist/audit.js +416 -0
  7. package/dist/boardgen.d.ts +1 -9
  8. package/dist/boardgen.js +288 -47
  9. package/dist/chips/resolve.js +20 -0
  10. package/dist/chips/types.d.ts +22 -1
  11. package/dist/debug-codegen.js +1 -1
  12. package/dist/display/bindings.d.ts +55 -0
  13. package/dist/display/bindings.js +316 -0
  14. package/dist/display/gfx.d.ts +2 -3
  15. package/dist/display/gfx.js +166 -154
  16. package/dist/display/index.js +20 -1
  17. package/dist/display/mipi-dbi-host.d.ts +9 -0
  18. package/dist/display/mipi-dbi-host.js +174 -0
  19. package/dist/display/profiles.d.ts +109 -4
  20. package/dist/display/profiles.js +270 -7
  21. package/dist/display/touch-adapter.js +119 -49
  22. package/dist/display/ui-adapter-eink.d.ts +2 -0
  23. package/dist/display/ui-adapter-eink.js +4 -0
  24. package/dist/display/ui-adapter-gray.d.ts +8 -0
  25. package/dist/display/ui-adapter-gray.js +170 -0
  26. package/dist/display/ui-adapter-mono.d.ts +13 -0
  27. package/dist/display/ui-adapter-mono.js +230 -0
  28. package/dist/display/ui-adapter-native.d.ts +10 -0
  29. package/dist/display/ui-adapter-native.js +295 -0
  30. package/dist/display/ui-adapter-shared.d.ts +11 -0
  31. package/dist/display/ui-adapter-shared.js +122 -0
  32. package/dist/display/ui-adapter.js +510 -558
  33. package/dist/doctor.js +4 -4
  34. package/dist/dt-config/custom-board.js +2 -2
  35. package/dist/dt-config/kconfig.d.ts +62 -1
  36. package/dist/dt-config/kconfig.js +141 -38
  37. package/dist/dt-config/overlay.d.ts +15 -2
  38. package/dist/dt-config/overlay.js +433 -18
  39. package/dist/framework.manifest.d.ts +10 -4
  40. package/dist/framework.manifest.js +133 -17
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.js +14 -6
  43. package/dist/licenses.d.ts +2 -2
  44. package/dist/licenses.js +13 -92
  45. package/dist/lowering/can.d.ts +25 -0
  46. package/dist/lowering/can.js +97 -0
  47. package/dist/lowering/clock.d.ts +17 -0
  48. package/dist/lowering/clock.js +58 -0
  49. package/dist/lowering/fs.js +1 -1
  50. package/dist/lowering/gpio.js +0 -32
  51. package/dist/lowering/hid.d.ts +27 -0
  52. package/dist/lowering/hid.js +244 -0
  53. package/dist/lowering/http.js +264 -32
  54. package/dist/lowering/i2c.d.ts +8 -0
  55. package/dist/lowering/i2c.js +137 -5
  56. package/dist/lowering/i2s.d.ts +27 -0
  57. package/dist/lowering/i2s.js +98 -0
  58. package/dist/lowering/index.d.ts +9 -1
  59. package/dist/lowering/index.js +25 -1
  60. package/dist/lowering/interrupts.js +6 -0
  61. package/dist/lowering/matrix.d.ts +15 -0
  62. package/dist/lowering/matrix.js +63 -0
  63. package/dist/lowering/mqtt.js +110 -8
  64. package/dist/lowering/power.d.ts +3 -2
  65. package/dist/lowering/power.js +20 -45
  66. package/dist/lowering/pwm.js +25 -0
  67. package/dist/lowering/sensor.d.ts +2 -2
  68. package/dist/lowering/sensor.js +8 -4
  69. package/dist/lowering/strip.d.ts +16 -0
  70. package/dist/lowering/strip.js +70 -0
  71. package/dist/lowering/thread.js +5 -1
  72. package/dist/lowering/trace.d.ts +44 -0
  73. package/dist/lowering/trace.js +239 -0
  74. package/dist/lowering/uart.js +6 -1
  75. package/dist/lowering/usb.d.ts +3 -1
  76. package/dist/lowering/usb.js +16 -13
  77. package/dist/lowering/wdt.js +2 -29
  78. package/dist/sbom.d.ts +181 -0
  79. package/dist/sbom.js +901 -0
  80. package/dist/sdk/board-catalog-sync.d.ts +1 -3
  81. package/dist/sdk/board-catalog-sync.js +4 -10
  82. package/dist/strategy.d.ts +82 -46
  83. package/dist/strategy.js +639 -182
  84. package/dist/tmp-probe.d.ts +2 -0
  85. package/dist/tmp-probe.js +9 -0
  86. package/dist/toolchain/debug-config.d.ts +50 -90
  87. package/dist/toolchain/debug-config.js +239 -510
  88. package/dist/toolchain/env-check.d.ts +1 -3
  89. package/dist/toolchain/env-check.js +2 -7
  90. package/dist/toolchain/index.d.ts +28 -3
  91. package/dist/toolchain/index.js +498 -62
  92. package/dist/toolchain/runners.d.ts +16 -0
  93. package/dist/toolchain/runners.js +75 -0
  94. package/dist/toolchain/scaffold.d.ts +5 -2
  95. package/dist/toolchain/scaffold.js +79 -15
  96. package/dist/toolchain/west-discover.d.ts +6 -0
  97. package/dist/toolchain/west-discover.js +36 -13
  98. package/dist/toolchain/west-spawn.js +8 -2
  99. package/dist/west-inventory.d.ts +25 -0
  100. package/dist/west-inventory.js +97 -0
  101. package/installer/README.md +328 -328
  102. package/installer/install.sh +2 -2
  103. package/installer/templates/project/.typecad/activate-zephyr.ps1 +1 -1
  104. package/installer/templates/project/.typecad/activate-zephyr.sh +1 -1
  105. package/installer/templates/project/.vscode/settings.json +1 -1
  106. package/installer/templates/project/README.md +2 -2
  107. package/package.json +5 -5
  108. package/src/as-built.ts +206 -206
  109. package/src/audit.ts +529 -0
  110. package/src/boardgen.ts +265 -50
  111. package/src/chips/resolve.ts +21 -0
  112. package/src/chips/types.ts +10 -1
  113. package/src/display/bindings.ts +347 -0
  114. package/src/display/gfx.ts +318 -306
  115. package/src/display/index.ts +87 -70
  116. package/src/display/mipi-dbi-host.ts +183 -0
  117. package/src/display/profiles.ts +458 -139
  118. package/src/display/touch-adapter.ts +119 -49
  119. package/src/display/ui-adapter-eink.ts +13 -0
  120. package/src/display/ui-adapter-gray.ts +178 -0
  121. package/src/display/ui-adapter-mono.ts +238 -0
  122. package/src/display/ui-adapter-native.ts +304 -0
  123. package/src/display/ui-adapter-shared.ts +125 -0
  124. package/src/display/ui-adapter.ts +732 -781
  125. package/src/doctor.ts +4 -4
  126. package/src/dt-config/custom-board.ts +2 -2
  127. package/src/dt-config/kconfig.ts +647 -505
  128. package/src/dt-config/overlay.ts +1475 -1058
  129. package/src/framework.manifest.ts +659 -535
  130. package/src/index.ts +16 -6
  131. package/src/licenses.ts +346 -425
  132. package/src/lowering/can.ts +140 -0
  133. package/src/lowering/clock.ts +91 -0
  134. package/src/lowering/fs.ts +135 -135
  135. package/src/lowering/gpio.ts +0 -33
  136. package/src/lowering/hid.ts +261 -0
  137. package/src/lowering/http.ts +264 -32
  138. package/src/lowering/i2c.ts +142 -5
  139. package/src/lowering/i2s.ts +143 -0
  140. package/src/lowering/index.ts +18 -1
  141. package/src/lowering/interrupts.ts +6 -0
  142. package/src/lowering/matrix.ts +70 -0
  143. package/src/lowering/mqtt.ts +109 -8
  144. package/src/lowering/power.ts +41 -0
  145. package/src/lowering/pwm.ts +192 -167
  146. package/src/lowering/sensor.ts +159 -155
  147. package/src/lowering/strip.ts +81 -0
  148. package/src/lowering/thread.ts +5 -1
  149. package/src/lowering/trace.ts +270 -0
  150. package/src/lowering/uart.ts +6 -1
  151. package/src/lowering/usb.ts +16 -13
  152. package/src/lowering/wdt.ts +2 -25
  153. package/src/sbom.ts +1117 -0
  154. package/src/sdk/board-catalog-sync.ts +4 -25
  155. package/src/strategy.ts +2680 -2309
  156. package/src/toolchain/debug-config.ts +262 -522
  157. package/src/toolchain/env-check.ts +279 -285
  158. package/src/toolchain/index.ts +1792 -1359
  159. package/src/toolchain/runners.ts +80 -0
  160. package/src/toolchain/scaffold.ts +355 -296
  161. package/src/toolchain/west-discover.ts +35 -13
  162. package/src/toolchain/west-spawn.ts +174 -168
  163. package/src/west-inventory.ts +102 -0
  164. package/dist/async/timer-polyfill.d.ts +0 -10
  165. package/dist/async/timer-polyfill.js +0 -95
  166. package/dist/chips/board-overrides.d.ts +0 -7
  167. package/dist/chips/board-overrides.js +0 -11
  168. package/dist/chips/esp32.d.ts +0 -2
  169. package/dist/chips/esp32.js +0 -71
  170. package/dist/chips/esp32s3.d.ts +0 -2
  171. package/dist/chips/esp32s3.js +0 -103
  172. package/dist/chips/soc/.d.ts +0 -2
  173. package/dist/chips/soc/.js +0 -129
  174. package/dist/chips/soc/esp32.d.ts +0 -2
  175. package/dist/chips/soc/esp32.js +0 -120
  176. package/dist/chips/soc/esp32c3.d.ts +0 -2
  177. package/dist/chips/soc/esp32c3.js +0 -90
  178. package/dist/chips/soc/esp32c6.d.ts +0 -2
  179. package/dist/chips/soc/esp32c6.js +0 -109
  180. package/dist/chips/soc/esp32s3.d.ts +0 -2
  181. package/dist/chips/soc/esp32s3.js +0 -189
  182. package/dist/chips/soc/index.d.ts +0 -2
  183. package/dist/chips/soc/index.js +0 -23
  184. package/dist/chips/soc/nrf52840.d.ts +0 -2
  185. package/dist/chips/soc/nrf52840.js +0 -130
  186. package/dist/chips/soc/rp2040.d.ts +0 -2
  187. package/dist/chips/soc/rp2040.js +0 -141
  188. package/dist/chips/soc/rp2350a.d.ts +0 -2
  189. package/dist/chips/soc/rp2350a.js +0 -145
  190. package/dist/chips/soc/samd21g18a.d.ts +0 -2
  191. package/dist/chips/soc/samd21g18a.js +0 -143
  192. package/dist/chips/soc/stm32f411xe.d.ts +0 -2
  193. package/dist/chips/soc/stm32f411xe.js +0 -251
  194. package/dist/chips/xiao-ble.d.ts +0 -2
  195. package/dist/chips/xiao-ble.js +0 -100
  196. package/dist/lowering/pulse.d.ts +0 -7
  197. package/dist/lowering/pulse.js +0 -51
  198. package/dist/lowering/tone.d.ts +0 -10
  199. package/dist/lowering/tone.js +0 -63
  200. package/dist/lowering/worker-backing.d.ts +0 -14
  201. package/dist/lowering/worker-backing.js +0 -79
  202. package/dist/lowering/worker.d.ts +0 -6
  203. package/dist/lowering/worker.js +0 -14
  204. package/dist/sdk/board-data.generated.d.ts +0 -2
  205. package/dist/sdk/board-data.generated.js +0 -4
  206. package/dist/sdk/catalog-walker.d.ts +0 -90
  207. package/dist/sdk/catalog-walker.js +0 -682
  208. package/dist/sdk/dts-reader.d.ts +0 -83
  209. package/dist/sdk/dts-reader.js +0 -596
  210. package/src/debug-codegen.ts +0 -207
package/dist/doctor.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // ---------------------------------------------------------------------------
2
2
  // @typecad/framework-zephyr — Zephyr environment doctor
3
3
  //
4
- // `cuttlefish doctor` (Zephyr framework) — verify west (the Zephyr build tool)
4
+ // `typecad-hal doctor` (Zephyr framework) — verify west (the Zephyr build tool)
5
5
  // is installed + responsive, the Zephyr RTOS is inside the framework's declared
6
6
  // compat range, and the configured board target exists in the checkout. Exits 0
7
7
  // if the environment is OK, non-zero otherwise. Follows the same contract
@@ -11,7 +11,7 @@
11
11
  import { existsSync, readFileSync } from 'node:fs';
12
12
  import { join } from 'node:path';
13
13
  import * as ui from '@typecad/cuttlefish/utils/ui';
14
- import { loadCuttlefishConfig } from '@typecad/cuttlefish/config-loader';
14
+ import { loadTypecadConfig } from '@typecad/cuttlefish/config-loader';
15
15
  import { checkZephyrEnv } from './toolchain/env-check.js';
16
16
  import { PINNED_ZEPHYR_MANIFEST_REV, PINNED_ZEPHYR_SDK_VERSION, sdkFingerprint } from '@typecad/cuttlefish/board-catalog';
17
17
  import { resolveChipFromBoard } from './chips/resolve.js';
@@ -23,7 +23,7 @@ import { resolveChipFromBoard } from './chips/resolve.js';
23
23
  export function runDoctor() {
24
24
  ui.printHeader();
25
25
  ui.printStep('Checking Zephyr environment...');
26
- const config = loadCuttlefishConfig(process.cwd());
26
+ const config = loadTypecadConfig(process.cwd());
27
27
  const buildTarget = config?.buildTarget;
28
28
  const result = checkZephyrEnv(buildTarget);
29
29
  const c = result.check;
@@ -69,7 +69,7 @@ export function runDoctor() {
69
69
  }
70
70
  }
71
71
  else {
72
- ui.printInfo('(no buildTarget in cuttlefish.config.ts — skipping board check)');
72
+ ui.printInfo('(no buildTarget in typecad-hal.config.ts — skipping board check)');
73
73
  }
74
74
  // Probe methods — from the board package's table, via the board constants
75
75
  // the transpile persists (candidates cover the standard out-dir layouts).
@@ -69,7 +69,7 @@ export function generateCustomBoard(projectRoot, chip, rawName) {
69
69
  '# package (or add a board package) instead of this file.',
70
70
  'board:',
71
71
  ` name: ${name}`,
72
- ` full_name: Cuttlefish custom board (${chip.soc})`,
72
+ ` full_name: TypeCAD custom board (${chip.soc})`,
73
73
  ` vendor: ${CUSTOM_BOARD_VENDOR}`,
74
74
  ' socs:',
75
75
  ` - name: ${soc}`,
@@ -95,7 +95,7 @@ export function generateCustomBoard(projectRoot, chip, rawName) {
95
95
  ...cb.dtsIncludes.map((inc) => `#include <${inc}>`),
96
96
  '',
97
97
  '/ {',
98
- ` model = "Cuttlefish custom board (${chip.soc})";`,
98
+ ` model = "TypeCAD custom board (${chip.soc})";`,
99
99
  ` compatible = "${CUSTOM_BOARD_VENDOR},${name.replace(/_/g, '-')}";`,
100
100
  '',
101
101
  ' chosen {',
@@ -20,6 +20,12 @@ export interface KconfigUsage {
20
20
  usesFS?: boolean;
21
21
  usesHwtimer?: boolean;
22
22
  usesI2c?: boolean;
23
+ /** I2C target mode used (i2c.resp_* ops — the responder). Enables the
24
+ * i2c_target API paths: driver implementations are gated on it (e.g.
25
+ * STM32 compiles target support + selects interrupt mode only under
26
+ * I2C_TARGET); controllers without target support still build and
27
+ * return -ENOSYS at registration, which the shim prints loudly. */
28
+ usesI2cTarget?: boolean;
23
29
  usesSpi?: boolean;
24
30
  usesUart?: boolean;
25
31
  /** USB CDC-ACM serial used (usb.* ops). Selects the "next" USB device
@@ -30,6 +36,22 @@ export interface KconfigUsage {
30
36
  usesWdt?: boolean;
31
37
  usesBle?: boolean;
32
38
  usesDisplay?: boolean;
39
+ /** How the UI adapter reaches the panel. 'zephyr-display' binds the
40
+ * in-tree drivers (CONFIG_MIPI_DBI_SPI on); 'direct-spi' (default)
41
+ * force-disables them — the adapter drives the panel itself. */
42
+ displayTransport?: 'direct-spi' | 'zephyr-display';
43
+ /** Panel controller for the display Kconfig symbol when the transport
44
+ * needs one explicitly. Synthesized (compatible-driven) profiles carry
45
+ * none — their driver symbol auto-defaults on from the DT node
46
+ * (`default y depends on DT_HAS_<COMPATIBLE>_ENABLED`), so no symbol
47
+ * is assigned at all. */
48
+ displayController?: 'st7796s' | 'ili9341' | 'ssd16xx' | 'uc81xx';
49
+ /** Panel bus family from the binding harvest: i2c-family panels (mono
50
+ * OLEDs) get I2C and no SPI/MIPI/DMA block at all. */
51
+ displayBus?: 'i2c' | 'spi';
52
+ /** Profile-required Kconfig fragments, appended verbatim (e.g. the SDL
53
+ * panel's mono pixel-format choice on native_sim). */
54
+ displayKconfigExtra?: readonly string[];
33
55
  usesWifi?: boolean;
34
56
  usesHttp?: boolean;
35
57
  usesMqtt?: boolean;
@@ -43,6 +65,44 @@ export interface KconfigUsage {
43
65
  * umbrella under which every driver sensor Kconfig lives (`if SENSOR`);
44
66
  * the per-driver symbols default on from their DT node presence. */
45
67
  usesSensor?: boolean;
68
+ /** Addressable LED strip (strip.* ops → ws2812-spi child). */
69
+ usesStrip?: boolean;
70
+ /** Strips the program drives: SPI controller index → chain length.
71
+ * Scanned from the emitted shim's buffer declarations. */
72
+ strips?: Array<{
73
+ index: number;
74
+ count: number;
75
+ }>;
76
+ /** USB HID keyboard/mouse (hid.* ops → zephyr,hid-device node). */
77
+ usesHid?: boolean;
78
+ /** Which HID protocol the program drives — picks the DT node's
79
+ * protocol-code and the report descriptor. */
80
+ hidProtocol?: 'keyboard' | 'mouse';
81
+ /** GPIO key matrix (matrix.* ops → gpio-kbd-matrix node). */
82
+ usesMatrix?: boolean;
83
+ /** The matrix's construction pad lists (from the lowering marker). */
84
+ matrix?: {
85
+ rows: number[];
86
+ cols: number[];
87
+ };
88
+ /** Explicit power-state entry (power.* ops → sys_poweroff). */
89
+ usesPower?: boolean;
90
+ /** Wall-clock time (clock.* ops → rtc alias). */
91
+ usesClock?: boolean;
92
+ /** CAN bus (can.* ops → the harvested can@ controller). */
93
+ usesCan?: boolean;
94
+ /** I2S audio (i2s.* ops → the harvested i2s@ controller). */
95
+ usesI2s?: boolean;
96
+ /** CAN loopback constructed (CAN_MODE_LOOPBACK in the emission) — the
97
+ * overlay routes both TWAI functions onto one pad (no transceiver). */
98
+ canLoopback?: boolean;
99
+ /** The counter the rtc shim wraps (label + optional timer parent for
100
+ * the child-form ESP32 counters). Omitted when the board ships its own
101
+ * rtc alias — the lowering uses the hardware node. */
102
+ clockShimCounter?: {
103
+ label: string;
104
+ parent?: string;
105
+ };
46
106
  /** Distinct constructed sensors — only the overlay generator consumes this
47
107
  * (one DT child node per entry, on the given I2C controller index); prj.conf
48
108
  * ignores it. Same adcReadPins/pwmUsedPins pattern. */
@@ -50,10 +110,11 @@ export interface KconfigUsage {
50
110
  part: string;
51
111
  busIndex: number;
52
112
  port: number;
53
- busKind: 'i2c' | 'spi';
113
+ busKind: 'i2c' | 'spi' | 'w1';
54
114
  spiHz?: number;
55
115
  spiMode?: number;
56
116
  alertPin?: number;
117
+ resolution?: number;
57
118
  }[];
58
119
  /** Distinct thin SPI targets (hal/spi-target.ts) — one DT child node per
59
120
  * entry (no compatible — a raw spi_dt_spec peer), appended after sensor
@@ -37,6 +37,11 @@ export function resolveKconfigFragments(usage, debug) {
37
37
  // DT_HAS_<COMPAT>_ENABLED, so the overlay's child node enables the driver.
38
38
  if (usage.usesSensor)
39
39
  m.set('CONFIG_SENSOR', 'y');
40
+ // 1-Wire masters: the w1 core + the bit-banged GPIO driver (default-on
41
+ // via the synthesized node, but the core W1 menuconfig gates the
42
+ // drivers — set it explicitly so the menu default cannot hide it).
43
+ if ((usage.sensorParts ?? []).some((sp) => sp.busKind === 'w1'))
44
+ m.set('CONFIG_W1', 'y');
40
45
  // The rare driver that is NOT DT-default-on: the catalog records its
41
46
  // Kconfig lines (from the driver's own Kconfig) and they are applied for
42
47
  // exactly the parts the program constructs. Empty for every in-tree part
@@ -51,10 +56,48 @@ export function resolveKconfigFragments(usage, debug) {
51
56
  }
52
57
  if (usage.usesPwm)
53
58
  m.set('CONFIG_PWM', 'y');
59
+ if (usage.usesStrip)
60
+ m.set('CONFIG_LED_STRIP', 'y');
61
+ // HID rides the same "next" device stack as CDC — the class is selected by
62
+ // the zephyr,hid-device node the overlay synthesizes.
63
+ if (usage.usesHid) {
64
+ m.set('CONFIG_USB_DEVICE_STACK_NEXT', 'y');
65
+ m.set('CONFIG_USBD_HID_SUPPORT', 'y');
66
+ }
67
+ if (usage.usesMatrix) {
68
+ m.set('CONFIG_INPUT', 'y');
69
+ m.set('CONFIG_INPUT_GPIO_KBD_MATRIX', 'y');
70
+ }
71
+ // sys_poweroff() only exists when the kernel builds the poweroff service
72
+ // (the SoC hook compiles under this symbol — without it the link fails
73
+ // with an undefined reference).
74
+ if (usage.usesPower)
75
+ m.set('CONFIG_POWEROFF', 'y');
76
+ // The rtc subsystem; the counter shim driver defaults on when the
77
+ // synthesized zephyr,rtc-counter node exists. RTC_INIT_PRIORITY defaults
78
+ // to KERNEL_INIT_PRIORITY_DEVICE (=50) which is BELOW the counter driver
79
+ // (=60) — the shim asserts it inits after its parent counter, so raise
80
+ // it whenever the shim is in play.
81
+ if (usage.usesCan)
82
+ m.set('CONFIG_CAN', 'y');
83
+ // I2S needs the DMA umbrella + the ESP32 GDMA driver (the controller
84
+ // DMA-runs through the gdma node the overlay enables — the driver is
85
+ // default-y once the node is on, but the umbrella needs the explicit
86
+ // set because nothing else pulls it in).
87
+ if (usage.usesI2s) {
88
+ m.set('CONFIG_I2S', 'y');
89
+ m.set('CONFIG_DMA', 'y');
90
+ }
91
+ if (usage.usesClock) {
92
+ m.set('CONFIG_RTC', 'y');
93
+ m.set('CONFIG_RTC_INIT_PRIORITY', '70');
94
+ }
54
95
  if (usage.usesDac)
55
96
  m.set('CONFIG_DAC', 'y');
56
97
  if (usage.usesI2c)
57
98
  m.set('CONFIG_I2C', 'y');
99
+ if (usage.usesI2cTarget)
100
+ m.set('CONFIG_I2C_TARGET', 'y');
58
101
  if (usage.usesSpi)
59
102
  m.set('CONFIG_SPI', 'y');
60
103
  // USB CDC-ACM serial: the "next" USB device stack + the CDC-ACM class.
@@ -93,38 +136,92 @@ export function resolveKconfigFragments(usage, debug) {
93
136
  m.set('CONFIG_COUNTER', 'y');
94
137
  if (usage.usesDisplay) {
95
138
  m.set('CONFIG_DISPLAY', 'y');
96
- m.set('CONFIG_SPI', 'y');
97
- m.set('CONFIG_MIPI_DBI', 'y');
98
- // Enable GDMA so the ESP32 SPI driver uses DMA for panel transfers instead
99
- // of PIO through the 64-byte hardware FIFO. Without DMA a full 480x320 fill
100
- // takes ~110ms (effectively ~4MHz); with DMA the same transfer runs at the
101
- // configured SPI clock (~80MHz) and drops into the low tens of ms. The
102
- // display overlay pairs this with dma-enabled + dmas on the spi2 node.
103
- m.set('CONFIG_DMA', 'y');
104
- // Disable the MIPI DBI SPI bridge + in-tree panel drivers (ILI9341,
105
- // ST7796S). The display adapter drives the panel directly via spi_write.
106
- // Binding these drivers would allocate a tearing-effect GPIO interrupt
107
- // that conflicts with the SPI/I2C driver interrupts — the
108
- // VECDESC_FL_SHARED assertion crashes on touch. ILI9341 matters as much
109
- // as the bridge: the driver auto-defaults on from the overlay's
110
- // ilitek,ili9341 node and references the (disabled) mipi-dbi-spi
111
- // controller's device struct, failing at link time with
112
- // "undefined reference to __device_dts_ord_N". (Assign the prompted
113
- // ILI9341, not the hidden ILI9XXX — promptless symbols reject prj.conf
114
- // assignments.)
115
- m.set('CONFIG_MIPI_DBI_SPI', 'n');
116
- m.set('CONFIG_ILI9341', 'n');
117
- m.set('CONFIG_ST7796S', 'n');
139
+ if (usage.displayBus === 'i2c' || usage.displayKconfigExtra) {
140
+ // Self-describing panels — no SPI bridge, no DMA:
141
+ // - i2c-family (mono OLEDs, ssd1306-class): an I2C child node; the
142
+ // panel driver self-builds from it.
143
+ // - board-provided panels (native_sim's sdl_dc): the board's own DTS
144
+ // wires the display; the profile's extra fragments (e.g. the SDL
145
+ // panel's mono pixel-format choice) land here verbatim.
146
+ if (usage.displayBus === 'i2c')
147
+ m.set('CONFIG_I2C', 'y');
148
+ for (const frag of usage.displayKconfigExtra ?? []) {
149
+ const eq = frag.indexOf('=');
150
+ if (eq > 0)
151
+ m.set(frag.slice(0, eq).trim(), frag.slice(eq + 1).trim());
152
+ }
153
+ }
154
+ else {
155
+ m.set('CONFIG_SPI', 'y');
156
+ m.set('CONFIG_MIPI_DBI', 'y');
157
+ // Enable GDMA so the ESP32 SPI driver uses DMA for panel transfers instead
158
+ // of PIO through the 64-byte hardware FIFO. Without DMA a full 480x320 fill
159
+ // takes ~110ms (effectively ~4MHz); with DMA the same transfer runs at the
160
+ // configured SPI clock (~80MHz) and drops into the low tens of ms. The
161
+ // display overlay pairs this with dma-enabled + dmas on the spi2 node.
162
+ m.set('CONFIG_DMA', 'y');
163
+ if (usage.displayTransport === 'zephyr-display') {
164
+ // Native display-API transport: the mipi-dbi SPI bridge hosts the
165
+ // panel driver, which owns init/rotation/wire format. Controller-
166
+ // specific exceptions and the drop-in (compatible-driven) path:
167
+ // - st7796s (registry profile): the stock bridge deasserts CS
168
+ // between command and parameters (scrambles clone panels), so it
169
+ // stays OFF — the adapter emits an app-local CS-holding host.
170
+ // - ili9341 (registry profile): assign the prompted symbol explicitly
171
+ // (survives DT-only probes; not the hidden ILI9XXX).
172
+ // - synthesized profiles (no controller): assign NOTHING — panel
173
+ // drivers are `default y depends on DT_HAS_<COMPATIBLE>_ENABLED`,
174
+ // so the overlay's enabled node builds its own driver.
175
+ if (usage.displayController === 'st7796s') {
176
+ m.set('CONFIG_MIPI_DBI_SPI', 'n');
177
+ m.set('CONFIG_ST7796S', 'y');
178
+ }
179
+ else if (usage.displayController === 'ili9341') {
180
+ m.set('CONFIG_MIPI_DBI_SPI', 'y');
181
+ m.set('CONFIG_ILI9341', 'y');
182
+ }
183
+ else {
184
+ m.set('CONFIG_MIPI_DBI_SPI', 'y');
185
+ }
186
+ // E-ink families (Stage 4): the panel driver under the mipi-dbi SPI
187
+ // bridge — ssd16xx/uc81xx own the flash-cycle refresh + BUSY wait.
188
+ if (usage.displayController === 'ssd16xx') {
189
+ m.set('CONFIG_SSD16XX', 'y');
190
+ }
191
+ else if (usage.displayController === 'uc81xx') {
192
+ m.set('CONFIG_UC81XX', 'y');
193
+ }
194
+ }
195
+ else {
196
+ // Direct-spi transport (default): the display adapter drives the panel
197
+ // directly via spi_write. Disable the MIPI DBI SPI bridge + in-tree panel
198
+ // drivers (ILI9341, ST7796S) — binding them would allocate a
199
+ // tearing-effect GPIO interrupt that conflicts with the SPI/I2C driver
200
+ // interrupts — the VECDESC_FL_SHARED assertion crashes on touch.
201
+ // ILI9341 matters as much as the bridge: the driver auto-defaults on
202
+ // from the overlay's ilitek,ili9341 node and references the (disabled)
203
+ // mipi-dbi-spi controller's device struct, failing at link time with
204
+ // "undefined reference to __device_dts_ord_N".
205
+ m.set('CONFIG_MIPI_DBI_SPI', 'n');
206
+ m.set('CONFIG_ILI9341', 'n');
207
+ m.set('CONFIG_ST7796S', 'n');
208
+ }
209
+ }
118
210
  }
119
211
  if (usage.usesTouch) {
120
- // FT6336U touch is on I2C; the XPT2046 shares the display's SPI bus.
121
- // CONFIG_INPUT stays off either way: the adapters drive the controllers
122
- // directly, and enabling it would build the in-tree input drivers
123
- // (ft5336 / xpt2046) against nodes these adapters already own.
124
212
  if (usage.touchController === 'xpt2046') {
213
+ // XPT2046 rides the display's SPI bus — the raw adapter owns the chip
214
+ // (CONFIG_INPUT stays off: the in-tree driver's DT min/max scaling
215
+ // would double-apply the runtime calibration — see touch-adapter.ts).
125
216
  m.set('CONFIG_SPI', 'y');
126
217
  }
127
218
  else {
219
+ // FT6336U through the input subsystem: the in-tree focaltech driver
220
+ // owns the controller in polling mode (no int-gpios on the node — no
221
+ // GPIO IRQ is registered, sidestepping the ESP32 VECDESC_FL_SHARED
222
+ // crash the interrupt path hit). The adapter listens for its events.
223
+ m.set('CONFIG_INPUT', 'y');
224
+ m.set('CONFIG_INPUT_FT5336', 'y');
128
225
  m.set('CONFIG_I2C', 'y');
129
226
  }
130
227
  }
@@ -246,12 +343,16 @@ export function resolveKconfigFragments(usage, debug) {
246
343
  // pinned-CA handshake fails with EPERM at connect (the insecure path
247
344
  // skips verification, so it works either way).
248
345
  m.set('CONFIG_MBEDTLS_X509_CRT_PARSE_C', 'y');
249
- // KNOWN LIMITATION on this Zephyr tree: pinned-CA (verified TLS) fails at
250
- // connect — the tf-psa-crypto mbedTLS needs a wider symbol matrix
251
- // (RSA public-key parse + PEM/DER glue) than the single-ciphersuite
252
- // select pulls in, and forcing the extra symbols regresses the insecure
253
- // path. insecure() HTTPS is fully verified; caCert() chain verification
254
- // stays open until the upstream matrix is mapped.
346
+ // KNOWN LIMITATION on this Zephyr tree: pinned-CA (verified TLS) was
347
+ // observed failing at connect with EPERM — the tf-psa-crypto mbedTLS
348
+ // needs a wider symbol matrix (RSA public-key parse + PEM/DER glue)
349
+ // than the single-ciphersuite select pulls in, and forcing the extra
350
+ // symbols regressed the insecure path (two hardware cycles proved it
351
+ // upstream). CAVEAT: that diagnosis predates the 2026-09 fix of the
352
+ // request-fact reset ordering (every option — including caCert — was
353
+ // being wiped before each send, which alone reproduces connect
354
+ // failures); the matrix limitation needs a hardware re-run to confirm
355
+ // it still applies. insecure() HTTPS and no-CA https are unaffected.
255
356
  // Handshake/protocol buffers allocate from the mbedTLS heap; MBEDTLS_HEAP_SIZE
256
357
  // must hold ~2x MBEDTLS_SSL_MAX_CONTENT_LEN plus working state. 65000 fits on
257
358
  // the ESP32; mbedTLS requires the full libc and PEM (not DER) cert format.
@@ -306,12 +407,14 @@ export function resolveKconfigFragments(usage, debug) {
306
407
  // pinned-CA handshake fails with EPERM at connect (the insecure path
307
408
  // skips verification, so it works either way).
308
409
  m.set('CONFIG_MBEDTLS_X509_CRT_PARSE_C', 'y');
309
- // KNOWN LIMITATION on this Zephyr tree: pinned-CA (verified TLS) fails at
310
- // connect — the tf-psa-crypto mbedTLS needs a wider symbol matrix
311
- // (RSA public-key parse + PEM/DER glue) than the single-ciphersuite
312
- // select pulls in, and forcing the extra symbols regresses the insecure
313
- // path. insecure() HTTPS is fully verified; caCert() chain verification
314
- // stays open until the upstream matrix is mapped.
410
+ // KNOWN LIMITATION on this Zephyr tree: pinned-CA (verified TLS) was
411
+ // observed failing at connect with EPERM — the tf-psa-crypto mbedTLS
412
+ // needs a wider symbol matrix (RSA public-key parse + PEM/DER glue)
413
+ // than the single-ciphersuite select pulls in. CAVEAT: that diagnosis
414
+ // was made on the HTTPS path and predates the 2026-09 request-fact
415
+ // reset-ordering fix (options were wiped before every send, which
416
+ // alone reproduces connect failures); it is shared here because mqtts
417
+ // pins its CA through the same matrix — re-verify on hardware.
315
418
  m.set('CONFIG_MBEDTLS_ENABLE_HEAP', 'y');
316
419
  // 2x SSL_MAX_CONTENT_LEN record buffers + CA-chain parse state +
317
420
  // handshake working memory. 65000 fit insecure-mode handshakes but the
@@ -5,7 +5,7 @@ import type { KconfigUsage } from './kconfig.js';
5
5
  * Generate the overlay source for a board + usage. Returns the overlay text
6
6
  * (caller writes it to app/boards/<board>.overlay via writeIfChanged).
7
7
  */
8
- /** Display wiring from cuttlefish.config.ts (cs/dc/rst/spiFrequency/spiPins). */
8
+ /** Display wiring from typecad-hal.config.ts (cs/dc/rst/spiFrequency/spiPins). */
9
9
  export interface DisplayWiring {
10
10
  cs?: number;
11
11
  dc?: number;
@@ -13,7 +13,20 @@ export interface DisplayWiring {
13
13
  /** Tearing-effect (TE) GPIO from display.tearingEffectPin — emitted as
14
14
  * te-gpios on the display DT node. Opt-in; most boards don't wire TE. */
15
15
  tearingEffectPin?: number;
16
+ /** E-ink BUSY GPIO from display.busyPin — emitted as busy-gpios on the
17
+ * panel child (required by the ssd16xx/uc81xx bindings, active-high). */
18
+ busyPin?: number;
16
19
  spiFrequency?: number;
20
+ /** I2C address for i2c-family panels (mono OLEDs, ssd1306-class). */
21
+ address?: number;
22
+ /** I2C bus pins for i2c-family panels. When present, the overlay remuxes
23
+ * the I2C controller's pinctrl to these pins — the board's default I2C
24
+ * pins rarely match a breakout's wiring (same rationale as the SPI pins
25
+ * below; the ESP32 pinctrl headers carry the named I2C0_*_GPIOn macros).
26
+ * Shared bus: when touch wiring also remuxes, the last assignment wins —
27
+ * wire both to the same pins. */
28
+ sda?: number;
29
+ scl?: number;
17
30
  /** SPI bus pins. When present, the overlay remuxes the SPI controller's
18
31
  * pinctrl to these pins (the board defaults rarely match a breakout's
19
32
  * wiring — e.g. demo-st's panel is on SCK=18/MOSI=23, not the devkitc
@@ -28,7 +41,7 @@ export interface DisplayWiring {
28
41
  * backlight init is guarded by `DT_HAS_ALIAS` and compiles away. */
29
42
  backlightPin?: number;
30
43
  }
31
- /** Touch wiring from cuttlefish.config.ts (irq/resetPin/sda/scl; cs for SPI
44
+ /** Touch wiring from typecad-hal.config.ts (irq/resetPin/sda/scl; cs for SPI
32
45
  * resistive controllers, calibration for the XPT2046 DT binding). */
33
46
  export interface TouchWiring {
34
47
  /** Touch controller kind — selects the DT node shape (FT6336U node on I2C0