fix(usb-deployer): add detailed diagnostic logging for sync failures

This commit is contained in:
a2nr 2026-07-17 10:24:39 +07:00
parent 7dd8e5d522
commit 4ec5d4cb92
1 changed files with 6 additions and 0 deletions

View File

@ -420,9 +420,13 @@ export class USBHardwareDeployer implements HardwareDeployer {
console.log(`[USB] INSYNC: 0x${insync[0].toString(16).padStart(2, '0')}`); console.log(`[USB] INSYNC: 0x${insync[0].toString(16).padStart(2, '0')}`);
if (insync[0] === STK_NOSYNC) { if (insync[0] === STK_NOSYNC) {
console.log('[USB] optiboot replied NOSYNC');
throw new Error('optiboot replied NOSYNC'); throw new Error('optiboot replied NOSYNC');
} }
if (insync[0] !== STK_INSYNC) { if (insync[0] !== STK_INSYNC) {
console.log(
`[USB] expected INSYNC 0x${STK_INSYNC.toString(16)}, got 0x${insync[0].toString(16)}`
);
throw new Error( throw new Error(
`expected INSYNC 0x14, got 0x${insync[0].toString(16)}` `expected INSYNC 0x14, got 0x${insync[0].toString(16)}`
); );
@ -475,6 +479,8 @@ export class USBHardwareDeployer implements HardwareDeployer {
result.set(value.subarray(0, copyLen), got); result.set(value.subarray(0, copyLen), got);
got += copyLen; got += copyLen;
} catch (e) { } catch (e) {
const reason = (e as Error).message || 'unknown';
console.log(`[USB] readExact failed at ${got}/${len}: ${reason}`);
/* Drain stale bytes from orphaned reader.read() promise (C1) */ /* Drain stale bytes from orphaned reader.read() promise (C1) */
await this.drainStray(); await this.drainStray();
throw e; throw e;