@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.
- package/README.md +22 -47
- package/dist/as-built.d.ts +33 -0
- package/dist/as-built.js +188 -0
- package/dist/async/timer-polyfill.js +1 -1
- package/dist/boardgen.d.ts +128 -0
- package/dist/boardgen.js +1366 -0
- package/dist/chips/board-overrides.d.ts +7 -0
- package/dist/chips/board-overrides.js +11 -0
- package/dist/chips/esp32s3.js +49 -0
- package/dist/chips/index.d.ts +6 -12
- package/dist/chips/index.js +18 -34
- package/dist/chips/resolve.d.ts +16 -2
- package/dist/chips/resolve.js +267 -10
- package/dist/chips/soc/.d.ts +2 -0
- package/dist/chips/soc/.js +129 -0
- package/dist/chips/soc/esp32.d.ts +2 -0
- package/dist/chips/soc/esp32.js +120 -0
- package/dist/chips/soc/esp32c3.d.ts +2 -0
- package/dist/chips/soc/esp32c3.js +90 -0
- package/dist/chips/soc/esp32c6.d.ts +2 -0
- package/dist/chips/soc/esp32c6.js +109 -0
- package/dist/chips/soc/esp32s3.d.ts +2 -0
- package/dist/chips/soc/esp32s3.js +189 -0
- package/dist/chips/soc/index.d.ts +2 -0
- package/dist/chips/soc/index.js +23 -0
- package/dist/chips/soc/nrf52840.d.ts +2 -0
- package/dist/chips/soc/nrf52840.js +130 -0
- package/dist/chips/soc/rp2040.d.ts +2 -0
- package/dist/chips/soc/rp2040.js +141 -0
- package/dist/chips/soc/rp2350a.d.ts +2 -0
- package/dist/chips/soc/rp2350a.js +145 -0
- package/dist/chips/soc/samd21g18a.d.ts +2 -0
- package/dist/chips/soc/samd21g18a.js +143 -0
- package/dist/chips/soc/stm32f411xe.d.ts +2 -0
- package/dist/chips/soc/stm32f411xe.js +251 -0
- package/dist/chips/types.d.ts +319 -0
- package/dist/chips/xiao-ble.js +21 -0
- package/dist/display/profiles.js +1 -1
- package/dist/doctor.js +38 -4
- package/dist/dt-config/custom-board.d.ts +23 -0
- package/dist/dt-config/custom-board.js +227 -0
- package/dist/dt-config/kconfig.d.ts +72 -1
- package/dist/dt-config/kconfig.js +115 -26
- package/dist/dt-config/overlay.js +548 -28
- package/dist/framework.manifest.d.ts +3 -3
- package/dist/framework.manifest.js +122 -185
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -2
- package/dist/lowering/adc.d.ts +20 -2
- package/dist/lowering/adc.js +121 -29
- package/dist/lowering/ble.js +31 -28
- package/dist/lowering/dac.js +9 -9
- package/dist/lowering/fs.js +18 -10
- package/dist/lowering/gpio.d.ts +2 -0
- package/dist/lowering/gpio.js +82 -5
- package/dist/lowering/http.js +39 -14
- package/dist/lowering/hwtimer.d.ts +4 -0
- package/dist/lowering/hwtimer.js +35 -10
- package/dist/lowering/i2c.js +46 -54
- package/dist/lowering/index.d.ts +5 -5
- package/dist/lowering/index.js +15 -16
- package/dist/lowering/interrupts.d.ts +22 -5
- package/dist/lowering/interrupts.js +104 -22
- package/dist/lowering/mqtt.js +3 -5
- package/dist/lowering/power.js +0 -4
- package/dist/lowering/preferences.js +49 -77
- package/dist/lowering/pulse.js +0 -31
- package/dist/lowering/pwm.d.ts +12 -1
- package/dist/lowering/pwm.js +78 -14
- package/dist/lowering/random.js +3 -3
- package/dist/lowering/sensor.d.ts +37 -0
- package/dist/lowering/sensor.js +119 -0
- package/dist/lowering/spi.d.ts +12 -0
- package/dist/lowering/spi.js +65 -40
- package/dist/lowering/thread.d.ts +14 -0
- package/dist/lowering/thread.js +55 -0
- package/dist/lowering/timing.js +20 -46
- package/dist/lowering/tone.js +16 -4
- package/dist/lowering/uart.d.ts +13 -0
- package/dist/lowering/uart.js +72 -51
- package/dist/lowering/usb.d.ts +34 -0
- package/dist/lowering/usb.js +206 -0
- package/dist/lowering/wdt.d.ts +1 -1
- package/dist/lowering/wdt.js +17 -7
- package/dist/lowering/wifi.d.ts +3 -2
- package/dist/lowering/wifi.js +97 -111
- package/dist/sdk/board-catalog-sync.d.ts +16 -0
- package/dist/sdk/board-catalog-sync.js +41 -0
- package/dist/sdk/board-data.generated.d.ts +2 -0
- package/dist/sdk/board-data.generated.js +4 -0
- package/dist/sdk/catalog-walker.d.ts +90 -0
- package/dist/sdk/catalog-walker.js +682 -0
- package/dist/sdk/dts-reader.d.ts +83 -0
- package/dist/sdk/dts-reader.js +596 -0
- package/dist/strategy.d.ts +136 -17
- package/dist/strategy.js +839 -222
- package/dist/toolchain/bossac-touch.d.ts +18 -0
- package/dist/toolchain/bossac-touch.js +88 -0
- package/dist/toolchain/compat.d.ts +2 -2
- package/dist/toolchain/compat.js +8 -3
- package/dist/toolchain/debug-config.d.ts +21 -26
- package/dist/toolchain/debug-config.js +226 -76
- package/dist/toolchain/env-check.d.ts +4 -4
- package/dist/toolchain/env-check.js +5 -5
- package/dist/toolchain/index.d.ts +115 -1
- package/dist/toolchain/index.js +680 -71
- package/dist/toolchain/scaffold.js +39 -7
- package/dist/toolchain/west-discover.d.ts +4 -0
- package/dist/toolchain/west-discover.js +17 -6
- package/installer/CHANGELOG.md +473 -0
- package/installer/README.md +328 -0
- package/installer/environment.yml +46 -0
- package/installer/etc/conda/activate.d/zephyr.bat +7 -0
- package/installer/etc/conda/activate.d/zephyr.ps1 +12 -0
- package/installer/etc/conda/activate.d/zephyr.sh +20 -0
- package/installer/etc/conda/deactivate.d/zephyr.bat +6 -0
- package/installer/etc/conda/deactivate.d/zephyr.ps1 +6 -0
- package/installer/etc/conda/deactivate.d/zephyr.sh +4 -0
- package/installer/install.mjs +580 -0
- package/installer/install.ps1 +619 -0
- package/installer/install.sh +310 -0
- package/installer/lib/detect-platform.sh +62 -0
- package/installer/lib/fetch-sdk.sh +304 -0
- package/installer/lib/init-workspace.sh +153 -0
- package/installer/lib/write-activation.sh +76 -0
- package/installer/patches/tfm-c-include-separators.patch +19 -0
- package/installer/patches/zephyr-tfm-nordic-zephyr-include.patch +24 -0
- package/installer/templates/project/.typecad/activate-zephyr.ps1 +31 -0
- package/installer/templates/project/.typecad/activate-zephyr.sh +31 -0
- package/installer/templates/project/.vscode/settings.json +30 -0
- package/installer/templates/project/README.md +58 -0
- package/installer/versions.env +110 -0
- package/package.json +15 -15
- package/src/as-built.ts +206 -0
- package/src/boardgen.ts +1428 -0
- package/src/chips/index.ts +35 -54
- package/src/chips/resolve.ts +285 -10
- package/src/chips/types.ts +325 -1
- package/src/display/profiles.ts +1 -1
- package/src/doctor.ts +110 -77
- package/src/dt-config/custom-board.ts +325 -0
- package/src/dt-config/kconfig.ts +165 -18
- package/src/dt-config/overlay.ts +537 -25
- package/src/framework.manifest.ts +123 -185
- package/src/index.ts +57 -41
- package/src/lowering/adc.ts +222 -118
- package/src/lowering/ble.ts +32 -28
- package/src/lowering/dac.ts +82 -82
- package/src/lowering/fs.ts +18 -10
- package/src/lowering/gpio.ts +242 -155
- package/src/lowering/http.ts +512 -488
- package/src/lowering/hwtimer.ts +139 -101
- package/src/lowering/i2c.ts +116 -126
- package/src/lowering/index.ts +91 -93
- package/src/lowering/interrupts.ts +113 -21
- package/src/lowering/mqtt.ts +3 -5
- package/src/lowering/preferences.ts +327 -354
- package/src/lowering/pwm.ts +167 -99
- package/src/lowering/random.ts +3 -3
- package/src/lowering/sensor.ts +155 -0
- package/src/lowering/spi.ts +164 -124
- package/src/lowering/thread.ts +63 -0
- package/src/lowering/timing.ts +46 -72
- package/src/lowering/uart.ts +73 -51
- package/src/lowering/usb.ts +221 -0
- package/src/lowering/wdt.ts +95 -84
- package/src/lowering/wifi.ts +97 -112
- package/src/sdk/board-catalog-sync.ts +62 -0
- package/src/strategy.ts +848 -237
- package/src/toolchain/bossac-touch.ts +112 -0
- package/src/toolchain/compat.ts +8 -3
- package/src/toolchain/debug-config.ts +676 -522
- package/src/toolchain/env-check.ts +9 -9
- package/src/toolchain/index.ts +1359 -645
- package/src/toolchain/scaffold.ts +38 -7
- package/src/toolchain/west-discover.ts +19 -6
- package/src/async/timer-polyfill.ts +0 -107
- package/src/chips/esp32.ts +0 -74
- package/src/chips/esp32s3.ts +0 -57
- package/src/chips/xiao-ble.ts +0 -82
- package/src/lowering/power.ts +0 -70
- package/src/lowering/pulse.ts +0 -93
- package/src/lowering/tone.ts +0 -60
- package/src/lowering/worker-backing.ts +0 -94
- package/src/lowering/worker.ts +0 -17
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// 1200-baud touch-to-reset for BOSSA-bootloader boards (host side)
|
|
3
|
+
//
|
|
4
|
+
// The device side lives in the emitted USB shim (lowering/usb.ts): when the
|
|
5
|
+
// host sets the CDC baud rate to 1200, the firmware writes the bootloader's
|
|
6
|
+
// stay-resident magic to RAM and reboots — the board lands in the BOSSA
|
|
7
|
+
// bootloader without a button press. This module is the other half: open the
|
|
8
|
+
// app's console port at 1200 baud to trigger that reboot, then wait for the
|
|
9
|
+
// bootloader's own USB identity to appear and report its port so bossac can
|
|
10
|
+
// be pointed at it.
|
|
11
|
+
//
|
|
12
|
+
// Runs as a spawned `node -e` helper (upload() is synchronous; serialport's
|
|
13
|
+
// open/poll loop is async) with require() resolution rooted at THIS package,
|
|
14
|
+
// so `serialport` resolves from the monorepo's hoisted node_modules. In a
|
|
15
|
+
// published install without serialport available, the touch is skipped with
|
|
16
|
+
// a note telling the user to double-tap reset — never a hard failure.
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
import { spawnSync } from 'node:child_process';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
|
|
23
|
+
/** The descriptor subset this helper needs (see ZephyrChipDescriptor.usb.touchReset). */
|
|
24
|
+
export interface TouchResetInfo {
|
|
25
|
+
readonly flagAddress: number;
|
|
26
|
+
readonly magic: number;
|
|
27
|
+
readonly bootloaderVid?: string;
|
|
28
|
+
readonly bootloaderPid?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface TouchResetResult {
|
|
32
|
+
/** Bootloader port to flash (undefined = touch failed / timed out). */
|
|
33
|
+
readonly port?: string;
|
|
34
|
+
/** Human-readable outcome for the build log. */
|
|
35
|
+
readonly note: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// CommonJS so `node -e` can require() it without a package "type" lookup.
|
|
39
|
+
// Keep the logic compact: open at 1200, close, poll for the bootloader
|
|
40
|
+
// identity, print the port (or nothing) on stdout.
|
|
41
|
+
const TOUCH_SCRIPT = `
|
|
42
|
+
const SerialPort = require('serialport');
|
|
43
|
+
const [appPort, wantVid, wantPid, timeoutMsStr] = process.argv.slice(1);
|
|
44
|
+
const norm = (v) => (v || '').toLowerCase().replace(/^0x/, '');
|
|
45
|
+
const timeoutMs = parseInt(timeoutMsStr, 10) || 15000;
|
|
46
|
+
function die(msg) { console.log(JSON.stringify({ error: msg })); process.exit(0); }
|
|
47
|
+
// The open call itself delivers the touch: serialport applies the 1200-baud
|
|
48
|
+
// line coding as part of opening, and the firmware resets to the bootloader
|
|
49
|
+
// MID-OPEN — so the open erroring ("File not found" on Windows as the device
|
|
50
|
+
// vanishes) is the EXPECTED symptom of success, not a failure. Whatever the
|
|
51
|
+
// open result, proceed to watching for the bootloader identity; only a
|
|
52
|
+
// missing bootloader after the timeout is a real failure.
|
|
53
|
+
async function watchForBootloader() {
|
|
54
|
+
const deadline = Date.now() + timeoutMs;
|
|
55
|
+
while (Date.now() < deadline) {
|
|
56
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
57
|
+
try {
|
|
58
|
+
const list = await SerialPort.SerialPort.list();
|
|
59
|
+
const hit = list.find((p) =>
|
|
60
|
+
norm(p.vendorId) === norm(wantVid) && norm(p.productId) === norm(wantPid));
|
|
61
|
+
if (hit) { console.log(JSON.stringify({ port: hit.path })); process.exit(0); }
|
|
62
|
+
} catch { /* transient enumeration races while ports bounce */ }
|
|
63
|
+
}
|
|
64
|
+
die('timeout');
|
|
65
|
+
}
|
|
66
|
+
const port = new SerialPort.SerialPort({ path: appPort, baudRate: 1200, autoOpen: false });
|
|
67
|
+
port.open((err) => {
|
|
68
|
+
if (err) { watchForBootloader(); return; }
|
|
69
|
+
// The 1200-baud line coding was applied BY the open; close immediately —
|
|
70
|
+
// the firmware's 250 ms pre-reboot delay covers the ordering, and holding
|
|
71
|
+
// the handle open across the device reset is what wedges usbser.
|
|
72
|
+
port.close(() => watchForBootloader());
|
|
73
|
+
});
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Touch the app port at 1200 baud and wait for the bootloader to appear.
|
|
78
|
+
* Never throws — a failed touch degrades to "double-tap reset" guidance.
|
|
79
|
+
*/
|
|
80
|
+
export function bossacTouchReset(
|
|
81
|
+
appPort: string,
|
|
82
|
+
info: TouchResetInfo,
|
|
83
|
+
timeoutMs = 30_000,
|
|
84
|
+
): TouchResetResult {
|
|
85
|
+
if (!info.bootloaderVid || !info.bootloaderPid) {
|
|
86
|
+
return { note: 'touch-reset: board declares no bootloader USB identity — skipping (double-tap reset to enter the bootloader)' };
|
|
87
|
+
}
|
|
88
|
+
const pkgDir = path.dirname(path.dirname(fileURLToPath(import.meta.url))); // .../src -> package root
|
|
89
|
+
let result: ReturnType<typeof spawnSync>;
|
|
90
|
+
try {
|
|
91
|
+
result = spawnSync(
|
|
92
|
+
process.execPath,
|
|
93
|
+
['-e', TOUCH_SCRIPT, '--', appPort, info.bootloaderVid, info.bootloaderPid, String(timeoutMs)],
|
|
94
|
+
{ encoding: 'utf8', timeout: timeoutMs + 10_000, cwd: pkgDir },
|
|
95
|
+
);
|
|
96
|
+
} catch {
|
|
97
|
+
return { note: 'touch-reset: helper failed to launch — double-tap reset to enter the bootloader' };
|
|
98
|
+
}
|
|
99
|
+
const stdout = (typeof result.stdout === 'string' ? result.stdout : '').trim();
|
|
100
|
+
const lastLine = stdout.split('\n').filter(Boolean).pop() ?? '';
|
|
101
|
+
try {
|
|
102
|
+
const parsed = JSON.parse(lastLine) as { port?: string; error?: string };
|
|
103
|
+
if (parsed.port) {
|
|
104
|
+
return { port: parsed.port, note: `touch-reset: bootloader on ${parsed.port}` };
|
|
105
|
+
}
|
|
106
|
+
return { note: 'touch-reset: bootloader did not re-appear in time — double-tap reset and retry' };
|
|
107
|
+
} catch {
|
|
108
|
+
// serialport not resolvable (published install without it) or the helper
|
|
109
|
+
// crashed — degrade gracefully.
|
|
110
|
+
return { note: 'touch-reset: unavailable (serialport not installed?) — double-tap reset to enter the bootloader' };
|
|
111
|
+
}
|
|
112
|
+
}
|
package/src/toolchain/compat.ts
CHANGED
|
@@ -76,7 +76,7 @@ export function detectZephyrVersion(): string | undefined {
|
|
|
76
76
|
let base = process.env.ZEPHYR_BASE;
|
|
77
77
|
if (!base) {
|
|
78
78
|
// Fall back to the discovered west install's zephyrBase — covers the
|
|
79
|
-
// micromamba env from
|
|
79
|
+
// micromamba env from the bundled Zephyr installer WITHOUT activation.
|
|
80
80
|
// (micromamba run sets ZEPHYR_BASE only inside the west subprocess; this
|
|
81
81
|
// makes the compat check work in the parent cuttlefish process too.)
|
|
82
82
|
const install = discoverWest();
|
|
@@ -132,17 +132,22 @@ export function checkZephyrCompat(version: string | undefined): CompatResult {
|
|
|
132
132
|
* found". Map each known multi-core board id to its procpu (main app core)
|
|
133
133
|
* qualified form. procpu is the core that runs application firmware; appcpu is
|
|
134
134
|
* the secondary core (selected explicitly only when offloading to it).
|
|
135
|
+
* Single-SoC boards (xiao_ble, rpi_pico) still normalize their bare ids on
|
|
136
|
+
* 4.4, but Zephyr has signaled that bare-name normalization is going away —
|
|
137
|
+
* map them too so builds do not depend on it.
|
|
135
138
|
*/
|
|
136
139
|
const QUALIFIED_TARGETS_GE_4_3: Record<string, string> = {
|
|
137
140
|
esp32_devkitc: 'esp32_devkitc/esp32/procpu',
|
|
138
141
|
esp32s3_devkitc: 'esp32s3_devkitc/esp32s3/procpu',
|
|
142
|
+
xiao_ble: 'xiao_ble/nrf52840',
|
|
143
|
+
rpi_pico: 'rpi_pico/rp2040',
|
|
139
144
|
};
|
|
140
145
|
|
|
141
146
|
/**
|
|
142
147
|
* Normalize a board target for the installed Zephyr version. Rewrites a stale
|
|
143
148
|
* bare id (esp32s3_devkitc) to the qualified form on Zephyr >=4.3; idempotent
|
|
144
|
-
* if the target is already qualified. Older Zephyr
|
|
145
|
-
*
|
|
149
|
+
* if the target is already qualified. Older Zephyr and unknown boards pass
|
|
150
|
+
* through unchanged.
|
|
146
151
|
*/
|
|
147
152
|
export function resolveBoardTarget(boardTarget: string, version: string | undefined): string {
|
|
148
153
|
const boardId = boardTarget.split('/')[0]!;
|