@geastack/cli 0.1.91 → 0.1.93
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/package.json +4 -4
- package/src/boards/custom-target.mjs +52 -6
- package/src/boards/usb.mjs +23 -6
- package/src/commands/board.mjs +1 -1
- package/src/device/device.mjs +1 -1
- package/src/device/serial.mjs +38 -4
- package/src/esp32/build.mjs +10 -5
- package/src/esp32/capabilities.mjs +2 -0
- package/src/esp32/flash.mjs +1 -1
- package/src/esp32/idf-env.mjs +47 -14
- package/src/esp32/idf-version.mjs +5 -0
- package/NOTICE +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.93",
|
|
4
4
|
"description": "Command-line front door for GeaStack apps, targets, and local toolchains.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@clack/prompts": "^1.8.0",
|
|
40
40
|
"@geastack/simulator": "^0.1.13",
|
|
41
|
-
"@geastack/targets": "^0.1.
|
|
41
|
+
"@geastack/targets": "^0.1.88",
|
|
42
42
|
"picocolors": "^1.1.1",
|
|
43
43
|
"serialport": "^13.0.0"
|
|
44
44
|
},
|
|
45
45
|
"starterDependencies": {
|
|
46
|
-
"@geastack/core": "^0.1.
|
|
47
|
-
"@geastack/targets": "^0.1.
|
|
46
|
+
"@geastack/core": "^0.1.34",
|
|
47
|
+
"@geastack/targets": "^0.1.88",
|
|
48
48
|
"@geastack/apple": "^0.2.13"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
@@ -151,6 +151,7 @@ export function normalizeCustomTarget(raw, catalog) {
|
|
|
151
151
|
[imu, 'chips.imu'],
|
|
152
152
|
[expander, 'chips.expander']
|
|
153
153
|
].filter(([chip]) => chip && chip.interface === 'i2c')
|
|
154
|
+
if (audio) i2cChips.push([audio, 'chips.audio (codec control)'])
|
|
154
155
|
if (absent(buses.i2c) && i2cChips.length > 0) {
|
|
155
156
|
throw new Error(`buses.i2c is required because ${i2cChips.map(([, label]) => label).join(', ')} ${i2cChips.length > 1 ? 'are' : 'is'} on the I2C bus.`)
|
|
156
157
|
}
|
|
@@ -171,7 +172,8 @@ export function normalizeCustomTarget(raw, catalog) {
|
|
|
171
172
|
const spiHost = display && displayInterface === 'qspi' ? String(display.spiHost ?? 'spi2').toLowerCase() : 'spi2'
|
|
172
173
|
if (display && displayInterface === 'qspi' && !['spi2', 'spi3'].includes(spiHost)) throw new Error("chips.display.spiHost must be 'spi2' or 'spi3'.")
|
|
173
174
|
const expanderOutputs = expander ? (absent(expander.outputs) ? {} : object(expander.outputs, 'chips.expander.outputs')) : null
|
|
174
|
-
const
|
|
175
|
+
const expanderMaxPin = expander?.driver === 'tca9554' ? 7 : expander?.driver === 'ch422g' ? 11 : 15
|
|
176
|
+
const expanderPin = (value, label) => (absent(value) ? -1 : integer(value, label, { min: 0, max: expanderMaxPin }))
|
|
175
177
|
|
|
176
178
|
// Flash size and the partition table are board geometry, not app policy: a
|
|
177
179
|
// module with 16MB of flash cannot borrow its base's 32MB layout, and every
|
|
@@ -208,6 +210,36 @@ export function normalizeCustomTarget(raw, catalog) {
|
|
|
208
210
|
throw new Error(`psram.speed must be 40, 80 or 120 MHz, not ${psramSpeed}.`)
|
|
209
211
|
}
|
|
210
212
|
|
|
213
|
+
const controller = display && !absent(display.controller) ? object(display.controller, 'chips.display.controller') : null
|
|
214
|
+
if (controller && (displayInterface !== 'rgb' || !expander)) throw new Error('RGB controller initialization requires an I/O expander.')
|
|
215
|
+
const byte = (value, label) => integer(value, label, { min: 0, max: 255 })
|
|
216
|
+
const controllerConfig = controller ? {
|
|
217
|
+
cs: expanderPin(controller.cs, 'controller.cs'),
|
|
218
|
+
clock: expanderPin(controller.clock, 'controller.clock'),
|
|
219
|
+
data: expanderPin(controller.data, 'controller.data'),
|
|
220
|
+
reset: expanderPin(controller.reset, 'controller.reset'),
|
|
221
|
+
addressSelect: expanderPin(controller.addressSelect, 'controller.addressSelect'),
|
|
222
|
+
commands: Array.isArray(controller.commands) ? controller.commands.map((command, index) => {
|
|
223
|
+
object(command, `controller.commands[${index}]`)
|
|
224
|
+
if (!Array.isArray(command.data) || command.data.length > 32) throw new Error('Controller command data must be an array of at most 32 bytes.')
|
|
225
|
+
return { command: byte(command.command, 'controller command'), data: command.data.map(value => byte(value, 'controller data')), delayMs: integer(command.delayMs ?? 0, 'controller delayMs', { min: 0, max: 1000 }) }
|
|
226
|
+
}) : []
|
|
227
|
+
} : null
|
|
228
|
+
if (controllerConfig && (controllerConfig.cs < 0 || controllerConfig.clock < 0 || controllerConfig.data < 0 || !controllerConfig.commands.length)) throw new Error('Controller requires CS, clock, data and initialization commands.')
|
|
229
|
+
|
|
230
|
+
if (controllerConfig) {
|
|
231
|
+
const assigned = new Set()
|
|
232
|
+
for (const [label, value] of Object.entries(controllerConfig)) {
|
|
233
|
+
if (label === 'commands' || value < 0) continue
|
|
234
|
+
if (assigned.has(value)) throw new Error(`Controller control pins overlap at expander pin ${value}.`)
|
|
235
|
+
assigned.add(value)
|
|
236
|
+
}
|
|
237
|
+
for (const [label, value] of Object.entries(expanderOutputs)) {
|
|
238
|
+
if (label.startsWith('_') || absent(value)) continue
|
|
239
|
+
if (assigned.has(value)) throw new Error(`Controller pin overlaps expander.outputs.${label}.`)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
211
243
|
const target = {
|
|
212
244
|
id,
|
|
213
245
|
extends: base,
|
|
@@ -239,6 +271,8 @@ export function normalizeCustomTarget(raw, catalog) {
|
|
|
239
271
|
vsyncBackPorch: integer(display.vsyncBackPorch ?? 8, 'chips.display.vsyncBackPorch', { min: 0, max: 1024 }),
|
|
240
272
|
vsyncFrontPorch: integer(display.vsyncFrontPorch ?? 8, 'chips.display.vsyncFrontPorch', { min: 0, max: 1024 }),
|
|
241
273
|
pclkActiveNeg: boolean(display.pclkActiveNeg, 'chips.display.pclkActiveNeg', true),
|
|
274
|
+
backlightActiveLow: boolean(display.backlightActiveLow, 'chips.display.backlightActiveLow', false),
|
|
275
|
+
controller: controllerConfig,
|
|
242
276
|
nativeSources: display.nativeSources,
|
|
243
277
|
bindingSources: display.bindingSources,
|
|
244
278
|
requires: display.requires,
|
|
@@ -290,8 +324,11 @@ export function normalizeCustomTarget(raw, catalog) {
|
|
|
290
324
|
nativeSources: expander.nativeSources,
|
|
291
325
|
bindingSources: expander.bindingSources,
|
|
292
326
|
requires: expander.requires,
|
|
327
|
+
address: integer(expander.address ?? 32, 'chips.expander.address', { min: 8, max: 119 }),
|
|
328
|
+
initialDirections: byte(expander.initialDirections ?? 255, 'chips.expander.initialDirections'),
|
|
293
329
|
initialOutputs: integer(expander.initialOutputs ?? 255, 'chips.expander.initialOutputs', { min: 0, max: 255 }),
|
|
294
330
|
outputs: {
|
|
331
|
+
powerAmplifier: expanderPin(expanderOutputs.powerAmplifier, 'chips.expander.outputs.powerAmplifier'),
|
|
295
332
|
backlight: expanderPin(expanderOutputs.backlight, 'chips.expander.outputs.backlight'),
|
|
296
333
|
touchReset: expanderPin(expanderOutputs.touchReset, 'chips.expander.outputs.touchReset'),
|
|
297
334
|
displayReset: expanderPin(expanderOutputs.displayReset, 'chips.expander.outputs.displayReset')
|
|
@@ -314,6 +351,7 @@ export function normalizeCustomTarget(raw, catalog) {
|
|
|
314
351
|
audio: audio === null ? null : {
|
|
315
352
|
driver: audio.driver,
|
|
316
353
|
interface: exact(audio.interface, 'i2s', 'chips.audio.interface'),
|
|
354
|
+
es7210Address: integer(audio.es7210Address ?? 0, 'chips.audio.es7210Address', { min: 0, max: 119 }),
|
|
317
355
|
nativeSources: audio.nativeSources,
|
|
318
356
|
bindingSources: audio.bindingSources,
|
|
319
357
|
requires: audio.requires,
|
|
@@ -323,7 +361,7 @@ export function normalizeCustomTarget(raw, catalog) {
|
|
|
323
361
|
ws: pin(audioPins.ws, 'chips.audio.pins.ws'),
|
|
324
362
|
dout: pin(audioPins.dout, 'chips.audio.pins.dout'),
|
|
325
363
|
din: pin(audioPins.din, 'chips.audio.pins.din'),
|
|
326
|
-
powerAmplifier: pin(audioPins.powerAmplifier, 'chips.audio.pins.powerAmplifier')
|
|
364
|
+
powerAmplifier: pin(audioPins.powerAmplifier, 'chips.audio.pins.powerAmplifier', { optional: true })
|
|
327
365
|
}
|
|
328
366
|
}
|
|
329
367
|
},
|
|
@@ -448,6 +486,7 @@ ${includes}
|
|
|
448
486
|
#define GEA_BOARD_HAS_MICROSD ${target.storage.microSD ? 1 : 0}
|
|
449
487
|
#define GEA_BOARD_HAS_LAUNCHER_BUTTON ${target.controls.launcherButton ? 1 : 0}
|
|
450
488
|
#define GEA_BOARD_HAS_EXPANDER ${expander ? 1 : 0}
|
|
489
|
+
#define GEA_BOARD_HAS_RGB_CONTROLLER ${rgb?.controller ? 1 : 0}
|
|
451
490
|
|
|
452
491
|
namespace gea::platform::board {
|
|
453
492
|
|
|
@@ -464,7 +503,7 @@ ${qspi ? 'struct Co5300DisplayConfig { spi_host_device_t spiHost; gpio_num_t cs;
|
|
|
464
503
|
// framebuffer out with these timings. data[0..4] are blue, [5..10] green,
|
|
465
504
|
// [11..15] red (RGB565 lane order). backlight is a PWM-capable GPIO, or
|
|
466
505
|
// GPIO_NUM_NC when the expander drives it.
|
|
467
|
-
struct RgbPanelDisplayConfig { gpio_num_t de; gpio_num_t hsync; gpio_num_t vsync; gpio_num_t pclk; gpio_num_t disp; gpio_num_t backlight; gpio_num_t data[16]; int pclkHz; int hsyncPulseWidth; int hsyncBackPorch; int hsyncFrontPorch; int vsyncPulseWidth; int vsyncBackPorch; int vsyncFrontPorch; bool pclkActiveNeg; };` : ''}${touch ? '\nstruct Ft3168TouchConfig { gpio_num_t reset; gpio_num_t interrupt; };' : ''}${expander ? '\n// Expander pin numbers (0-based, the chip\'s own), -1 where a line is not routed through it.\nstruct IoExpanderConfig { int initialOutputs; int backlight; int touchReset; int displayReset; };' : ''}${audio ? '\nstruct Es8311AudioConfig { int i2sPort; gpio_num_t mclk; gpio_num_t bclk; gpio_num_t ws; gpio_num_t dout; gpio_num_t din; gpio_num_t powerAmplifier; };' : ''}
|
|
506
|
+
struct RgbPanelDisplayConfig { gpio_num_t de; gpio_num_t hsync; gpio_num_t vsync; gpio_num_t pclk; gpio_num_t disp; gpio_num_t backlight; gpio_num_t data[16]; int pclkHz; int hsyncPulseWidth; int hsyncBackPorch; int hsyncFrontPorch; int vsyncPulseWidth; int vsyncBackPorch; int vsyncFrontPorch; bool pclkActiveNeg; bool backlightActiveLow; };` : ''}${touch ? '\nstruct Ft3168TouchConfig { gpio_num_t reset; gpio_num_t interrupt; };' : ''}${expander ? '\n// Expander pin numbers (0-based, the chip\'s own), -1 where a line is not routed through it.\nstruct IoExpanderConfig { int initialOutputs; int backlight; int touchReset; int displayReset; int address; int initialDirections; int powerAmplifier; };' : ''}${audio ? '\nstruct Es8311AudioConfig { int i2sPort; gpio_num_t mclk; gpio_num_t bclk; gpio_num_t ws; gpio_num_t dout; gpio_num_t din; gpio_num_t powerAmplifier; int es7210Address; };' : ''}
|
|
468
507
|
|
|
469
508
|
inline constexpr I2cBusConfig i2c{ .sda = ${gpio(i2c.sda)}, .scl = ${gpio(i2c.scl)} };
|
|
470
509
|
inline constexpr SdMmcConfig storage{ .clk = ${gpio(sdPins.clk)}, .cmd = ${gpio(sdPins.cmd)}, .data0 = ${gpio(sdPins.data0)} };
|
|
@@ -476,7 +515,8 @@ ${rgb ? `inline constexpr RgbPanelDisplayConfig display{
|
|
|
476
515
|
.pclkHz = ${rgb.pclkHz},
|
|
477
516
|
.hsyncPulseWidth = ${rgb.hsyncPulseWidth}, .hsyncBackPorch = ${rgb.hsyncBackPorch}, .hsyncFrontPorch = ${rgb.hsyncFrontPorch},
|
|
478
517
|
.vsyncPulseWidth = ${rgb.vsyncPulseWidth}, .vsyncBackPorch = ${rgb.vsyncBackPorch}, .vsyncFrontPorch = ${rgb.vsyncFrontPorch},
|
|
479
|
-
.pclkActiveNeg = ${rgb.pclkActiveNeg ? 'true' : 'false'}
|
|
518
|
+
.pclkActiveNeg = ${rgb.pclkActiveNeg ? 'true' : 'false'},
|
|
519
|
+
.backlightActiveLow = ${rgb.backlightActiveLow ? 'true' : 'false'}
|
|
480
520
|
};` : ''}${qspi ? `inline constexpr Co5300DisplayConfig display{
|
|
481
521
|
.spiHost = ${display.spiHost === 'spi3' ? 'SPI3_HOST' : 'SPI2_HOST'}, .cs = ${gpio(displayPins.cs)}, .pclk = ${gpio(displayPins.pclk)},
|
|
482
522
|
.data0 = ${gpio(displayPins.data0)}, .data1 = ${gpio(displayPins.data1)},
|
|
@@ -484,13 +524,19 @@ ${rgb ? `inline constexpr RgbPanelDisplayConfig display{
|
|
|
484
524
|
.reset = ${gpio(displayPins.reset)}, .te = ${gpio(displayPins.te)}
|
|
485
525
|
};` : ''}${touch ? `
|
|
486
526
|
inline constexpr Ft3168TouchConfig touch{ .reset = ${gpio(touchPins.reset)}, .interrupt = ${gpio(touchPins.interrupt)} };` : ''}${expander ? `
|
|
487
|
-
inline constexpr IoExpanderConfig expander{ .initialOutputs = ${expander.initialOutputs}, .backlight = ${expander.outputs.backlight}, .touchReset = ${expander.outputs.touchReset}, .displayReset = ${expander.outputs.displayReset} };` : ''}${audio ? `
|
|
527
|
+
inline constexpr IoExpanderConfig expander{ .initialOutputs = ${expander.initialOutputs}, .backlight = ${expander.outputs.backlight}, .touchReset = ${expander.outputs.touchReset}, .displayReset = ${expander.outputs.displayReset}, .address = ${expander.address}, .initialDirections = ${expander.initialDirections}, .powerAmplifier = ${expander.outputs.powerAmplifier} };` : ''}${audio ? `
|
|
488
528
|
inline constexpr Es8311AudioConfig audio{
|
|
489
529
|
.i2sPort = I2S_NUM_AUTO, .mclk = ${gpio(audioPins.mclk)}, .bclk = ${gpio(audioPins.bclk)},
|
|
490
530
|
.ws = ${gpio(audioPins.ws)}, .dout = ${gpio(audioPins.dout)}, .din = ${gpio(audioPins.din)},
|
|
491
|
-
.powerAmplifier = ${gpio(audioPins.powerAmplifier)}
|
|
531
|
+
.powerAmplifier = ${gpio(audioPins.powerAmplifier)}, .es7210Address = ${audio.es7210Address}
|
|
492
532
|
};` : ''}
|
|
493
533
|
|
|
534
|
+
${rgb?.controller ? `struct RgbControllerConfig { int cs; int clock; int data; int reset; int addressSelect; };
|
|
535
|
+
inline constexpr RgbControllerConfig rgbController{ ${rgb.controller.cs}, ${rgb.controller.clock}, ${rgb.controller.data}, ${rgb.controller.reset}, ${rgb.controller.addressSelect} };
|
|
536
|
+
struct RgbControllerCommand { unsigned char command; unsigned char data[32]; int length; int delayMs; };
|
|
537
|
+
inline constexpr RgbControllerCommand rgbControllerCommands[] = {
|
|
538
|
+
${rgb.controller.commands.map(command => ` { ${command.command}, { ${command.data.join(', ')} }, ${command.data.length}, ${command.delayMs} },`).join('\n')}
|
|
539
|
+
};` : ''}
|
|
494
540
|
} // namespace gea::platform::board
|
|
495
541
|
`
|
|
496
542
|
}
|
package/src/boards/usb.mjs
CHANGED
|
@@ -109,7 +109,10 @@ function macUsbCalloutPortsForSerial(serial, ioreg = runIoreg) {
|
|
|
109
109
|
for (const line of output.split(/\r?\n/)) {
|
|
110
110
|
const node = line.match(/^([\s|]*)[+\\-]*o\s+/)
|
|
111
111
|
if (node) {
|
|
112
|
-
|
|
112
|
+
// The column of `+-o` is the depth. Counting `|` is not: ioreg draws the
|
|
113
|
+
// last child's subtree with spaces, so a callout under a device's last
|
|
114
|
+
// interface would look shallower than the device holding its serial.
|
|
115
|
+
const depth = node[1].length
|
|
113
116
|
while (stack.length > 0 && stack[stack.length - 1].depth >= depth) stack.pop()
|
|
114
117
|
stack.push({ depth, serial: '' })
|
|
115
118
|
continue
|
|
@@ -144,7 +147,10 @@ export function listMacUsbCalloutPorts(ioreg = runIoreg) {
|
|
|
144
147
|
for (const line of output.split(/\r?\n/)) {
|
|
145
148
|
const node = line.match(/^([\s|]*)[+\\-]*o\s+/)
|
|
146
149
|
if (node) {
|
|
147
|
-
|
|
150
|
+
// The column of `+-o` is the depth. Counting `|` is not: ioreg draws the
|
|
151
|
+
// last child's subtree with spaces, so a callout under a device's last
|
|
152
|
+
// interface would look shallower than the device holding its serial.
|
|
153
|
+
const depth = node[1].length
|
|
148
154
|
while (stack.length > 0 && stack[stack.length - 1].depth >= depth) stack.pop()
|
|
149
155
|
stack.push({ depth, serial: '', product: '' })
|
|
150
156
|
continue
|
|
@@ -183,8 +189,18 @@ function resolveMacUsbSerialPort(serial, ioreg = runIoreg) {
|
|
|
183
189
|
throw new Error(`Could not map USB serial ${serial} to a /dev/cu.* port. Check that the board is attached.`)
|
|
184
190
|
}
|
|
185
191
|
|
|
186
|
-
export function resolveUsbSerialPort({ serial }, { platform = process.platform, ioreg = runIoreg } = {}) {
|
|
192
|
+
export function resolveUsbSerialPort({ serial }, { platform = process.platform, ioreg = runIoreg, env = process.env } = {}) {
|
|
187
193
|
if (!serial) throw new Error('A USB serial number is required to locate the board; /dev paths are not accepted.')
|
|
194
|
+
// GEA_SERIAL_DEVICES replaces OS enumeration everywhere (see detectSerialDevices);
|
|
195
|
+
// resolution honors it with the same exact-serial rule, so a declared device list
|
|
196
|
+
// can never map one board's serial onto another's port.
|
|
197
|
+
if (env.GEA_SERIAL_DEVICES) {
|
|
198
|
+
const needle = normalizedSerial(serial)
|
|
199
|
+
const matches = detectSerialDevices({ env }).filter((device) => device.serial && normalizedSerial(device.serial) === needle)
|
|
200
|
+
if (matches.length === 1) return matches[0].path
|
|
201
|
+
if (matches.length > 1) throw new Error([`USB serial ${serial} maps to multiple ports:`, ...matches.map((device) => ` ${device.path}`)].join('\n'))
|
|
202
|
+
throw new Error(`Could not map USB serial ${serial} to a port in GEA_SERIAL_DEVICES. Check that the board is attached.`)
|
|
203
|
+
}
|
|
188
204
|
if (platform === 'linux') {
|
|
189
205
|
const matches = linuxSerialByIdCandidates(serial)
|
|
190
206
|
if (matches.length === 1) return realpathSync(matches[0])
|
|
@@ -225,7 +241,8 @@ export async function waitForSerialPort({
|
|
|
225
241
|
pollSeconds = 1,
|
|
226
242
|
log = (line) => process.stderr.write(`${line}\n`),
|
|
227
243
|
resolver = resolveUsbSerialPort,
|
|
228
|
-
portPresent = serialPortPresent
|
|
244
|
+
portPresent = serialPortPresent,
|
|
245
|
+
env = process.env
|
|
229
246
|
} = {}) {
|
|
230
247
|
const startedAt = Date.now()
|
|
231
248
|
let nextLog = startedAt
|
|
@@ -234,14 +251,14 @@ export async function waitForSerialPort({
|
|
|
234
251
|
if (portPresent(port)) {
|
|
235
252
|
if (!serial) return port
|
|
236
253
|
try {
|
|
237
|
-
if (resolver({ serial }) === port) return port
|
|
254
|
+
if (resolver({ serial }, { env }) === port) return port
|
|
238
255
|
} catch {
|
|
239
256
|
// An explicit path does not override the registered board identity.
|
|
240
257
|
}
|
|
241
258
|
}
|
|
242
259
|
} else if (serial) {
|
|
243
260
|
try {
|
|
244
|
-
const resolved = resolver({ serial })
|
|
261
|
+
const resolved = resolver({ serial }, { env })
|
|
245
262
|
if (resolved && portPresent(resolved)) return resolved
|
|
246
263
|
} catch {
|
|
247
264
|
// not attached yet
|
package/src/commands/board.mjs
CHANGED
|
@@ -161,7 +161,7 @@ export async function cleanCommand(ctx, parsed, rest, options) {
|
|
|
161
161
|
async function flashEsp32(ctx, parsed, rest, options, selection, { monitor }) {
|
|
162
162
|
const base = io(parsed, options)
|
|
163
163
|
const env = createChildEnv(ctx, base.env)
|
|
164
|
-
const idf = requireEspIdf(env, base.stdout)
|
|
164
|
+
const idf = requireEspIdf(env, base.stdout, selection)
|
|
165
165
|
const flashEnv = idf.env
|
|
166
166
|
const opts = flashOptions(flashEnv, { idf, selection, manualBoot: flag(parsed, 'manual-boot'), noReset: option(parsed, 'reset') === false, baud: option(parsed, 'flash-baud', '') })
|
|
167
167
|
const common = { idf, selection, options: opts, port: selection.port, env: flashEnv, dryRun: base.dryRun, verbose: flag(parsed, 'verbose'), stdout: base.stdout, stderr: base.stderr }
|
package/src/device/device.mjs
CHANGED
|
@@ -36,7 +36,7 @@ export async function openDevice({ selection, transport, host = '', port = '', e
|
|
|
36
36
|
if (!selection.usbSerial && !port) {
|
|
37
37
|
fail(`Board '${selection.boardName || selection.target}' has no transports.usbSerial.serial; use --transport wifi or add the USB serial.`, ExitCode.usage)
|
|
38
38
|
}
|
|
39
|
-
const devicePath = await waitForSerialPort({ port, serial: selection.usbSerial, timeoutSeconds: waitSeconds, label: 'USB serial port', log: stderr })
|
|
39
|
+
const devicePath = await waitForSerialPort({ port, serial: selection.usbSerial, timeoutSeconds: waitSeconds, label: 'USB serial port', log: stderr, env })
|
|
40
40
|
const serial = await SerialDevice.open({ path: devicePath, baudRate: serialBaudRate(selection, env), trace, stderr })
|
|
41
41
|
return new UsbDevice(serial, { stderr })
|
|
42
42
|
}
|
package/src/device/serial.mjs
CHANGED
|
@@ -92,13 +92,47 @@ export class SerialDevice {
|
|
|
92
92
|
|
|
93
93
|
async writeLine(line) {
|
|
94
94
|
const data = `${line.replace(/[\r\n]+$/, '')}\n`
|
|
95
|
-
await
|
|
96
|
-
await new Promise((resolve) => this.port.drain(() => resolve()))
|
|
95
|
+
await this.writeRaw(data)
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
async writeRaw(data) {
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if (this.error) throw this.error
|
|
100
|
+
if (this.closed) throw new Error(`serial device ${this.path} is closed`)
|
|
101
|
+
// A USB removal can leave write/drain callbacks permanently pending.
|
|
102
|
+
// Keep a referenced deadline and reject on lifecycle events so callers can
|
|
103
|
+
// still release remote resources when the physical transport disappears.
|
|
104
|
+
await new Promise((resolve, reject) => {
|
|
105
|
+
let settled = false
|
|
106
|
+
const finish = (error) => {
|
|
107
|
+
if (settled) return
|
|
108
|
+
settled = true
|
|
109
|
+
clearTimeout(timer)
|
|
110
|
+
this.port.removeListener('close', closed)
|
|
111
|
+
this.port.removeListener('error', failed)
|
|
112
|
+
if (error) reject(error)
|
|
113
|
+
else resolve()
|
|
114
|
+
}
|
|
115
|
+
const closed = () => finish(new Error(`serial device ${this.path} closed during write`))
|
|
116
|
+
const failed = (error) => finish(error)
|
|
117
|
+
const timer = setTimeout(() => finish(new Error(`serial write timed out for ${this.path}`)), 5000)
|
|
118
|
+
this.port.once('close', closed)
|
|
119
|
+
this.port.once('error', failed)
|
|
120
|
+
try {
|
|
121
|
+
this.port.write(data, (error) => {
|
|
122
|
+
if (settled) return
|
|
123
|
+
if (error) finish(error)
|
|
124
|
+
else {
|
|
125
|
+
try {
|
|
126
|
+
this.port.drain((error) => finish(error))
|
|
127
|
+
} catch (error) {
|
|
128
|
+
finish(error)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
} catch (error) {
|
|
133
|
+
finish(error)
|
|
134
|
+
}
|
|
135
|
+
})
|
|
102
136
|
}
|
|
103
137
|
|
|
104
138
|
async readLine(timeoutMs) {
|
package/src/esp32/build.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { appCmakeMeta, appCmakeLdFragments, appTargetConfig, appTargetPaths } fr
|
|
|
9
9
|
import { quietSteps, runQuiet } from '../run.mjs'
|
|
10
10
|
import { resolveAppCapabilities, withRendererFeatureDefines } from './capabilities.mjs'
|
|
11
11
|
import { activateEspIdf, idfPyCommand } from './idf-env.mjs'
|
|
12
|
+
import { espIdfVersionForTarget } from './idf-version.mjs'
|
|
12
13
|
import { Sdkconfig, prepareBuildLocalSdkconfig } from './sdkconfig.mjs'
|
|
13
14
|
import { writePartitionTable } from './partitions-from-manifest.mjs'
|
|
14
15
|
import { listAppSources } from './source-set.mjs'
|
|
@@ -48,15 +49,19 @@ export function buildImages(buildDir) {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
export function requireEspIdf(env, log) {
|
|
52
|
+
export function requireEspIdf(env, log, selection = null) {
|
|
53
|
+
const defaultVersion = espIdfVersionForTarget(selection?.target)
|
|
52
54
|
let idf
|
|
53
55
|
try {
|
|
54
|
-
idf = activateEspIdf({ env, log })
|
|
56
|
+
idf = activateEspIdf({ env, log, defaultVersion })
|
|
55
57
|
} catch (error) {
|
|
56
58
|
fail(error.message, ExitCode.missingDependency)
|
|
57
59
|
}
|
|
58
60
|
if (!idf) {
|
|
59
|
-
fail(
|
|
61
|
+
fail(
|
|
62
|
+
`ESP-IDF ${defaultVersion} was not found${selection?.target ? ` for target '${selection.target}'` : ''}. Install it under ~/esp32/esp-idf-v${defaultVersion} and run its install.sh (install.bat on Windows), or set IDF_PATH to another installation.`,
|
|
63
|
+
ExitCode.missingDependency
|
|
64
|
+
)
|
|
60
65
|
}
|
|
61
66
|
return idf
|
|
62
67
|
}
|
|
@@ -549,7 +554,7 @@ function runInTarget(command, args, { cwd, env, dryRun, verbose, label, logFile,
|
|
|
549
554
|
// system's responsibility. This retains Ninja's sub-second no-op.
|
|
550
555
|
export async function ensureConfigured({ idf, prepared, env, dryRun = false, verbose = false, stdout, stderr = console.error }) {
|
|
551
556
|
const signatureFile = path.join(prepared.buildDir, '.gea-configure-args')
|
|
552
|
-
const signature = [`-DSDKCONFIG=${prepared.sdkconfigFile}`, `-DSDKCONFIG_DEFAULTS=${prepared.defaultsArg || prepared.defaultsFile}`, ...prepared.idfArgs, ...(prepared.sourceSet || [])].join('\n') + '\n'
|
|
557
|
+
const signature = [`IDF_PATH=${idf.idfDir}`, `IDF_PYTHON_ENV_PATH=${idf.pythonEnv}`, `-DSDKCONFIG=${prepared.sdkconfigFile}`, `-DSDKCONFIG_DEFAULTS=${prepared.defaultsArg || prepared.defaultsFile}`, ...prepared.idfArgs, ...(prepared.sourceSet || [])].join('\n') + '\n'
|
|
553
558
|
if (existsSync(path.join(prepared.buildDir, 'CMakeCache.txt')) && existsSync(signatureFile) && readFileSync(signatureFile, 'utf8') === signature) {
|
|
554
559
|
return false
|
|
555
560
|
}
|
|
@@ -623,7 +628,7 @@ export async function buildEsp32Firmware({ ctx, selection, app = null, env = ctx
|
|
|
623
628
|
// dim line; the spinner labels name each phase.
|
|
624
629
|
const quiet = quietSteps(env, verbose)
|
|
625
630
|
const detail = quiet ? () => {} : stdout
|
|
626
|
-
const idf = requireEspIdf(env, detail)
|
|
631
|
+
const idf = requireEspIdf(env, detail, selection)
|
|
627
632
|
const prepared = prepareEsp32Build({ ctx, selection, app, env: idf.env, log: detail, bleOta, dryRun })
|
|
628
633
|
prepared.targetDir = selection.targetDir
|
|
629
634
|
if (quiet) hint(stdout, buildSummaryLine(idf, selection, prepared.capabilities))
|
|
@@ -101,7 +101,9 @@ export function withRendererFeatureDefines(defines, features, { devicePixelRatio
|
|
|
101
101
|
// An older plugin knows nothing about renderer features. Absence without the
|
|
102
102
|
// version marker is not proof of unreachability: retain engine defaults.
|
|
103
103
|
const generatedNames = new Set([...rendererFeatureDefines, ...cssFeatureVersions.flat(), ...nodeFeatureDefines, ...nodeAuxFeatureDefines, ...compactStyleDefines].map(([, name]) => name).concat(triangleOcclusionMacro, circleCacheMacros, rangeFamilies.map(rangeMacro), ['GEA_UI_CLASS_INLINE_TOKENS', 'GEA_UI_CLASS_OVERFLOW']))
|
|
104
|
+
generatedNames.add('GEA_RUNTIME_REALMS')
|
|
104
105
|
const result = defines.split(';').filter((define) => define && !generatedNames.has(define.split('=')[0]))
|
|
106
|
+
if (features.includes('worker-realms')) result.push('GEA_RUNTIME_REALMS=1')
|
|
105
107
|
if (features.includes('node-analysis-v1')) {
|
|
106
108
|
for (const [feature, name] of nodeFeatureDefines) result.push(`${name}=${features.includes(feature) ? 1 : 0}`)
|
|
107
109
|
}
|
package/src/esp32/flash.mjs
CHANGED
|
@@ -70,7 +70,7 @@ export async function runEsptoolOverUsb({ idf, selection, options, args, port =
|
|
|
70
70
|
}
|
|
71
71
|
const flashPort = dryRun
|
|
72
72
|
? port || `<usb serial ${selection.usbSerial}>`
|
|
73
|
-
: await waitForSerialPort({ port, serial: selection.usbSerial, timeoutSeconds: remaining, label: 'ESP32 USB flash port', log: stderr })
|
|
73
|
+
: await waitForSerialPort({ port, serial: selection.usbSerial, timeoutSeconds: remaining, label: 'ESP32 USB flash port', log: stderr, env })
|
|
74
74
|
if (options.before === 'no-reset') {
|
|
75
75
|
stdout('Manual boot mode: hold BOOT/IO0, reset or power-cycle the board, then keep BOOT held until esptool connects.')
|
|
76
76
|
stdout('Manual boot mode: esptool will not toggle reset before connecting.')
|
package/src/esp32/idf-env.mjs
CHANGED
|
@@ -43,13 +43,38 @@ function compareVersions(a, b) {
|
|
|
43
43
|
return 0
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
// A checkout of an unreleased IDF line (master, a release candidate) is named
|
|
47
|
+
// for it: `esp-idf-v6.2-dev`, `esp-idf-v6.1-rc1`. Its version.cmake already
|
|
48
|
+
// reads like the release, so the name is the only thing that tells it apart.
|
|
49
|
+
function isPrereleaseIdf(dir) {
|
|
50
|
+
return /-(dev|rc\d*|beta\d*|master)$/i.test(path.basename(dir))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function meetsMinimum(dir, minimum) {
|
|
54
|
+
if (!minimum) return true
|
|
55
|
+
const want = minimum.split('.').map((part) => Number(part) || 0)
|
|
56
|
+
return compareVersions(versionKey(dir), [want[0] || 0, want[1] || 0, 0]) >= 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function matchesDefaultVersion(dir, defaultVersion) {
|
|
60
|
+
if (!defaultVersion) return true
|
|
61
|
+
const version = espIdfVersion(dir)
|
|
62
|
+
if (defaultVersion.endsWith('-dev')) {
|
|
63
|
+
return version?.majorMinor === defaultVersion.slice(0, -4) && /-dev$/i.test(path.basename(dir))
|
|
64
|
+
}
|
|
65
|
+
return version?.full === defaultVersion && !isPrereleaseIdf(dir)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Generic discovery honours explicit settings and otherwise prefers the
|
|
69
|
+
// newest stable installation. Callers can request a minimum version instead.
|
|
70
|
+
// Builds provide an exact defaultVersion for automatic discovery. IDF_PATH
|
|
71
|
+
// overrides that default; export-script hints must still match the target.
|
|
72
|
+
export function findEspIdf(env = process.env, home = os.homedir(), { minVersion = '', defaultVersion = '' } = {}) {
|
|
73
|
+
const accepts = (dir) => meetsMinimum(dir, minVersion) && matchesDefaultVersion(dir, defaultVersion)
|
|
74
|
+
if (isIdfDir(env.IDF_PATH) && meetsMinimum(env.IDF_PATH, minVersion)) return path.resolve(env.IDF_PATH)
|
|
75
|
+
const explicit = [envExportDir(env.GEA_EMBEDDED_IDF_EXPORT), envExportDir(env.ESP_IDF_EXPORT)]
|
|
51
76
|
for (const candidate of explicit) {
|
|
52
|
-
if (isIdfDir(candidate)) return path.resolve(candidate)
|
|
77
|
+
if (isIdfDir(candidate) && accepts(candidate)) return path.resolve(candidate)
|
|
53
78
|
}
|
|
54
79
|
const roots = [path.join(home, 'esp'), path.join(home, 'esp32'), home]
|
|
55
80
|
const found = []
|
|
@@ -72,7 +97,9 @@ export function findEspIdf(env = process.env, home = os.homedir()) {
|
|
|
72
97
|
}
|
|
73
98
|
if (found.length === 0) return ''
|
|
74
99
|
found.sort((a, b) => compareVersions(versionKey(b), versionKey(a)))
|
|
75
|
-
return found
|
|
100
|
+
if (defaultVersion) return found.find(accepts) || ''
|
|
101
|
+
if (minVersion) return found.find((dir) => meetsMinimum(dir, minVersion)) || ''
|
|
102
|
+
return found.find((dir) => !isPrereleaseIdf(dir)) || found[0]
|
|
76
103
|
}
|
|
77
104
|
|
|
78
105
|
function envExportDir(exportScript) {
|
|
@@ -92,9 +119,10 @@ export function idfVenvPython(pythonEnv) {
|
|
|
92
119
|
}
|
|
93
120
|
|
|
94
121
|
export function findIdfPythonEnv(idfDir, env = process.env, home = os.homedir()) {
|
|
95
|
-
const explicit = env.IDF_PYTHON_ENV_PATH
|
|
96
|
-
if (explicit && existsSync(idfVenvPython(explicit))) return explicit
|
|
97
122
|
const version = espIdfVersion(idfDir)?.majorMinor
|
|
123
|
+
const explicit = env.IDF_PYTHON_ENV_PATH
|
|
124
|
+
const explicitVersion = explicit && path.basename(explicit).match(/^idf(\d+\.\d+)_py/)?.[1]
|
|
125
|
+
if (explicit && (!explicitVersion || explicitVersion === version) && existsSync(idfVenvPython(explicit))) return explicit
|
|
98
126
|
if (!version) return ''
|
|
99
127
|
const envRoot = path.join(env.IDF_TOOLS_PATH || path.join(home, '.espressif'), 'python_env')
|
|
100
128
|
let entries = []
|
|
@@ -130,10 +158,15 @@ const activationCache = new Map()
|
|
|
130
158
|
// The tool export is cached per installation; the caller's environment is
|
|
131
159
|
// layered on fresh every time so per-invocation settings (jobs, variants,
|
|
132
160
|
// flash baud) are never frozen into a cached activation.
|
|
133
|
-
export function activateEspIdf({ env = process.env, home = os.homedir(), log = () => {} } = {}) {
|
|
134
|
-
const idfDir = findEspIdf(env, home)
|
|
161
|
+
export function activateEspIdf({ env = process.env, home = env.HOME || env.USERPROFILE || os.homedir(), log = () => {}, minVersion = '', defaultVersion = '' } = {}) {
|
|
162
|
+
const idfDir = findEspIdf(env, home, { minVersion, defaultVersion })
|
|
135
163
|
if (!idfDir) return null
|
|
136
|
-
|
|
164
|
+
// A venv exported by a different active checkout belongs to that checkout.
|
|
165
|
+
const activeIdf = env.IDF_PATH || envExportDir(env.GEA_EMBEDDED_IDF_EXPORT) || envExportDir(env.ESP_IDF_EXPORT)
|
|
166
|
+
const pythonEnvSettings = defaultVersion && activeIdf && path.resolve(activeIdf) !== idfDir
|
|
167
|
+
? { ...env, IDF_PYTHON_ENV_PATH: '' }
|
|
168
|
+
: env
|
|
169
|
+
const pythonEnv = findIdfPythonEnv(idfDir, pythonEnvSettings, home)
|
|
137
170
|
if (!pythonEnv) {
|
|
138
171
|
const envRoot = path.join(env.IDF_TOOLS_PATH || path.join(home, '.espressif'), 'python_env')
|
|
139
172
|
throw new Error(
|
|
@@ -149,7 +182,7 @@ export function activateEspIdf({ env = process.env, home = os.homedir(), log = (
|
|
|
149
182
|
exported = parseKeyValueExport(
|
|
150
183
|
execFileSync(python, [idfToolsPy, 'export', '--format', 'key-value'], {
|
|
151
184
|
encoding: 'utf8',
|
|
152
|
-
env: { ...env, IDF_PATH: idfDir },
|
|
185
|
+
env: { ...env, IDF_PATH: idfDir, IDF_PYTHON_ENV_PATH: pythonEnv },
|
|
153
186
|
stdio: ['ignore', 'pipe', 'ignore']
|
|
154
187
|
})
|
|
155
188
|
)
|
|
@@ -157,8 +190,8 @@ export function activateEspIdf({ env = process.env, home = os.homedir(), log = (
|
|
|
157
190
|
throw new Error(`ESP-IDF tool export failed for ${idfDir}: ${error.message}`)
|
|
158
191
|
}
|
|
159
192
|
activationCache.set(cacheKey, exported)
|
|
160
|
-
log(`Using ESP-IDF ${espIdfVersion(idfDir)?.full || ''} at ${idfDir} (python env ${pythonEnv})`)
|
|
161
193
|
}
|
|
194
|
+
log(`Using ESP-IDF ${espIdfVersion(idfDir)?.full || ''} at ${idfDir} (python env ${pythonEnv})`)
|
|
162
195
|
const callerPath = envPath(env)
|
|
163
196
|
const exportedPath = (exported.PATH || '').replace(/\$PATH|%PATH%/g, callerPath)
|
|
164
197
|
return {
|
|
@@ -15,6 +15,11 @@ const VERSION_IN_TEXT = /v?(\d+)\.(\d+)\.(\d+)/i
|
|
|
15
15
|
// Bump this alongside board-script updates.
|
|
16
16
|
export const DEFAULT_ESP_IDF_VERSION = 'v6.0.2'
|
|
17
17
|
|
|
18
|
+
// Automatic build selection is target-specific; IDF_PATH can override it.
|
|
19
|
+
export function espIdfVersionForTarget(target) {
|
|
20
|
+
return target === 'esp32-s31-espressif-mosaico' ? '6.2-dev' : DEFAULT_ESP_IDF_VERSION.slice(1)
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
const GITHUB_LATEST_RELEASE_URL = 'https://api.github.com/repos/espressif/esp-idf/releases/latest'
|
|
19
24
|
|
|
20
25
|
// Parses a strict `vX.Y.Z` release tag. Returns null for anything else,
|
package/NOTICE
DELETED