@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
@@ -1,79 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Zephyr worker-offload backing (system workqueue + counting semaphore)
3
- //
4
- // Supplies the spawn/signal/poll primitives that the shared worker_runtime
5
- // polyfill calls into, for Zephyr targets. This is the Zephyr-native analog of
6
- // the ESP32 FreeRTOS backing (framework-esp32/src/lowering/worker-backing.ts):
7
- //
8
- // ESP32 (FreeRTOS) Zephyr
9
- // ───────────────────────── ─────────────────────────────────────────
10
- // xTaskCreate + vTaskDelete k_work_submit to the system workqueue
11
- // xTaskNotifyGive (barrier) k_sem_give (kernel barrier)
12
- // ulTaskNotifyTake(0) k_sem_take(K_NO_WAIT)
13
- //
14
- // The worker runs on the system workqueue thread (a real kernel thread, not an
15
- // ISR), so it can execute a full function. Completion is signalled via a per-
16
- // slot counting semaphore given from workqueue thread context (k_sem_give is
17
- // safe from thread context — NOT k_sem_give from an ISR; workqueue handlers run
18
- // in thread context). k_sem provides the memory barrier the contract requires.
19
- //
20
- // IMPORTANT: the system workqueue has a fixed stack (CONFIG_SYSTEM_WORKQUEUE_
21
- // STACK_SIZE). The scaffold bumps it because heavy workers (TLS, sensor fusion)
22
- // overflow the default ~2 KB. Pin a large worker to a private workqueue if it
23
- // exceeds the system queue's stack.
24
- // ---------------------------------------------------------------------------
25
- /**
26
- * Build the Zephyr (k_work + k_sem) worker backing.
27
- *
28
- * Per slot: a `struct k_work _work_<i>` and a `struct k_sem _done_sem_<i>`.
29
- * submit resets the semaphore and submits the work to the system workqueue;
30
- * the work handler runs the trampoline; the trampoline signals completion via
31
- * k_sem_give; done polls via k_sem_take(K_NO_WAIT).
32
- */
33
- export function buildZephyrWorkerBacking(_options = {}) {
34
- return {
35
- requiredIncludes: ['<zephyr/kernel.h>', '<zephyr/work/work.h>'],
36
- declarations: [
37
- `// Zephyr worker backing: per-slot work item + completion semaphore.`,
38
- `// Declared inside the typecad_worker namespace alongside the slots.`,
39
- ],
40
- slotDeclarations: (handleId, trampolineName) => {
41
- // Per-slot completion semaphore (given from workqueue thread context).
42
- // Declared before the trampoline so the trampoline's signalDoneExpr can
43
- // reference it. The trampoline itself is forward-declared by the shared
44
- // runtime above this block.
45
- return [
46
- `// Per-slot completion semaphore.`,
47
- `K_SEM_DEFINE(_done_sem_${handleId}, 0, 1);`,
48
- ``,
49
- `// Per-slot work item + handler. The handler forwards to the shared-`,
50
- `// runtime trampoline (which runs the submitted fn + signals the sem).`,
51
- `static void ${trampolineName}_work_handler(struct k_work* work) {`,
52
- ` (void)work;`,
53
- ` ${trampolineName}(nullptr);`,
54
- `}`,
55
- `K_WORK_DEFINE(_work_${handleId}, ${trampolineName}_work_handler);`,
56
- ];
57
- },
58
- spawnLines: (handleId, trampolineName, _waiterExpr) => {
59
- // The waiter field is unused on Zephyr (the semaphore IS the signal).
60
- // Reset the completion semaphore, then submit the work item to the
61
- // system workqueue. The work handler (bound via K_WORK_DEFINE above)
62
- // runs the shared-runtime trampoline.
63
- return [
64
- `(void)0; // waiter unused: k_sem is the signal`,
65
- `k_sem_reset(&_done_sem_${handleId});`,
66
- `(void)k_work_submit(&_work_${handleId}); // ${trampolineName} on sys workqueue`,
67
- ];
68
- },
69
- signalDoneExpr: (handleId) =>
70
- // Given from workqueue thread context (k_sem_give is thread-safe here).
71
- // k_sem provides the kernel memory barrier making the worker's outputs
72
- // visible to the consumer once k_sem_take succeeds.
73
- `k_sem_give(&_done_sem_${handleId})`,
74
- isDoneExpr: (handleId) =>
75
- // Non-blocking take; its barrier makes the worker's outputs safe to read.
76
- // The shared runtime fast-paths on the volatile done flag first.
77
- `(k_sem_take(&_done_sem_${handleId}, K_NO_WAIT) == 0)`,
78
- };
79
- }
@@ -1,6 +0,0 @@
1
- import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
2
- /** Resolve a HAL worker.* op to C++ against the shared __tc_worker contract. */
3
- export declare function lowerWorker(op: HALOpIR): {
4
- code?: string;
5
- expression?: string;
6
- } | undefined;
@@ -1,14 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Zephyr worker-offload lowering
3
- //
4
- // Delegates the shared worker.* op contract to the cross-framework helper
5
- // lowerWorkerOp (worker-runtime.ts). The per-framework primitives are supplied
6
- // by the Zephyr worker backing (worker-backing.ts: k_work + k_sem), emitted via
7
- // the worker_runtime polyfill when the program uses worker.* ops. See the
8
- // Zephyr strategy's worker backing wiring + generateNativePolyfills.
9
- // ---------------------------------------------------------------------------
10
- import { lowerWorkerOp } from '@typecad/cuttlefish/api/shared';
11
- /** Resolve a HAL worker.* op to C++ against the shared __tc_worker contract. */
12
- export function lowerWorker(op) {
13
- return lowerWorkerOp(op);
14
- }
@@ -1,2 +0,0 @@
1
- export { BOARD_DATA } from '@typecad/cuttlefish/api/shared';
2
- export type { BoardDataEntry } from '@typecad/cuttlefish/api/shared';
@@ -1,4 +0,0 @@
1
- // The board data pack lives in cuttlefish (src/create/) so the scaffolder
2
- // and the framework share one catalog. Re-exported here for boardgen + the
3
- // existing sdk imports.
4
- export { BOARD_DATA } from '@typecad/cuttlefish/api/shared';
@@ -1,90 +0,0 @@
1
- import type { BoardDataEntry } from '@typecad/cuttlefish/api/shared';
2
- /** Provenance of a walked catalog — pins it to the exact tree it describes. */
3
- export interface BoardCatalogProvenance {
4
- /** The Zephyr base directory the walk read (resolved). */
5
- readonly zephyrBase: string;
6
- /** VERSION file contents rendered 'MAJOR.MINOR.PATCH' (best-effort). */
7
- readonly version: string;
8
- /** Git HEAD of the tree when readable (best-effort; tarballs carry none). */
9
- readonly gitHead?: string;
10
- /** Boards-dir mtime (epoch ms) — the fallback change signal for git-less trees. */
11
- readonly boardsMtimeMs: number;
12
- /** ISO timestamp of the walk. */
13
- readonly generatedAt: string;
14
- /** Variant count, carried for quick display without loading `boards`. */
15
- readonly variants: number;
16
- }
17
- /** A completed walk: records in boards/ directory order + provenance. */
18
- export interface BoardCatalogWalkResult {
19
- readonly boards: Readonly<Record<string, BoardDataEntry>>;
20
- readonly provenance: BoardCatalogProvenance;
21
- readonly stats: {
22
- readonly variants: number;
23
- readonly withFacts: number;
24
- readonly failures: number;
25
- };
26
- }
27
- /** board.yml soc lookup, both formats Zephyr ships:
28
- * - legacy single-board (`board:` / top-level `socs:`): every soc listed
29
- * under the socs: block → `uniqueSocs`;
30
- * - multi-board directories (top-level `boards:` list — lyra_24_dvk,
31
- * lyra_dvk, …): each entry carries its own socs; single-soc entries map
32
- * board name → soc in `byName`. Multi-soc entries stay unmapped (their
33
- * variant yamls carry qualified identifiers).
34
- * `boardNames` lists every declared board name (the `boards:` entries and
35
- * the legacy `board:` name) — the CONFIG_BOARD_<X> stem a variant's
36
- * board.cmake guards its runner args with. */
37
- export interface BoardYmlSocIndex {
38
- readonly byName: ReadonlyMap<string, string>;
39
- readonly uniqueSocs: readonly string[];
40
- readonly boardNames: readonly string[];
41
- }
42
- /** Read board.yml's board→soc index (see BoardYmlSocIndex). */
43
- export declare function boardYmlSocIndex(dir: string): BoardYmlSocIndex;
44
- /** How the caller pins runner args to ONE variant of a shared board dir. */
45
- export interface VariantPin {
46
- /** CONFIG_BOARD stems to try in order: the board.yml entry name this
47
- * target belongs to, then the full underscored target name. */
48
- readonly boardConfigs?: readonly string[];
49
- /** The target's soc segment ('nrf5340'). */
50
- readonly soc?: string;
51
- /** Qualifier segments after the soc ('cpunet', ['a53','smp']). */
52
- readonly quals?: readonly string[];
53
- }
54
- export declare function boardProbeMethods(dir: string, variant?: VariantPin): BoardDataEntry['probeMethods'];
55
- /** VERSION file → 'MAJOR.MINOR.PATCH' ('' when unreadable). */
56
- export declare function zephyrVersionOf(zephyrBase: string): string;
57
- /**
58
- * Git HEAD of the tree, read straight off the filesystem (no git spawn —
59
- * sync runs where git may be absent). Handles the plain clone (.git dir,
60
- * HEAD → ref → loose ref or packed-refs) and the worktree/submodule form
61
- * (.git file pointing at a gitdir). Best-effort: undefined when unreadable.
62
- */
63
- export declare function gitHeadOf(zephyrBase: string): string | undefined;
64
- /** Every build target a board.yml declares, with the naming facts the
65
- * synthesizer needs (board.yml-driven dirs ship NO per-variant yamls —
66
- * nucleo_n657x0_q's sb target exists only as a board.yml entry). */
67
- export interface BoardYmlTarget {
68
- readonly identifier: string;
69
- /** The board entry name the target belongs to (CONFIG_BOARD stem). */
70
- readonly boardName: string;
71
- readonly soc?: string;
72
- /** Variant chain segments after the soc ('sb', ['a53','smp']). */
73
- readonly chain: readonly string[];
74
- readonly fullName?: string;
75
- readonly vendor?: string;
76
- }
77
- /**
78
- * Parse board.yml into its declared build targets, both shapes:
79
- * multi-board (`boards:` list) and legacy (`board:` block), with socs and
80
- * (nested) variants. Variant chains accumulate through nesting levels
81
- * (board/soc/v1/v2).
82
- */
83
- export declare function boardYmlTargets(dir: string): BoardYmlTarget[];
84
- /**
85
- * Walk `<zephyrBase>/boards` and extract one record per board variant.
86
- * Reader failures degrade to the base record (identifier/name/vendor/dts +
87
- * probe methods) — a board whose DTS defeats the reader still resolves, it
88
- * just carries no pin facts.
89
- */
90
- export declare function walkBoardCatalog(zephyrBase: string): BoardCatalogWalkResult;