@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,16 @@
1
+ import * as catalog from '@typecad/cuttlefish/board-catalog';
2
+ export type BoardCatalogSyncReport = catalog.BoardCatalogSyncReport;
3
+ export type BoardCatalogEnsureResult = catalog.BoardCatalogEnsureResult;
4
+ export type BoardCatalogOverlay = catalog.BoardCatalogOverlay;
5
+ export declare const GENERATOR_REV: number, isZephyrBase: typeof catalog.isZephyrBase, locateZephyrBaseCheap: typeof catalog.locateZephyrBaseCheap, overlayPathFor: typeof catalog.overlayPathFor, readBoardCatalogOverlayFile: typeof catalog.readBoardCatalogOverlayFile, loadBoardCatalogOverlay: typeof catalog.loadBoardCatalogOverlay, resetBoardCatalogOverlayCache: typeof catalog.resetBoardCatalogOverlayCache, isOverlayStale: typeof catalog.isOverlayStale, diffBoardCatalogs: typeof catalog.diffBoardCatalogs, boardRecordFingerprint: typeof catalog.boardRecordFingerprint, findBoardInCatalog: typeof catalog.findBoardInCatalog, activeBoardCatalog: typeof catalog.activeBoardCatalog, resetActiveBoardCatalog: typeof catalog.resetActiveBoardCatalog;
6
+ /** Sync with the full west discovery cascade behind it (the CLI's path):
7
+ * falls back through spawn-based discovery when the cheap fs probes find
8
+ * nothing. */
9
+ export declare function syncBoardCatalog(opts?: {
10
+ zephyrBase?: string;
11
+ }): catalog.BoardCatalogSyncReport;
12
+ /** The build-path pre-step: refresh a stale overlay before a regen
13
+ * (fs-only discovery — no spawns during builds). */
14
+ export declare function ensureFreshBoardCatalog(): catalog.BoardCatalogEnsureResult;
15
+ /** Locate a Zephyr tree by any means (spawn cascade included). */
16
+ export declare function locateZephyrBaseFull(): string | undefined;
@@ -0,0 +1,41 @@
1
+ // ---------------------------------------------------------------------------
2
+ // sdk/board-catalog-sync.ts — framework-side catalog orchestration.
3
+ //
4
+ // The catalog tooling (walker, overlay store, fs-only discovery) lives in
5
+ // @typecad/cuttlefish/board-catalog — the create flow needs it before any
6
+ // framework is installed. This module adds the one thing the framework owns
7
+ // — the full spawn-based west discovery cascade for an explicit
8
+ // `cuttlefish board sync` — and re-exports the store for the strategy's
9
+ // import surface.
10
+ // ----------------------------------------------------------------------------
11
+ import path from 'node:path';
12
+ import * as catalog from '@typecad/cuttlefish/board-catalog';
13
+ import { discoverWest } from '../toolchain/west-discover.js';
14
+ export const { GENERATOR_REV, isZephyrBase, locateZephyrBaseCheap, overlayPathFor, readBoardCatalogOverlayFile, loadBoardCatalogOverlay, resetBoardCatalogOverlayCache, isOverlayStale, diffBoardCatalogs, boardRecordFingerprint, findBoardInCatalog, activeBoardCatalog, resetActiveBoardCatalog, } = catalog;
15
+ /** Sync with the full west discovery cascade behind it (the CLI's path):
16
+ * falls back through spawn-based discovery when the cheap fs probes find
17
+ * nothing. */
18
+ export function syncBoardCatalog(opts = {}) {
19
+ if (opts.zephyrBase)
20
+ return catalog.syncBoardCatalog(opts);
21
+ const cheap = catalog.locateZephyrBaseCheap();
22
+ if (cheap)
23
+ return catalog.syncBoardCatalog({ zephyrBase: cheap });
24
+ const install = discoverWest();
25
+ const base = install?.zephyrBase && catalog.isZephyrBase(install.zephyrBase)
26
+ ? path.resolve(install.zephyrBase)
27
+ : undefined;
28
+ return catalog.syncBoardCatalog(base ? { zephyrBase: base } : {});
29
+ }
30
+ /** The build-path pre-step: refresh a stale overlay before a regen
31
+ * (fs-only discovery — no spawns during builds). */
32
+ export function ensureFreshBoardCatalog() {
33
+ return catalog.ensureFreshBoardCatalog();
34
+ }
35
+ /** Locate a Zephyr tree by any means (spawn cascade included). */
36
+ export function locateZephyrBaseFull() {
37
+ const install = discoverWest();
38
+ return install?.zephyrBase && catalog.isZephyrBase(install.zephyrBase)
39
+ ? path.resolve(install.zephyrBase)
40
+ : undefined;
41
+ }
@@ -0,0 +1,2 @@
1
+ export { BOARD_DATA } from '@typecad/cuttlefish/api/shared';
2
+ export type { BoardDataEntry } from '@typecad/cuttlefish/api/shared';
@@ -0,0 +1,4 @@
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';
@@ -0,0 +1,90 @@
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;