@typecad/framework-zephyr 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 +22 -35
- 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/controllers.d.ts +28 -8
- package/dist/chips/controllers.js +49 -12
- 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 +298 -15
- 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 +382 -12
- package/dist/chips/xiao-ble.js +33 -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 +83 -1
- package/dist/dt-config/kconfig.js +116 -27
- package/dist/dt-config/overlay.js +623 -18
- package/dist/framework.manifest.d.ts +20 -30
- package/dist/framework.manifest.js +124 -178
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -2
- package/dist/lowering/adc.d.ts +26 -5
- package/dist/lowering/adc.js +137 -31
- 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 +90 -10
- 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 +12 -6
- package/dist/lowering/power.js +0 -4
- package/dist/lowering/preferences.js +49 -77
- package/dist/lowering/pulse.js +5 -36
- package/dist/lowering/pwm.d.ts +32 -3
- package/dist/lowering/pwm.js +105 -17
- 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 +18 -5
- 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 +120 -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 +881 -212
- 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 +212 -72
- package/dist/toolchain/env-check.d.ts +4 -4
- package/dist/toolchain/env-check.js +5 -5
- package/dist/toolchain/index.d.ts +66 -1
- package/dist/toolchain/index.js +713 -58
- package/dist/toolchain/scaffold.d.ts +9 -0
- package/dist/toolchain/scaffold.js +84 -7
- package/dist/toolchain/west-discover.d.ts +8 -1
- package/dist/toolchain/west-discover.js +19 -6
- package/dist/toolchain/west-spawn.js +17 -5
- 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 +16 -16
- package/src/as-built.ts +206 -0
- package/src/boardgen.ts +1428 -0
- package/src/chips/controllers.ts +61 -12
- package/src/chips/index.ts +35 -54
- package/src/chips/resolve.ts +316 -14
- package/src/chips/types.ts +388 -13
- 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 +177 -19
- package/src/dt-config/overlay.ts +1058 -450
- package/src/framework.manifest.ts +125 -178
- package/src/index.ts +57 -41
- package/src/lowering/adc.ts +222 -102
- 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 -152
- 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 +12 -6
- package/src/lowering/preferences.ts +327 -354
- package/src/lowering/pwm.ts +167 -74
- 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 +120 -111
- package/src/sdk/board-catalog-sync.ts +62 -0
- package/src/strategy.ts +888 -229
- package/src/toolchain/bossac-touch.ts +112 -0
- package/src/toolchain/compat.ts +8 -3
- package/src/toolchain/debug-config.ts +666 -522
- package/src/toolchain/env-check.ts +9 -9
- package/src/toolchain/index.ts +765 -44
- package/src/toolchain/scaffold.ts +81 -7
- package/src/toolchain/west-discover.ts +334 -316
- package/src/toolchain/west-spawn.ts +17 -5
- 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 -70
- 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
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
import { writeFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
|
|
11
11
|
import { join } from 'node:path';
|
|
12
12
|
import { resolveKconfigFragments, type KconfigUsage } from '../dt-config/kconfig.js';
|
|
13
|
+
import { scanSensorParts } from './index.js';
|
|
14
|
+
import { readCuttlefishLibrarySidecar } from '@typecad/cuttlefish/library-packages';
|
|
15
|
+
import { SENSOR_PART_INFO } from '@typecad/hal';
|
|
13
16
|
|
|
14
17
|
/** Write a file only if the content differs from the existing file.
|
|
15
18
|
* Returns true when the file was written (content changed or file was new). */
|
|
@@ -58,6 +61,30 @@ function readEmittedSources(srcDir: string): string {
|
|
|
58
61
|
return out;
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Append cuttlefish library packages' devicetree overlay fragments to the
|
|
66
|
+
* generated overlay. Library entries come from the transpiler's libraries.json
|
|
67
|
+
* sidecar (next to the emitted sources) and are already gated on the
|
|
68
|
+
* library's include token appearing in the emitted sources — no re-detection.
|
|
69
|
+
* Fragments merge after the framework overlay so library nodes (e.g.
|
|
70
|
+
* @typecad/zephyr-esp32s3-rgb's WS2812 node on I2S0) layer over it.
|
|
71
|
+
*/
|
|
72
|
+
export function appendLibraryOverlayFragments(overlay: string, projectRoot: string): string {
|
|
73
|
+
let out = overlay;
|
|
74
|
+
for (const entry of readCuttlefishLibrarySidecar(join(projectRoot, 'src'))) {
|
|
75
|
+
if (!entry.overlay) continue;
|
|
76
|
+
try {
|
|
77
|
+
const fragment = readFileSync(entry.overlay, 'utf8').trim();
|
|
78
|
+
if (fragment.length > 0) {
|
|
79
|
+
out += (out.endsWith('\n') ? '' : '\n') + '\n' + fragment + '\n';
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
// best-effort; a missing fragment surfaces as a DT error
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
61
88
|
/**
|
|
62
89
|
* Emit the Zephyr application skeleton around the generated src/main.cpp.
|
|
63
90
|
*
|
|
@@ -98,17 +125,28 @@ export function scaffoldZephyrProject(projectRoot: string, debug = false, userKc
|
|
|
98
125
|
usesDac: uses('dac_') || uses('__tc_dac'),
|
|
99
126
|
usesFS: uses('__tc_fs'),
|
|
100
127
|
usesHwtimer: uses('counter_') || uses('__tc_hw'),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
128
|
+
// The __tc_<bus> alternative matches the shim's state block — a program
|
|
129
|
+
// that only calls begin() emits `(void)__tc_i2c1_dev;` (no driver API
|
|
130
|
+
// call yet), but the shim still declared DEVICE_DT_GET(DT_NODELABEL(...))
|
|
131
|
+
// so the overlay must enable the node or the device symbol is missing.
|
|
132
|
+
usesI2c: uses('i2c_') || uses('__tc_i2c'),
|
|
133
|
+
// DT-bound sensor parts: the __tc_sensor_* state references and the
|
|
134
|
+
// sensor_sample_fetch/sensor_channel_get calls both carry the token.
|
|
135
|
+
usesSensor: uses('sensor_') || uses('__tc_sensor'),
|
|
136
|
+
usesFloatFormat: /%[-0-9.]*[eEfFgG]/.test(src),
|
|
137
|
+
usesSpi: uses('spi_') || uses('__tc_spi'),
|
|
138
|
+
usesUart: uses('uart_') || uses('__tc_uart'),
|
|
139
|
+
// USB CDC serial: every usb.* lowering calls into the __tc_usb<N>_* shim
|
|
140
|
+
// (device + init helper emitted under usesUsb).
|
|
141
|
+
usesUsb: uses('__tc_usb'),
|
|
142
|
+
// STM32F4 DBGMCU keep-SWD-alive init present (emitted for stm32f4 socs).
|
|
143
|
+
usesStm32DebugSleep: uses('__tc_stm32_dbgmcu'),
|
|
104
144
|
usesWdt: uses('wdt_'),
|
|
105
145
|
usesBle: uses('bt_') || uses('bt_gatt') || uses('bt_le_'),
|
|
106
146
|
usesDisplay: uses('display_write') || uses('display_init') || uses('display_fill_rect') || uses('__tc_display_dev') || uses('CuttlefishDisplayTarget'),
|
|
107
147
|
usesTouch: uses('ft6336u') || uses('touch_'),
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
// with tx_power_dbm — removed.
|
|
111
|
-
usesPower: uses('pm_') || uses('k_sleep') || uses('PM_STATE_'),
|
|
148
|
+
// (The power HAL is removed; its former pm_/k_sleep token scan is gone —
|
|
149
|
+
// nothing here must match tx_power_dbm's `power` substring.)
|
|
112
150
|
usesWifi: uses('wifi_') || uses('net_mgmt') || uses('conn_mgr'),
|
|
113
151
|
// HTTP: the __tc_http_* shim + http_client_req + getaddrinfo. The '_'-anchored
|
|
114
152
|
// 'http_' token matches __tc_http_* and http_client_req (the core HTTP lib
|
|
@@ -141,6 +179,12 @@ export function scaffoldZephyrProject(projectRoot: string, debug = false, userKc
|
|
|
141
179
|
'# Auto-generated by @typecad/framework-zephyr from cuttlefish.config.ts.',
|
|
142
180
|
'cmake_minimum_required(VERSION 3.20.0)',
|
|
143
181
|
'',
|
|
182
|
+
'# The app is its own board root: MCU-only targets generate an out-of-tree',
|
|
183
|
+
'# custom board under boards/typecad/<name>/ that Zephyr must discover.',
|
|
184
|
+
'# Harmless when boards/ holds only .overlay files (BOARD_ROOT just needs',
|
|
185
|
+
'# the directory to exist).',
|
|
186
|
+
'list(APPEND BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR})',
|
|
187
|
+
'',
|
|
144
188
|
'find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})',
|
|
145
189
|
'',
|
|
146
190
|
'project(zephyr_app)',
|
|
@@ -205,6 +249,36 @@ export function scaffoldZephyrProject(projectRoot: string, debug = false, userKc
|
|
|
205
249
|
if (userKconfig && userKconfig.hasOwnProperty(sym)) continue;
|
|
206
250
|
prjConf.push(`${sym}=${val}`);
|
|
207
251
|
}
|
|
252
|
+
// ── Cuttlefish library packages ─────────────────────────────────────────
|
|
253
|
+
// Libraries the program imports (recorded in the transpiler's libraries.json
|
|
254
|
+
// sidecar, next to the emitted sources) contribute their manifest's kconfig
|
|
255
|
+
// lines — e.g. @typecad/zephyr-esp32s3-rgb contributes CONFIG_LED_STRIP.
|
|
256
|
+
// Sidecar entries are already gated on the library's include token
|
|
257
|
+
// appearing in the emitted sources, so no re-detection here. User
|
|
258
|
+
// zephyr.kconfig overrides still win.
|
|
259
|
+
const libraryEntries = readCuttlefishLibrarySidecar(srcDir);
|
|
260
|
+
if (libraryEntries.length > 0) {
|
|
261
|
+
prjConf.push('', '# Library packages (cuttlefish.library.json contributions).');
|
|
262
|
+
for (const entry of libraryEntries) {
|
|
263
|
+
for (const line of entry.kconfig) {
|
|
264
|
+
const sym = line.split('=')[0];
|
|
265
|
+
if (userKconfig && sym !== undefined && userKconfig.hasOwnProperty(sym)) continue;
|
|
266
|
+
prjConf.push(line);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Per-part Kconfig exceptions: catalog parts whose driver is NOT default-y
|
|
271
|
+
// on its DT node carry extra lines here (empty today — every in-tree sensor
|
|
272
|
+
// driver lights up from the node; the path exists so the first exception
|
|
273
|
+
// found by the generator has somewhere to go).
|
|
274
|
+
const sensorParts = scanSensorParts(src);
|
|
275
|
+
if (sensorParts.length > 0) {
|
|
276
|
+
const extra = [...new Set(sensorParts.flatMap((sp) => SENSOR_PART_INFO[sp.part]?.kconfig ?? []))];
|
|
277
|
+
if (extra.length > 0) {
|
|
278
|
+
prjConf.push('', '# Sensor part Kconfig (catalog exceptions).');
|
|
279
|
+
for (const line of extra) prjConf.push(line);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
208
282
|
// Emit user-specified Kconfig from cuttlefish.config.ts zephyr.kconfig.
|
|
209
283
|
// These override any matching auto-detected symbol (skipped above).
|
|
210
284
|
if (userKconfig) {
|