@typecad/framework-zephyr 1.0.0-alpha.15 → 1.0.0-alpha.18
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/LICENSE +202 -21
- package/README.md +49 -87
- package/dist/as-built.d.ts +2 -2
- package/dist/as-built.js +2 -2
- package/dist/boardgen.d.ts +1 -9
- package/dist/boardgen.js +228 -45
- package/dist/chips/types.d.ts +1 -1
- package/dist/debug-codegen.js +1 -1
- package/dist/display/touch-adapter.js +1 -1
- package/dist/display/ui-adapter.js +549 -549
- package/dist/doctor.js +4 -4
- package/dist/dt-config/custom-board.js +2 -2
- package/dist/dt-config/kconfig.js +18 -12
- package/dist/dt-config/overlay.d.ts +2 -2
- package/dist/dt-config/overlay.js +2 -2
- package/dist/framework.manifest.d.ts +3 -3
- package/dist/framework.manifest.js +10 -7
- package/dist/index.js +5 -5
- package/dist/licenses.d.ts +2 -2
- package/dist/licenses.js +8 -8
- package/dist/lowering/fs.js +1 -1
- package/dist/lowering/gpio.js +0 -32
- package/dist/lowering/http.js +264 -32
- package/dist/lowering/i2c.js +0 -8
- package/dist/lowering/interrupts.js +6 -0
- package/dist/lowering/mqtt.js +110 -8
- package/dist/lowering/usb.js +11 -11
- package/dist/lowering/wdt.js +2 -29
- package/dist/sdk/board-catalog-sync.d.ts +1 -3
- package/dist/sdk/board-catalog-sync.js +4 -10
- package/dist/strategy.d.ts +22 -44
- package/dist/strategy.js +152 -155
- package/dist/tmp-probe.d.ts +2 -0
- package/dist/tmp-probe.js +9 -0
- package/dist/toolchain/debug-config.d.ts +50 -90
- package/dist/toolchain/debug-config.js +241 -502
- package/dist/toolchain/env-check.d.ts +1 -3
- package/dist/toolchain/env-check.js +2 -7
- package/dist/toolchain/index.d.ts +65 -2
- package/dist/toolchain/index.js +432 -55
- package/dist/toolchain/runners.d.ts +16 -0
- package/dist/toolchain/runners.js +75 -0
- package/dist/toolchain/scaffold.d.ts +1 -1
- package/dist/toolchain/scaffold.js +12 -12
- package/dist/toolchain/west-discover.d.ts +6 -0
- package/dist/toolchain/west-discover.js +36 -13
- package/dist/toolchain/west-spawn.js +8 -2
- package/installer/README.md +328 -328
- package/installer/install.sh +2 -2
- package/installer/templates/project/.typecad/activate-zephyr.ps1 +1 -1
- package/installer/templates/project/.typecad/activate-zephyr.sh +1 -1
- package/installer/templates/project/.vscode/settings.json +1 -1
- package/installer/templates/project/README.md +2 -2
- package/package.json +5 -5
- package/src/as-built.ts +206 -206
- package/src/boardgen.ts +214 -48
- package/src/chips/types.ts +567 -567
- package/src/display/touch-adapter.ts +204 -204
- package/src/display/ui-adapter.ts +781 -781
- package/src/doctor.ts +4 -4
- package/src/dt-config/custom-board.ts +2 -2
- package/src/dt-config/kconfig.ts +18 -12
- package/src/dt-config/overlay.ts +1058 -1058
- package/src/framework.manifest.ts +538 -535
- package/src/index.ts +5 -5
- package/src/licenses.ts +425 -425
- package/src/lowering/fs.ts +135 -135
- package/src/lowering/gpio.ts +0 -33
- package/src/lowering/http.ts +264 -32
- package/src/lowering/i2c.ts +0 -9
- package/src/lowering/interrupts.ts +6 -0
- package/src/lowering/mqtt.ts +109 -8
- package/src/lowering/usb.ts +221 -221
- package/src/lowering/wdt.ts +2 -25
- package/src/sdk/board-catalog-sync.ts +4 -25
- package/src/strategy.ts +2265 -2309
- package/src/toolchain/debug-config.ts +264 -514
- package/src/toolchain/env-check.ts +279 -285
- package/src/toolchain/index.ts +1703 -1286
- package/src/toolchain/runners.ts +80 -0
- package/src/toolchain/scaffold.ts +296 -296
- package/src/toolchain/west-discover.ts +35 -13
- package/src/toolchain/west-spawn.ts +174 -168
- package/dist/async/timer-polyfill.d.ts +0 -10
- package/dist/async/timer-polyfill.js +0 -95
- package/dist/chips/board-overrides.d.ts +0 -7
- package/dist/chips/board-overrides.js +0 -11
- package/dist/chips/esp32.d.ts +0 -2
- package/dist/chips/esp32.js +0 -71
- package/dist/chips/esp32s3.d.ts +0 -2
- package/dist/chips/esp32s3.js +0 -103
- package/dist/chips/soc/.d.ts +0 -2
- package/dist/chips/soc/.js +0 -129
- package/dist/chips/soc/esp32.d.ts +0 -2
- package/dist/chips/soc/esp32.js +0 -120
- package/dist/chips/soc/esp32c3.d.ts +0 -2
- package/dist/chips/soc/esp32c3.js +0 -90
- package/dist/chips/soc/esp32c6.d.ts +0 -2
- package/dist/chips/soc/esp32c6.js +0 -109
- package/dist/chips/soc/esp32s3.d.ts +0 -2
- package/dist/chips/soc/esp32s3.js +0 -189
- package/dist/chips/soc/index.d.ts +0 -2
- package/dist/chips/soc/index.js +0 -23
- package/dist/chips/soc/nrf52840.d.ts +0 -2
- package/dist/chips/soc/nrf52840.js +0 -130
- package/dist/chips/soc/rp2040.d.ts +0 -2
- package/dist/chips/soc/rp2040.js +0 -141
- package/dist/chips/soc/rp2350a.d.ts +0 -2
- package/dist/chips/soc/rp2350a.js +0 -145
- package/dist/chips/soc/samd21g18a.d.ts +0 -2
- package/dist/chips/soc/samd21g18a.js +0 -143
- package/dist/chips/soc/stm32f411xe.d.ts +0 -2
- package/dist/chips/soc/stm32f411xe.js +0 -251
- package/dist/chips/xiao-ble.d.ts +0 -2
- package/dist/chips/xiao-ble.js +0 -100
- package/dist/lowering/power.d.ts +0 -9
- package/dist/lowering/power.js +0 -60
- package/dist/lowering/pulse.d.ts +0 -7
- package/dist/lowering/pulse.js +0 -51
- package/dist/lowering/tone.d.ts +0 -10
- package/dist/lowering/tone.js +0 -63
- package/dist/lowering/worker-backing.d.ts +0 -14
- package/dist/lowering/worker-backing.js +0 -79
- package/dist/lowering/worker.d.ts +0 -6
- package/dist/lowering/worker.js +0 -14
- package/dist/sdk/board-data.generated.d.ts +0 -2
- package/dist/sdk/board-data.generated.js +0 -4
- package/dist/sdk/catalog-walker.d.ts +0 -90
- package/dist/sdk/catalog-walker.js +0 -682
- package/dist/sdk/dts-reader.d.ts +0 -83
- package/dist/sdk/dts-reader.js +0 -596
- package/src/debug-codegen.ts +0 -207
package/src/debug-codegen.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// Zephyr debug code generator — printk-based debug output
|
|
3
|
-
//
|
|
4
|
-
// The Zephyr counterpart to framework-esp32/src/debug-codegen.ts. Zephyr's
|
|
5
|
-
// minimal C++ config has no <iostream> (manifest: needsIostream=false,
|
|
6
|
-
// stdlibSupport.hasIostream=false), so the GenericStrategy's std::cout fallback
|
|
7
|
-
// used by the debug preprocessor would NOT compile. This module routes every
|
|
8
|
-
// debug line through printk("...\n") — the always-available Zephyr console,
|
|
9
|
-
// with no CONFIG_CONSOLE dependency — so `cuttlefish build --debug` produces
|
|
10
|
-
// compiling output.
|
|
11
|
-
//
|
|
12
|
-
// The halt primitive is __tc_debug_wait_for_continue() (emitted in
|
|
13
|
-
// ZephyrStrategy.shimLines when --debug is active): a k_console-input / busy
|
|
14
|
-
// poll that yields to the scheduler so an unattended breakpoint does not trip
|
|
15
|
-
// any watchdog. ENTER continues; 's' disables this breakpoint for the run.
|
|
16
|
-
//
|
|
17
|
-
// Used by ZephyrStrategy's generateDebug* overrides, dispatched by the
|
|
18
|
-
// cuttlefish debug preprocessor (cuttlefish/src/debug/preprocessor.ts).
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
export interface CapturedVariable {
|
|
22
|
-
name: string;
|
|
23
|
-
isFunction?: boolean;
|
|
24
|
-
/** Coarse C++ type category (inferred by the preprocessor without a checker). */
|
|
25
|
-
cppType?: 'bool' | 'int' | 'long' | 'float' | 'string' | 'unknown';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface LogMessagePart {
|
|
29
|
-
type: 'text' | 'variable';
|
|
30
|
-
value: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Generate the debug-mode banner. printk is always wired (Zephyr console), so
|
|
35
|
-
* there is no init to perform — just confirm debug instrumentation is live.
|
|
36
|
-
*/
|
|
37
|
-
export function generateZephyrInitCode(): string[] {
|
|
38
|
-
return [
|
|
39
|
-
`// === DEBUG: Zephyr console (printk) ===`,
|
|
40
|
-
`printk("[TypeCAD] Debug Mode Active\\n");`,
|
|
41
|
-
`// === END DEBUG INIT ===`,
|
|
42
|
-
``,
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Generate Zephyr code for a breakpoint.
|
|
48
|
-
*
|
|
49
|
-
* The halt is __tc_debug_wait_for_continue() (emitted in ZephyrStrategy.shimLines
|
|
50
|
-
* under --debug): blocks until a byte arrives on the console, yielding to the
|
|
51
|
-
* scheduler between polls. The user must have a console attached (`west serial`
|
|
52
|
-
* or a terminal on the USB-CDC port); ENTER continues, 's' skips this breakpoint
|
|
53
|
-
* for the rest of the run.
|
|
54
|
-
*
|
|
55
|
-
* When `breakpointId` is set, the whole halt block is wrapped in
|
|
56
|
-
* `if (!__tc_bp_disabled_<id>)`, so a skipped breakpoint becomes a no-op until
|
|
57
|
-
* reboot. The flag is `static` so it persists across loop() iterations.
|
|
58
|
-
*/
|
|
59
|
-
export function generateZephyrBreakpointCode(
|
|
60
|
-
fileName: string,
|
|
61
|
-
lineNum: number,
|
|
62
|
-
originalLine: string,
|
|
63
|
-
variables: CapturedVariable[],
|
|
64
|
-
normalizedCondition: string | undefined,
|
|
65
|
-
breakpointId?: number,
|
|
66
|
-
): string[] {
|
|
67
|
-
const lines: string[] = [];
|
|
68
|
-
const hasDisableGuard = breakpointId !== undefined;
|
|
69
|
-
// Each wrap level adds two spaces of indent: the disable guard (outermost)
|
|
70
|
-
// then the condition (if any).
|
|
71
|
-
const indent = ' ' + (hasDisableGuard ? ' ' : '') + (normalizedCondition ? ' ' : '');
|
|
72
|
-
|
|
73
|
-
lines.push(` // === BREAKPOINT: ${fileName}:${lineNum} ===`);
|
|
74
|
-
|
|
75
|
-
// Disable guard: a skipped breakpoint becomes a no-op until reboot. The
|
|
76
|
-
// disable state lives in the framework's debug shim (a static registry keyed
|
|
77
|
-
// by breakpointId) — NOT as a per-breakpoint declaration here, because the
|
|
78
|
-
// transpiler mangles `static bool` declarations injected into the source.
|
|
79
|
-
if (hasDisableGuard) {
|
|
80
|
-
lines.push(` if (!__tc_bp_is_disabled(${breakpointId})) {`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (normalizedCondition) {
|
|
84
|
-
lines.push(` ${hasDisableGuard ? ' ' : ''}if (${normalizedCondition}) {`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
lines.push(`${indent}printk("----------------------------------------\\n");`);
|
|
88
|
-
|
|
89
|
-
const headerText = normalizedCondition
|
|
90
|
-
? `[BREAK] ${fileName}:${lineNum} (condition: ${escapeString(normalizedCondition)})`
|
|
91
|
-
: `[BREAK] ${fileName}:${lineNum}`;
|
|
92
|
-
lines.push(`${indent}printk("%s\\n", "${headerText}");`);
|
|
93
|
-
|
|
94
|
-
lines.push(`${indent}printk(" %s\\n", "${escapeString(originalLine)}");`);
|
|
95
|
-
|
|
96
|
-
if (variables.length > 0) {
|
|
97
|
-
lines.push(`${indent}printk(" Variables:\\n");`);
|
|
98
|
-
for (const v of variables) {
|
|
99
|
-
if (v.isFunction) {
|
|
100
|
-
lines.push(`${indent}printk(" - %s = [function]\\n", "${v.name}");`);
|
|
101
|
-
} else {
|
|
102
|
-
const { spec, arg } = formatSpecFor(v.name, v.cppType);
|
|
103
|
-
lines.push(`${indent}printk(" - %s = ${spec}\\n", "${v.name}", ${arg});`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
lines.push(`${indent}printk(" (no variables in scope)\\n");`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
lines.push(`${indent}printk(" [ENTER: continue | s: skip this breakpoint]\\n");`);
|
|
111
|
-
lines.push(`${indent}printk("----------------------------------------\\n");`);
|
|
112
|
-
|
|
113
|
-
// Halt — block on console input, scheduler-yielding. 's' records this id as
|
|
114
|
-
// disabled in the shim's registry. Pass -1 when no id (never disable).
|
|
115
|
-
lines.push(`${indent}__tc_debug_wait_for_continue(${hasDisableGuard ? breakpointId : -1});`);
|
|
116
|
-
|
|
117
|
-
if (normalizedCondition) {
|
|
118
|
-
lines.push(` ${hasDisableGuard ? ' ' : ''}}`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (hasDisableGuard) {
|
|
122
|
-
lines.push(` }`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
lines.push(` // === END BREAKPOINT ===`);
|
|
126
|
-
|
|
127
|
-
return lines;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Generate Zephyr code for a logpoint (logs a message without halting).
|
|
132
|
-
*/
|
|
133
|
-
export function generateZephyrLogpointCode(
|
|
134
|
-
fileName: string,
|
|
135
|
-
lineNum: number,
|
|
136
|
-
parts: LogMessagePart[],
|
|
137
|
-
variables: CapturedVariable[],
|
|
138
|
-
): string[] {
|
|
139
|
-
const lines: string[] = [];
|
|
140
|
-
|
|
141
|
-
lines.push(` // === LOGPOINT: ${fileName}:${lineNum} ===`);
|
|
142
|
-
lines.push(` printk("[LOG ${fileName}:${lineNum}] ");`);
|
|
143
|
-
|
|
144
|
-
for (const part of parts) {
|
|
145
|
-
if (part.type === 'text') {
|
|
146
|
-
lines.push(` printk("${escapeString(part.value)}");`);
|
|
147
|
-
} else {
|
|
148
|
-
// variable part: only printable if it is a non-function value in scope.
|
|
149
|
-
const match = variables.find((v) => v.name === part.value && !v.isFunction);
|
|
150
|
-
if (match) {
|
|
151
|
-
const { spec, arg } = formatSpecFor(match.name, match.cppType);
|
|
152
|
-
lines.push(` printk("${spec}", ${arg});`);
|
|
153
|
-
} else {
|
|
154
|
-
lines.push(` printk("{${escapeString(part.value)}}"); // variable not in scope`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
lines.push(` printk("\\n");`);
|
|
160
|
-
lines.push(` // === END LOGPOINT ===`);
|
|
161
|
-
|
|
162
|
-
return lines;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Escape a string for use inside printk("..."). Same rules as the ESP-IDF
|
|
167
|
-
* generator: backslash, double-quote, newline, carriage return.
|
|
168
|
-
*/
|
|
169
|
-
function escapeString(s: string): string {
|
|
170
|
-
return s
|
|
171
|
-
.replace(/\\/g, '\\\\')
|
|
172
|
-
.replace(/"/g, '\\"')
|
|
173
|
-
.replace(/\n/g, '\\n')
|
|
174
|
-
.replace(/\r/g, '\\r');
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Pick a printk format specifier + argument expression for a debug variable.
|
|
179
|
-
*
|
|
180
|
-
* The debug preprocessor has no TypeChecker, so `cppType` is a coarse category
|
|
181
|
-
* inferred from AST shape. For `unknown` we cast to `double` and use `%g` so
|
|
182
|
-
* the generated printk always compiles for any numeric/bool variable. printk
|
|
183
|
-
* supports the standard printf format specifiers.
|
|
184
|
-
*
|
|
185
|
-
* Returns `{ spec, arg }` where `spec` is the `%`-specifier substring to embed
|
|
186
|
-
* in the format string and `arg` is the C++ argument expression.
|
|
187
|
-
*/
|
|
188
|
-
function formatSpecFor(
|
|
189
|
-
varName: string,
|
|
190
|
-
cppType: CapturedVariable['cppType'],
|
|
191
|
-
): { spec: string; arg: string } {
|
|
192
|
-
switch (cppType) {
|
|
193
|
-
case 'bool':
|
|
194
|
-
case 'int':
|
|
195
|
-
return { spec: '%d', arg: varName };
|
|
196
|
-
case 'long':
|
|
197
|
-
return { spec: '%ld', arg: varName };
|
|
198
|
-
case 'float':
|
|
199
|
-
return { spec: '%g', arg: varName };
|
|
200
|
-
case 'string':
|
|
201
|
-
return { spec: '%s', arg: varName };
|
|
202
|
-
case 'unknown':
|
|
203
|
-
default:
|
|
204
|
-
// Cast to double so printk compiles regardless of the real C++ type.
|
|
205
|
-
return { spec: '%g', arg: `static_cast<double>(${varName})` };
|
|
206
|
-
}
|
|
207
|
-
}
|