@typecad/cuttlefish 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.
- package/README.md +82 -79
- package/assets/editor-extensions/typecad-debug/README.md +141 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
- package/assets/editor-extensions/typecad-debug/package.json +76 -0
- package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
- package/assets/editor-extensions/typecad-ui/README.md +52 -0
- package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
- package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
- package/assets/editor-extensions/typecad-ui/icon.png +0 -0
- package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
- package/assets/editor-extensions/typecad-ui/package.json +54 -0
- package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
- package/dist/api/config.d.ts +30 -27
- package/dist/api/schema/types.d.ts +20 -3
- package/dist/api/shared/async-runtime-static.d.ts +1 -1
- package/dist/api/shared/async-runtime-static.js +5 -5
- package/dist/api/shared/async-types.d.ts +3 -2
- package/dist/api/shared/board-catalog.d.ts +2 -0
- package/dist/api/shared/board-catalog.js +6 -0
- package/dist/api/shared/board-resolver.d.ts +4 -7
- package/dist/api/shared/board-resolver.js +2 -1
- package/dist/api/shared/coop-scheduler.d.ts +1 -1
- package/dist/api/shared/coop-scheduler.js +1 -1
- package/dist/api/shared/cpp-type-ir.d.ts +1 -1
- package/dist/api/shared/cpp-type-ir.js +1 -1
- package/dist/api/shared/display-profile.d.ts +1 -1
- package/dist/api/shared/display-profile.js +3 -5
- package/dist/api/shared/framework-manifest-registry.d.ts +1 -1
- package/dist/api/shared/framework-manifest-registry.js +0 -1
- package/dist/api/shared/framework-manifest.d.ts +65 -507
- package/dist/api/shared/framework-manifest.js +6 -11
- package/dist/api/shared/hal-op-ir.d.ts +294 -685
- package/dist/api/shared/hal-op-ir.js +31 -65
- package/dist/api/shared/index.d.ts +0 -4
- package/dist/api/shared/index.js +1 -7
- package/dist/api/shared/ir-core.d.ts +6 -0
- package/dist/api/shared/ir-declarations.d.ts +4 -0
- package/dist/api/shared/ir.d.ts +1 -3
- package/dist/api/shared/platform-strategy.d.ts +14 -37
- package/dist/api/shared/polyfill-helper-registry.js +0 -5
- package/dist/api/shared/polyfill-types.js +0 -27
- package/dist/api/shared/promise-runtime.js +3 -3
- package/dist/api/shared/spdx-licenses.d.ts +12 -10
- package/dist/api/shared/spdx-licenses.js +1 -1
- package/dist/api/shared/toolchain-types.d.ts +1 -1
- package/dist/api/shared/toolchain-types.js +3 -3
- package/dist/api/shared/types.d.ts +0 -3
- package/dist/api/shared/validate-framework-manifest.js +13 -33
- package/dist/board-catalog/dts-reader.d.ts +220 -0
- package/dist/board-catalog/dts-reader.js +1052 -0
- package/dist/board-catalog/index.d.ts +11 -0
- package/dist/board-catalog/index.js +12 -0
- package/dist/board-catalog/pinconfig.d.ts +48 -0
- package/dist/board-catalog/pinconfig.js +263 -0
- package/dist/board-catalog/sdk.d.ts +82 -0
- package/dist/board-catalog/sdk.js +180 -0
- package/dist/board-catalog/store.d.ts +196 -0
- package/dist/board-catalog/store.js +363 -0
- package/dist/board-catalog/types.d.ts +233 -0
- package/dist/board-catalog/types.js +7 -0
- package/dist/board-catalog/walker.d.ts +112 -0
- package/dist/board-catalog/walker.js +1101 -0
- package/dist/cli-utils.d.ts +2 -2
- package/dist/cli-utils.js +5 -5
- package/dist/cli.js +227 -244
- package/dist/config-loader.d.ts +14 -19
- package/dist/config-loader.js +242 -78
- package/dist/config-schema.d.ts +19 -227
- package/dist/config-schema.js +9 -8
- package/dist/contract/board-generator.d.ts +4 -4
- package/dist/contract/board-generator.js +16 -5
- package/dist/contract/contract-parser.d.ts +36 -127
- package/dist/contract/contract-parser.js +76 -0
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.js +70 -21
- package/dist/create/active-board-catalog.d.ts +9 -0
- package/dist/create/active-board-catalog.js +94 -0
- package/dist/create/board-catalog.generated.d.ts +96 -0
- package/dist/create/board-catalog.generated.js +128737 -0
- package/dist/create/board-search.d.ts +23 -0
- package/dist/create/board-search.js +88 -0
- package/dist/create/editor-integration.d.ts +32 -0
- package/dist/create/editor-integration.js +257 -0
- package/dist/create/eslint-rules-template.d.ts +2 -2
- package/dist/create/framework-catalog.d.ts +48 -8
- package/dist/create/framework-catalog.js +58 -44
- package/dist/create/index.d.ts +8 -13
- package/dist/create/index.js +5 -9
- package/dist/create/mcu-target.d.ts +39 -0
- package/dist/create/mcu-target.js +80 -0
- package/dist/create/pack-targets.d.ts +19 -0
- package/dist/create/pack-targets.js +56 -0
- package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +8 -11
- package/dist/create/{init-scaffold.js → scaffold.js} +28 -87
- package/dist/create/templates.d.ts +51 -0
- package/dist/create/{init-templates.js → templates.js} +135 -116
- package/dist/create/wizard.d.ts +19 -0
- package/dist/create/wizard.js +314 -0
- package/dist/debug/preprocessor.d.ts +5 -0
- package/dist/debug/preprocessor.js +31 -7
- package/dist/diagnostics/diagnostics-report.d.ts +1 -1
- package/dist/diagnostics/diagnostics-report.js +3 -11
- package/dist/diagnostics/json-schema.d.ts +1 -1
- package/dist/diagnostics/md-writer.js +2 -2
- package/dist/diagnostics/mermaid-builder.d.ts +1 -1
- package/dist/diagnostics/mermaid-builder.js +1 -1
- package/dist/emit/cpp-emitter.js +4 -1
- package/dist/emit/emitters/class-emitter.js +32 -4
- package/dist/emit/emitters/emitter-context.d.ts +11 -0
- package/dist/emit/emitters/entrypoint-synthesizer.js +1 -1
- package/dist/emit/emitters/function-emitter-impl.js +33 -17
- package/dist/emit/emitters/output-finalizer.d.ts +7 -0
- package/dist/emit/emitters/output-finalizer.js +31 -23
- package/dist/emit/emitters/setup.js +147 -63
- package/dist/emit/emitters/top-level-prep.js +1 -1
- package/dist/emit/emitters/type-decl-emitter.js +13 -8
- package/dist/emit/emitters/ui-emitter.js +1 -1
- package/dist/emit/expression-renderer.d.ts +3 -3
- package/dist/emit/expression-renderer.js +17 -7
- package/dist/emit/route-hal-op.js +17 -48
- package/dist/emit/snprintf-helpers.d.ts +1 -3
- package/dist/emit/snprintf-helpers.js +1 -39
- package/dist/emit/statement-renderer.d.ts +0 -4
- package/dist/emit/statement-renderer.js +54 -45
- package/dist/emit/utils/async-state-machine.d.ts +16 -9
- package/dist/emit/utils/async-state-machine.js +56 -54
- package/dist/emit/utils/comment-helpers.d.ts +0 -8
- package/dist/emit/utils/comment-helpers.js +1 -1
- package/dist/emit/utils/cpp-helpers.d.ts +2 -2
- package/dist/emit/utils/cpp-helpers.js +2 -2
- package/dist/emit/utils/hal-op-cpp-type.js +4 -6
- package/dist/emit/utils/index.d.ts +3 -3
- package/dist/emit/utils/index.js +3 -3
- package/dist/emit/utils/type-inference.d.ts +1 -29
- package/dist/emit/utils/type-inference.js +0 -75
- package/dist/framework-package.d.ts +3 -0
- package/dist/framework-package.js +23 -6
- package/dist/framework-registry.d.ts +5 -5
- package/dist/frameworks/native/graphics/terminal-preview.d.ts +5 -0
- package/dist/frameworks/native/graphics/terminal-preview.js +33 -0
- package/dist/frameworks/native/index.d.ts +3 -0
- package/dist/frameworks/native/index.js +15 -0
- package/dist/frameworks/native/native-compile.d.ts +17 -0
- package/dist/frameworks/native/native-compile.js +170 -0
- package/dist/frameworks/native/native-config.d.ts +41 -0
- package/dist/frameworks/native/native-config.js +7 -0
- package/dist/frameworks/native/strategy.d.ts +97 -0
- package/dist/frameworks/native/strategy.js +664 -0
- package/dist/ir/board-resolver.d.ts +18 -23
- package/dist/ir/board-resolver.js +43 -401
- package/dist/ir/build-ir-state.d.ts +3 -0
- package/dist/ir/build-ir-state.js +42 -0
- package/dist/ir/build-ir.d.ts +1 -1
- package/dist/ir/build-ir.js +64 -45
- package/dist/ir/declaration-builders.js +1 -0
- package/dist/ir/expression-to-ir.js +17 -10
- package/dist/ir/hal/hal-emitter.d.ts +0 -2
- package/dist/ir/hal/hal-emitter.js +92 -41
- package/dist/ir/hal/hal-parser.d.ts +5 -5
- package/dist/ir/hal/hal-parser.js +128 -36
- package/dist/ir/hal/hal-plugins.d.ts +0 -1
- package/dist/ir/hal/hal-plugins.js +425 -716
- package/dist/ir/heap-analysis.js +2 -41
- package/dist/ir/identifier-collector.js +32 -20
- package/dist/ir/network-validation.js +7 -11
- package/dist/ir/ownership-analysis.js +75 -13
- package/dist/ir/peripheral-usage.d.ts +8 -2
- package/dist/ir/peripheral-usage.js +78 -149
- package/dist/ir/peripheral-validation.js +23 -3
- package/dist/ir/pin-capability-validation.d.ts +12 -0
- package/dist/ir/pin-capability-validation.js +61 -97
- package/dist/ir/pin-mode-validation.js +5 -5
- package/dist/ir/program-analysis.d.ts +8 -15
- package/dist/ir/program-analysis.js +140 -323
- package/dist/ir/pulldown-validation.js +11 -4
- package/dist/ir/resource-analysis.js +15 -3
- package/dist/ir/statement-to-ir.js +0 -6
- package/dist/ir/timing-validation.js +1 -1
- package/dist/ir/transformers/array-methods.js +11 -5
- package/dist/ir/transformers/call-statement.js +20 -87
- package/dist/ir/transformers/callback-context-registry.d.ts +1 -1
- package/dist/ir/transformers/callback-context-registry.js +8 -16
- package/dist/ir/transformers/control-flow.js +0 -13
- package/dist/ir/transformers/expressions.js +10 -9
- package/dist/ir/transformers/hal-call-resolver.d.ts +2 -2
- package/dist/ir/transformers/hal-call-resolver.js +24 -10
- package/dist/ir/transformers/hal-emit-helpers.d.ts +2 -2
- package/dist/ir/transformers/hal-emit-helpers.js +2 -2
- package/dist/ir/transformers/namespace-methods.js +1 -1
- package/dist/ir/transformers/ui-callback-lowering.d.ts +0 -2
- package/dist/ir/transformers/ui-callback-lowering.js +0 -24
- package/dist/ir/transformers/variables.js +338 -42
- package/dist/ir/try-catch-validation.js +4 -3
- package/dist/ir/type-resolution.js +15 -4
- package/dist/ir/validation-orchestrator.js +0 -9
- package/dist/libdef/cpp-to-decl.d.ts +0 -9
- package/dist/libdef/cpp-to-decl.js +0 -72
- package/dist/libdef/registry.d.ts +0 -1
- package/dist/libdef/registry.js +1 -24
- package/dist/library/catalog.d.ts +35 -0
- package/dist/library/catalog.js +67 -0
- package/dist/library/cli.d.ts +2 -0
- package/dist/library/cli.js +168 -0
- package/dist/library/init.d.ts +25 -0
- package/dist/library/init.js +397 -0
- package/dist/library/install.d.ts +9 -0
- package/dist/library/install.js +80 -0
- package/dist/library/registry-search.d.ts +34 -0
- package/dist/library/registry-search.js +50 -0
- package/dist/library/validate.d.ts +17 -0
- package/dist/library/validate.js +175 -0
- package/dist/library-packages.d.ts +95 -0
- package/dist/library-packages.js +275 -0
- package/dist/mapping/peripheral-names.js +9 -4
- package/dist/mapping/source-map.d.ts +3 -4
- package/dist/mapping/source-map.js +12 -18
- package/dist/orchestrator/graph-builder.d.ts +3 -3
- package/dist/orchestrator/graph-builder.js +29 -12
- package/dist/orchestrator/type-checker.d.ts +3 -3
- package/dist/orchestrator/type-checker.js +3 -3
- package/dist/platform/async-runtime.js +1 -1
- package/dist/platform/coop-scheduler-runtime.js +2 -2
- package/dist/platform/generic-debug-codegen.d.ts +36 -0
- package/dist/platform/generic-debug-codegen.js +185 -0
- package/dist/platform/generic-strategy.d.ts +3 -4
- package/dist/platform/generic-strategy.js +5 -80
- package/dist/platform/index.js +1 -1
- package/dist/platform/registry.d.ts +2 -2
- package/dist/platform/registry.js +2 -2
- package/dist/preview/client.js +17 -3
- package/dist/safety/asil-decorators.d.ts +32 -0
- package/dist/safety/asil-decorators.js +32 -0
- package/dist/safety/authoring.d.ts +85 -0
- package/dist/safety/authoring.js +61 -0
- package/dist/safety/engine.d.ts +3 -0
- package/dist/safety/engine.js +83 -0
- package/dist/safety/hal/ops.d.ts +48 -0
- package/dist/safety/hal/ops.js +46 -0
- package/dist/safety/iso26262/analyze.d.ts +13 -0
- package/dist/safety/iso26262/analyze.js +29 -0
- package/dist/safety/iso26262/asil.d.ts +10 -0
- package/dist/safety/iso26262/asil.js +22 -0
- package/dist/safety/iso26262/collect.d.ts +14 -0
- package/dist/safety/iso26262/collect.js +137 -0
- package/dist/safety/iso26262/goto-checker.d.ts +10 -0
- package/dist/safety/iso26262/goto-checker.js +72 -0
- package/dist/safety/iso26262/heap-checker.d.ts +7 -0
- package/dist/safety/iso26262/heap-checker.js +57 -0
- package/dist/safety/iso26262/init-checker.d.ts +13 -0
- package/dist/safety/iso26262/init-checker.js +127 -0
- package/dist/safety/iso26262/loop-checker.d.ts +7 -0
- package/dist/safety/iso26262/loop-checker.js +86 -0
- package/dist/safety/iso26262/recursion-checker.d.ts +9 -0
- package/dist/safety/iso26262/recursion-checker.js +134 -0
- package/dist/safety/iso26262/sidecar-writer.d.ts +25 -0
- package/dist/safety/iso26262/sidecar-writer.js +13 -0
- package/dist/safety/passes/pinMode-intercept.d.ts +3 -0
- package/dist/safety/passes/pinMode-intercept.js +60 -0
- package/dist/safety/runtime/mode-table.d.ts +5 -0
- package/dist/safety/runtime/mode-table.js +55 -0
- package/dist/safety/runtime/polyfills.d.ts +6 -0
- package/dist/safety/runtime/polyfills.js +12 -0
- package/dist/safety/runtime/result-struct.d.ts +11 -0
- package/dist/safety/runtime/result-struct.js +98 -0
- package/dist/safety/runtime/safe-int.d.ts +33 -0
- package/dist/safety/runtime/safe-int.js +170 -0
- package/dist/safety/runtime/safe-traits.d.ts +4 -0
- package/dist/safety/runtime/safe-traits.js +95 -0
- package/dist/safety/runtime/safe-variable.d.ts +39 -0
- package/dist/safety/runtime/safe-variable.js +226 -0
- package/dist/safety/runtime/vote.d.ts +8 -0
- package/dist/safety/runtime/vote.js +92 -0
- package/dist/safety/runtime/write-verify.d.ts +8 -0
- package/dist/safety/runtime/write-verify.js +71 -0
- package/dist/safety/safe-int-types.d.ts +45 -0
- package/dist/safety/safe-int-types.js +25 -0
- package/dist/safety/safe-variable-types.d.ts +29 -0
- package/dist/safety/safe-variable-types.js +19 -0
- package/dist/safety/safety-bridge.d.ts +5 -6
- package/dist/safety/safety-bridge.js +15 -28
- package/dist/safety/sidecar-bridge.d.ts +1 -3
- package/dist/safety/sidecar-bridge.js +3 -20
- package/dist/safety/specifiers.d.ts +6 -0
- package/dist/safety/specifiers.js +14 -0
- package/dist/safety-hook.d.ts +8 -7
- package/dist/safety-hook.js +12 -13
- package/dist/testing.d.ts +5 -6
- package/dist/testing.js +5 -5
- package/dist/transpile/resolution.d.ts +1 -1
- package/dist/transpile/resolution.js +18 -9
- package/dist/transpile/test-pins.d.ts +18 -0
- package/dist/transpile/test-pins.js +142 -0
- package/dist/transpile.d.ts +1 -2
- package/dist/transpile.js +90 -29
- package/dist/types.d.ts +45 -26
- package/dist/ui-hook.d.ts +1 -1
- package/dist/utils/cli.d.ts +2 -2
- package/dist/utils/cli.js +160 -157
- package/dist/utils/fs.d.ts +3 -4
- package/dist/utils/fs.js +4 -5
- package/dist/utils/strings.d.ts +0 -1
- package/dist/utils/strings.js +0 -8
- package/dist/utils/ui.d.ts +5 -2
- package/dist/utils/ui.js +13 -3
- package/package.json +158 -149
- package/dist/add-preset.d.ts +0 -4
- package/dist/add-preset.js +0 -74
- package/dist/api/shared/async-symbol-detector.d.ts +0 -11
- package/dist/api/shared/async-symbol-detector.js +0 -140
- package/dist/api/shared/native-display-op-resolver.d.ts +0 -10
- package/dist/api/shared/native-display-op-resolver.js +0 -64
- package/dist/create/board-checklist.d.ts +0 -2
- package/dist/create/board-checklist.js +0 -52
- package/dist/create/board-codegen.d.ts +0 -9
- package/dist/create/board-codegen.js +0 -238
- package/dist/create/board-generators.d.ts +0 -12
- package/dist/create/board-generators.js +0 -651
- package/dist/create/board-spec.d.ts +0 -637
- package/dist/create/board-spec.js +0 -214
- package/dist/create/init-templates.d.ts +0 -28
- package/dist/create/init-wizard.d.ts +0 -8
- package/dist/create/init-wizard.js +0 -182
- package/dist/install/framework-catalog.d.ts +0 -53
- package/dist/install/framework-catalog.js +0 -107
- package/dist/install/handle-install.d.ts +0 -35
- package/dist/install/handle-install.js +0 -177
- package/dist/install/index.d.ts +0 -4
- package/dist/install/index.js +0 -3
- package/dist/ir/pin-state-tracking.d.ts +0 -58
- package/dist/ir/pin-state-tracking.js +0 -182
- package/dist/ir/pwm-timer-sharing.d.ts +0 -4
- package/dist/ir/pwm-timer-sharing.js +0 -94
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +0 -4
- package/dist/ir/timer0-pwm-timing-conflict.js +0 -72
- package/dist/libdef/component-decls.d.ts +0 -2
- package/dist/libdef/component-decls.js +0 -6
- package/dist/libdef/component-discovery.d.ts +0 -43
- package/dist/libdef/component-discovery.js +0 -83
- package/dist/theme-tokens.d.ts +0 -22
- package/dist/theme-tokens.js +0 -172
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ResolvedCuttlefishConfig } from '../config-loader.js';
|
|
2
2
|
export type { HwContract, ContractPin, ContractComponent, AvailablePeripherals, } from './contract-parser.js';
|
|
3
|
-
export { parseContractFile, matchConnectedPins, selectPeripherals } from './contract-parser.js';
|
|
3
|
+
export { parseContractFile, matchConnectedPins, selectPeripherals, contractPinNames, contractPads } from './contract-parser.js';
|
|
4
4
|
export { generateBoardFile, CUTTLEFISH_DIR } from './board-generator.js';
|
|
5
5
|
export type { GenerateBoardOptions } from './board-generator.js';
|
|
6
6
|
/**
|
package/dist/contract/index.js
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
// module is what writes that file.
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import { locateZephyrBaseCheap } from '../board-catalog/index.js';
|
|
13
|
+
import { parseContractFile, contractPinNames, contractPads } from './contract-parser.js';
|
|
11
14
|
import { generateBoardFile } from './board-generator.js';
|
|
12
|
-
export { parseContractFile, matchConnectedPins, selectPeripherals } from './contract-parser.js';
|
|
15
|
+
export { parseContractFile, matchConnectedPins, selectPeripherals, contractPinNames, contractPads } from './contract-parser.js';
|
|
13
16
|
export { generateBoardFile, CUTTLEFISH_DIR } from './board-generator.js';
|
|
14
17
|
/**
|
|
15
18
|
* Orchestrates contract-based board generation for a resolved config:
|
|
@@ -31,9 +34,9 @@ export async function generateContractBoard(config) {
|
|
|
31
34
|
if (!config.contract) {
|
|
32
35
|
throw new Error('generateContractBoard called without config.contract');
|
|
33
36
|
}
|
|
34
|
-
if (!config.
|
|
35
|
-
throw new Error(`A 'contract' config requires
|
|
36
|
-
`Add e.g.
|
|
37
|
+
if (!config.soc && !config.buildTarget) {
|
|
38
|
+
throw new Error(`A 'contract' config requires a 'soc' (Zephyr SoC name) to narrow against. ` +
|
|
39
|
+
`Add e.g. soc: 'stm32f411xe' to cuttlefish.config.ts.`);
|
|
37
40
|
}
|
|
38
41
|
const projectDir = path.dirname(config.configPath);
|
|
39
42
|
const contractPath = path.isAbsolute(config.contract)
|
|
@@ -41,27 +44,73 @@ export async function generateContractBoard(config) {
|
|
|
41
44
|
: path.resolve(projectDir, config.contract);
|
|
42
45
|
// (1) Parse the contract.
|
|
43
46
|
const contract = parseContractFile(contractPath);
|
|
44
|
-
// (2)
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
+
// (2) SDK-as-truth: the SoC's bus controller labels come from the
|
|
48
|
+
// INSTALLED Zephyr tree's soc dtsi (located via the same fs-only
|
|
49
|
+
// discovery the catalog uses), and the wired pads come from the contract
|
|
50
|
+
// itself. The framework runs them through the same board-module builder
|
|
51
|
+
// every catalog board uses.
|
|
52
|
+
const soc = config.soc ?? path.basename(config.buildTarget ?? '').split('/')[0];
|
|
53
|
+
if (!soc) {
|
|
54
|
+
throw new Error("Contract-based projects need a `soc:` (Zephyr SoC name, e.g. 'stm32f411xe') " +
|
|
55
|
+
"in cuttlefish.config.ts to select the silicon the contract narrows.");
|
|
56
|
+
}
|
|
57
|
+
if (!config.framework) {
|
|
58
|
+
throw new Error("Contract-based projects need a `framework:` package to generate the board data.");
|
|
59
|
+
}
|
|
60
|
+
// ESM-safe: the framework packages are "type": "module" — resolve through
|
|
61
|
+
// createRequire anchored at the project's package.json.
|
|
62
|
+
let strategy;
|
|
47
63
|
try {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
64
|
+
const projectRequire = createRequire(path.join(projectDir, 'package.json'));
|
|
65
|
+
const mod = projectRequire(projectRequire.resolve(config.framework));
|
|
66
|
+
const Ctor = mod.ZephyrStrategy ?? mod.default;
|
|
67
|
+
strategy = typeof Ctor === 'function' ? new Ctor() : undefined;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
strategy = undefined;
|
|
53
71
|
}
|
|
54
|
-
|
|
55
|
-
throw new Error(`
|
|
56
|
-
`
|
|
72
|
+
if (!strategy?.generateContractBoardModule) {
|
|
73
|
+
throw new Error(`Framework '${config.framework}' provides no contract board generation. ` +
|
|
74
|
+
`Zephyr contract projects require '@typecad/framework-zephyr' (which derives the ` +
|
|
75
|
+
`soc's bus controllers from the installed Zephyr tree).`);
|
|
57
76
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
const zephyrBase = locateZephyrBaseCheap();
|
|
78
|
+
if (!zephyrBase) {
|
|
79
|
+
throw new Error(`No Zephyr tree found for the contract build. The SoC's bus controllers are derived ` +
|
|
80
|
+
`from the installed Zephyr tree — install one via '@typecad/framework-zephyr' ` +
|
|
81
|
+
`(zephyr-installer) or set ZEPHYR_BASE.`);
|
|
82
|
+
}
|
|
83
|
+
const generated = strategy.generateContractBoardModule({
|
|
84
|
+
soc,
|
|
85
|
+
zephyrBase,
|
|
86
|
+
// The contract's own canonical pad names (boardName when typecad.net
|
|
87
|
+
// carried a mapping, else the KiCAD pin-name segment that matches the
|
|
88
|
+
// soc's datasheet form).
|
|
89
|
+
pinNames: contractPads(contract).map((p) => p.mcuName),
|
|
90
|
+
padAliases: contractPads(contract)
|
|
91
|
+
.filter((p) => p.alias)
|
|
92
|
+
.map((p) => ({ exportName: p.alias, padName: p.mcuName })),
|
|
93
|
+
peripherals: contract.availablePeripherals,
|
|
94
|
+
});
|
|
95
|
+
// (3) The narrowed pad set: the contract's own canonical names — the
|
|
96
|
+
// board module the framework generated exposes the soc's datasheet sweep
|
|
97
|
+
// for the wired controllers; board.ts narrows the user surface to the
|
|
98
|
+
// pads the PCB actually wired (an unwired pin is a compile error).
|
|
99
|
+
const connectedPins = contractPinNames(contract);
|
|
100
|
+
const peripherals = [
|
|
101
|
+
contract.availablePeripherals.i2c ? 'I2C0' : '',
|
|
102
|
+
contract.availablePeripherals.spi ? 'SPI0' : '',
|
|
103
|
+
contract.availablePeripherals.uart ? 'UART0' : '',
|
|
104
|
+
].filter(Boolean);
|
|
105
|
+
// (4) Emit the soc's full board.json — the transpiler's pin map and chip
|
|
106
|
+
// resolution read it (same artifact a board-target project carries).
|
|
107
|
+
const cuttlefishDir = path.join(projectDir, '.cuttlefish');
|
|
108
|
+
fs.mkdirSync(cuttlefishDir, { recursive: true });
|
|
109
|
+
fs.writeFileSync(path.join(cuttlefishDir, 'board.json'), generated.boardJson, 'utf-8');
|
|
110
|
+
// (5) Emit the narrowed board.
|
|
62
111
|
return generateBoardFile({
|
|
63
112
|
projectDir,
|
|
64
|
-
|
|
113
|
+
soc,
|
|
65
114
|
connectedPins,
|
|
66
115
|
peripherals,
|
|
67
116
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BoardDataEntry } from './board-catalog.generated.js';
|
|
2
|
+
/**
|
|
3
|
+
* The active board catalog: the local overlay when one is discoverable
|
|
4
|
+
* (env var, $ZEPHYR_BASE, well-known workspace layouts, installer env),
|
|
5
|
+
* else the compiled-in generated pack. Memoized per process.
|
|
6
|
+
*/
|
|
7
|
+
export declare function activeBoardCatalog(): Record<string, BoardDataEntry>;
|
|
8
|
+
/** Test hook — drop the memo so env/discovery changes take effect. */
|
|
9
|
+
export declare function resetActiveBoardCatalog(): void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// active-board-catalog.ts — the board catalog the create flow resolves
|
|
3
|
+
// against: the local overlay when one exists, else the compiled-in pack.
|
|
4
|
+
//
|
|
5
|
+
// `cuttlefish create` runs BEFORE the framework package is installed, so it
|
|
6
|
+
// cannot ask the framework for its catalog. It reads the same overlay file
|
|
7
|
+
// `cuttlefish board sync` writes — <workspace>/.cuttlefish/board-catalog.json
|
|
8
|
+
// beside the Zephyr checkout — with fs-only discovery (no spawns; the wizard
|
|
9
|
+
// stays snappy). The schema/path contract lives in framework-zephyr's
|
|
10
|
+
// src/sdk/board-catalog-sync.ts; keep this reader in sync with it.
|
|
11
|
+
//
|
|
12
|
+
// The overlay REPLACES the compiled-in pack (not a merge): it describes the
|
|
13
|
+
// exact tree west builds against, including boards the shipped pack no
|
|
14
|
+
// longer carries.
|
|
15
|
+
// ----------------------------------------------------------------------------
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { homedir } from 'node:os';
|
|
19
|
+
import { BOARD_DATA } from './board-catalog.generated.js';
|
|
20
|
+
/** Explicit overlay file ('' / 'off' disables) — same var as the framework's loader. */
|
|
21
|
+
const OVERLAY_ENV = 'CUTTLEFISH_BOARD_CATALOG';
|
|
22
|
+
const OVERLAY_SCHEMA = 1;
|
|
23
|
+
/** True when dir looks like a Zephyr checkout (mirrors west-discover's check). */
|
|
24
|
+
function isZephyrBase(dir) {
|
|
25
|
+
return (fs.existsSync(path.join(dir, 'CMakeLists.txt')) &&
|
|
26
|
+
fs.existsSync(path.join(dir, 'include', 'zephyr', 'kernel.h')));
|
|
27
|
+
}
|
|
28
|
+
/** Installer-written ZEPHYR_BASE from the micromamba env-vars file (fs-only). */
|
|
29
|
+
function micromambaZephyrBase() {
|
|
30
|
+
const root = process.env.MAMBA_ROOT_PREFIX || path.join(homedir(), 'micromamba');
|
|
31
|
+
const envDir = path.join(root, 'envs', process.env.TYPECAD_ZEPHYR_ENV || 'zephyr');
|
|
32
|
+
const candidates = process.platform === 'win32'
|
|
33
|
+
? [path.join(envDir, 'etc', 'conda', 'env-vars.ps1'), path.join(envDir, 'etc', 'conda', 'env-vars.bat')]
|
|
34
|
+
: [path.join(envDir, 'etc', 'conda', 'env-vars.sh')];
|
|
35
|
+
for (const f of candidates) {
|
|
36
|
+
if (!fs.existsSync(f))
|
|
37
|
+
continue;
|
|
38
|
+
try {
|
|
39
|
+
const m = fs.readFileSync(f, 'utf8').match(/TYPECAD_ZEPHYR_BASE\s*=\s*"([^"]+)"/);
|
|
40
|
+
if (m && isZephyrBase(m[1]))
|
|
41
|
+
return m[1];
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// unreadable — try the next candidate
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
let cached;
|
|
50
|
+
/**
|
|
51
|
+
* The active board catalog: the local overlay when one is discoverable
|
|
52
|
+
* (env var, $ZEPHYR_BASE, well-known workspace layouts, installer env),
|
|
53
|
+
* else the compiled-in generated pack. Memoized per process.
|
|
54
|
+
*/
|
|
55
|
+
export function activeBoardCatalog() {
|
|
56
|
+
if (cached)
|
|
57
|
+
return cached;
|
|
58
|
+
cached = { ...BOARD_DATA };
|
|
59
|
+
const read = (file) => {
|
|
60
|
+
try {
|
|
61
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
62
|
+
if (parsed.schema === OVERLAY_SCHEMA && parsed.boards)
|
|
63
|
+
cached = parsed.boards;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// unreadable/malformed overlay — keep the compiled-in pack
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const explicit = process.env[OVERLAY_ENV];
|
|
70
|
+
if (explicit !== undefined) {
|
|
71
|
+
if (explicit !== '' && explicit.toLowerCase() !== 'off')
|
|
72
|
+
read(explicit);
|
|
73
|
+
return cached;
|
|
74
|
+
}
|
|
75
|
+
const home = homedir();
|
|
76
|
+
const trees = [
|
|
77
|
+
process.env.ZEPHYR_BASE,
|
|
78
|
+
path.join(home, 'zephyrproject', 'zephyr'),
|
|
79
|
+
path.join(home, 'zephyr', 'zephyr'),
|
|
80
|
+
...(process.platform === 'win32' ? ['C:\\zephyrproject\\zephyr', 'C:\\zephyr\\zephyr'] : ['/opt/zephyrproject/zephyr', '/opt/zephyr/zephyr']),
|
|
81
|
+
micromambaZephyrBase(),
|
|
82
|
+
];
|
|
83
|
+
for (const t of trees) {
|
|
84
|
+
if (t && isZephyrBase(t)) {
|
|
85
|
+
read(path.join(path.dirname(path.resolve(t)), '.cuttlefish', 'board-catalog.json'));
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return cached;
|
|
90
|
+
}
|
|
91
|
+
/** Test hook — drop the memo so env/discovery changes take effect. */
|
|
92
|
+
export function resetActiveBoardCatalog() {
|
|
93
|
+
cached = undefined;
|
|
94
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface BoardDataEntry {
|
|
2
|
+
/** Qualified west build target (the variant yaml identifier). */
|
|
3
|
+
readonly identifier: string;
|
|
4
|
+
/** Human board name. */
|
|
5
|
+
readonly name: string;
|
|
6
|
+
/** Vendor directory name. */
|
|
7
|
+
readonly vendor: string;
|
|
8
|
+
/** The variant DTS file this was extracted from. */
|
|
9
|
+
readonly dts: string;
|
|
10
|
+
/** Console controller nodelabel (the chosen zephyr,console). */
|
|
11
|
+
readonly console?: string;
|
|
12
|
+
/** Addressable user LED (worldsemi,ws2812-*): the pad driving the pixel.
|
|
13
|
+
* A plain-GPIO LED — no led0 devicetree spec (the pixel is not a
|
|
14
|
+
* gpio-leds node). Present only when the board has no gpio-leds LED. */
|
|
15
|
+
readonly stripLed?: {
|
|
16
|
+
readonly controller: string;
|
|
17
|
+
readonly pin: number;
|
|
18
|
+
};
|
|
19
|
+
/** PWM-driven LEDs (pwm-leds children) in board order. The alias is the
|
|
20
|
+
* devicetree alias ('pwm-led0') — the DT_ALIAS-addressable form the PWM
|
|
21
|
+
* lowering needs; non-aliased channels are carried for reference. */
|
|
22
|
+
readonly pwmLeds?: readonly {
|
|
23
|
+
readonly alias?: string;
|
|
24
|
+
readonly controller: string;
|
|
25
|
+
readonly channel: number;
|
|
26
|
+
readonly periodNs?: number;
|
|
27
|
+
readonly flags?: readonly string[];
|
|
28
|
+
}[];
|
|
29
|
+
/** The board's USB device wiring: 'enabled' (DTS turns the device
|
|
30
|
+
* controller on), 'disabled' (explicitly off — suppress the USB0
|
|
31
|
+
* export), undefined (silent; the app overlay may still compose CDC). */
|
|
32
|
+
readonly usbDevice?: 'enabled' | 'disabled';
|
|
33
|
+
/** The USB device controller nodelabel backing usbDevice. */
|
|
34
|
+
readonly usbController?: string;
|
|
35
|
+
/** Watchdog node label (the devicetree watchdog0 alias). */
|
|
36
|
+
readonly wdtNodeLabel?: string;
|
|
37
|
+
/** Bus controller nodelabels the board DTS wires up (&i2c0/&spi2/&usart1
|
|
38
|
+
* overrides). Board-level facts only — a bus enabled solely in the SoC
|
|
39
|
+
* dtsi is invisible here. */
|
|
40
|
+
readonly buses?: {
|
|
41
|
+
readonly i2c: readonly string[];
|
|
42
|
+
readonly spi: readonly string[];
|
|
43
|
+
readonly uart: readonly string[];
|
|
44
|
+
};
|
|
45
|
+
/** Probe/flash methods from the board's board.cmake (west runners, in the
|
|
46
|
+
* board's include order — first = west's default runner). */
|
|
47
|
+
readonly probeMethods?: readonly {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly description: string;
|
|
50
|
+
readonly runner: string;
|
|
51
|
+
readonly args?: readonly string[];
|
|
52
|
+
readonly debug?: boolean;
|
|
53
|
+
readonly debugInterface?: 'swd' | 'jtag';
|
|
54
|
+
readonly debugDevice?: string;
|
|
55
|
+
/** The board's support/openocd.cfg, verbatim lines in file order. */
|
|
56
|
+
readonly debugCfg?: readonly string[];
|
|
57
|
+
}[];
|
|
58
|
+
/** The canonical aliased LED (led0). */
|
|
59
|
+
readonly led?: {
|
|
60
|
+
readonly dtSpec: string;
|
|
61
|
+
readonly controller: string;
|
|
62
|
+
readonly pin: number;
|
|
63
|
+
readonly flags: readonly string[];
|
|
64
|
+
};
|
|
65
|
+
/** The canonical aliased button (sw0). */
|
|
66
|
+
readonly button?: {
|
|
67
|
+
readonly dtSpec: string;
|
|
68
|
+
readonly controller: string;
|
|
69
|
+
readonly pin: number;
|
|
70
|
+
readonly flags: readonly string[];
|
|
71
|
+
};
|
|
72
|
+
/** Additional aliased LEDs/buttons beyond the canonical ones. */
|
|
73
|
+
readonly extraLeds?: readonly {
|
|
74
|
+
readonly dtSpec: string;
|
|
75
|
+
readonly controller: string;
|
|
76
|
+
readonly pin: number;
|
|
77
|
+
readonly flags: readonly string[];
|
|
78
|
+
}[];
|
|
79
|
+
readonly extraButtons?: readonly {
|
|
80
|
+
readonly dtSpec: string;
|
|
81
|
+
readonly controller: string;
|
|
82
|
+
readonly pin: number;
|
|
83
|
+
readonly flags: readonly string[];
|
|
84
|
+
}[];
|
|
85
|
+
/** Connector gpio-maps (arduino headers, XIAO edge connector, ...). */
|
|
86
|
+
readonly connectors?: readonly {
|
|
87
|
+
readonly nodelabel: string;
|
|
88
|
+
readonly compatible?: string;
|
|
89
|
+
readonly pins: Readonly<Record<string, {
|
|
90
|
+
readonly controller: string;
|
|
91
|
+
readonly pin: number;
|
|
92
|
+
readonly flags: readonly string[];
|
|
93
|
+
}>>;
|
|
94
|
+
}[];
|
|
95
|
+
}
|
|
96
|
+
export declare const BOARD_DATA: Readonly<Record<string, BoardDataEntry>>;
|