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

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 (52) hide show
  1. package/README.md +13 -1
  2. package/dist/chips/controllers.d.ts +28 -8
  3. package/dist/chips/controllers.js +49 -12
  4. package/dist/chips/resolve.js +32 -6
  5. package/dist/chips/types.d.ts +63 -12
  6. package/dist/chips/xiao-ble.js +12 -0
  7. package/dist/dt-config/kconfig.d.ts +11 -0
  8. package/dist/dt-config/kconfig.js +1 -1
  9. package/dist/dt-config/overlay.js +85 -0
  10. package/dist/framework.manifest.d.ts +20 -30
  11. package/dist/framework.manifest.js +12 -3
  12. package/dist/lowering/adc.d.ts +7 -4
  13. package/dist/lowering/adc.js +25 -11
  14. package/dist/lowering/gpio.js +9 -6
  15. package/dist/lowering/mqtt.js +9 -1
  16. package/dist/lowering/pulse.js +7 -7
  17. package/dist/lowering/pwm.d.ts +21 -3
  18. package/dist/lowering/pwm.js +28 -4
  19. package/dist/lowering/spi.js +2 -2
  20. package/dist/lowering/tone.js +3 -2
  21. package/dist/lowering/wifi.js +28 -5
  22. package/dist/strategy.js +56 -4
  23. package/dist/toolchain/debug-config.js +1 -1
  24. package/dist/toolchain/index.d.ts +1 -1
  25. package/dist/toolchain/index.js +83 -8
  26. package/dist/toolchain/scaffold.d.ts +9 -0
  27. package/dist/toolchain/scaffold.js +45 -0
  28. package/dist/toolchain/west-discover.d.ts +4 -1
  29. package/dist/toolchain/west-discover.js +2 -0
  30. package/dist/toolchain/west-spawn.js +17 -5
  31. package/package.json +5 -5
  32. package/src/chips/controllers.ts +61 -12
  33. package/src/chips/resolve.ts +32 -5
  34. package/src/chips/types.ts +63 -12
  35. package/src/chips/xiao-ble.ts +82 -70
  36. package/src/dt-config/kconfig.ts +12 -1
  37. package/src/dt-config/overlay.ts +546 -450
  38. package/src/framework.manifest.ts +12 -3
  39. package/src/lowering/adc.ts +28 -12
  40. package/src/lowering/gpio.ts +9 -6
  41. package/src/lowering/mqtt.ts +9 -1
  42. package/src/lowering/pulse.ts +7 -7
  43. package/src/lowering/pwm.ts +29 -4
  44. package/src/lowering/spi.ts +2 -2
  45. package/src/lowering/tone.ts +3 -3
  46. package/src/lowering/wifi.ts +29 -5
  47. package/src/strategy.ts +52 -4
  48. package/src/toolchain/debug-config.ts +1 -1
  49. package/src/toolchain/index.ts +645 -565
  50. package/src/toolchain/scaffold.ts +43 -0
  51. package/src/toolchain/west-discover.ts +321 -316
  52. package/src/toolchain/west-spawn.ts +17 -5
@@ -16,7 +16,8 @@
16
16
  // ---------------------------------------------------------------------------
17
17
 
18
18
  import type { SpawnSyncOptions } from 'node:child_process';
19
- import { dirname } from 'node:path';
19
+ import { dirname, join } from 'node:path';
20
+ import { existsSync } from 'node:fs';
20
21
  import { type WestInstall, discoverWest } from './west-discover.js';
21
22
 
22
23
  export interface WestInvocation {
@@ -57,8 +58,19 @@ export function buildEnv(install: WestInstall): NodeJS.ProcessEnv {
57
58
  if (install.zephyrBase && !env.ZEPHYR_BASE) {
58
59
  env.ZEPHYR_BASE = install.zephyrBase;
59
60
  }
60
- const bin = venvBinDir(install);
61
- if (bin) {
61
+ // SWD flashing (`zephyr.runner: 'openocd'`): west's openocd runner resolves
62
+ // a bare `openocd` from PATH. The Zephyr SDK ships it under
63
+ // hosttools/openocd/bin (the SDK's own setup.cmd puts that dir on PATH for
64
+ // activated terminals) — do the same for spawned west processes so ST-Link
65
+ // flashing works without activation. $ZEPHYR_SDK_INSTALL_DIR (set by an
66
+ // activated env) wins over the discovered install dir.
67
+ const sdkRoot = env.ZEPHYR_SDK_INSTALL_DIR || install.sdkInstallDir;
68
+ const openocdBin = sdkRoot ? join(sdkRoot, 'hosttools', 'openocd', 'bin') : undefined;
69
+ const prepend = [
70
+ openocdBin !== undefined && existsSync(openocdBin) ? openocdBin : undefined,
71
+ venvBinDir(install),
72
+ ].filter((d): d is string => d !== undefined);
73
+ if (prepend.length > 0) {
62
74
  const sep = process.platform === 'win32' ? ';' : ':';
63
75
  // On Windows the PATH environment variable may be cased as `Path` (the
64
76
  // registry-native form, the only one populated when node is launched from
@@ -66,9 +78,9 @@ export function buildEnv(install: WestInstall): NodeJS.ProcessEnv {
66
78
  // casing can leave the other stale/empty, which under PowerShell would drop
67
79
  // the user's real PATH (cmake, ninja, …) — breaking `west` configure. Read
68
80
  // whichever casing is populated and write that same casing back, preserving
69
- // the full existing value with the venv dir prepended.
81
+ // the full existing value with the discovered dirs prepended.
70
82
  const existing = env.Path ?? env.PATH ?? '';
71
- const updated = bin + sep + existing;
83
+ const updated = prepend.join(sep) + sep + existing;
72
84
  if (env.Path !== undefined || (env.PATH === undefined && process.platform === 'win32')) {
73
85
  env.Path = updated;
74
86
  } else {