Skip to content

Commit 9cc0fce

Browse files
committed
readme
1 parent 26dbc40 commit 9cc0fce

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ bun dev
1414
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
1515

1616
You can start editing the page by modifying `src/app/index.jsx`. The page auto-updates as you edit the file.
17+
18+
**Helpful for debugging**
19+
* [chrome://usb-internals/](chrome://usb-internals/)
20+
* [chrome://device-log/](chrome://device-log/)

src/app/Flash.jsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ const errors = {
119119
},
120120
}
121121

122-
if (isLinux) {
123-
// this is likely in StepCode.CONNECTING
124-
errors[ErrorCode.LOST_CONNECTION].description += ' Did you forget to unbind the device from qcserial?'
125-
}
122+
// Note: qcserial unbind hint is added dynamically in the component based on device type
126123

127124

128125
function LinearProgress({ value, barColor }) {
@@ -307,15 +304,21 @@ function ConnectInstructions({ deviceType, onNext }) {
307304

308305
<ol className="text-left space-y-3 text-lg dark:text-white">
309306
<li className="flex gap-3">
310-
<span className="flex-shrink-0 w-7 h-7 rounded-full bg-[#51ff00] text-black flex items-center justify-center font-bold text-sm">1</span>
311-
<span>Unplug the device and wait for the LED to switch off</span>
307+
<span className="flex-shrink-0 w-7 h-7 rounded-full bg-[#51ff00] text-black flex items-center justify-center font-bold text-sm">a</span>
308+
<span>Unplug the device</span>
312309
</li>
310+
{!isCommaFour && (
311+
<li className="flex gap-3">
312+
<span className="flex-shrink-0 w-7 h-7 rounded-full bg-[#51ff00] text-black flex items-center justify-center font-bold text-sm">b</span>
313+
<span>Wait for the light on the back to fully turn off</span>
314+
</li>
315+
)}
313316
<li className="flex gap-3">
314-
<span className="flex-shrink-0 w-7 h-7 rounded-full bg-[#51ff00] text-black flex items-center justify-center font-bold text-sm">2</span>
317+
<span className="flex-shrink-0 w-7 h-7 rounded-full bg-[#51ff00] text-black flex items-center justify-center font-bold text-sm">{isCommaFour ? 'b' : 'c'}</span>
315318
<span>Connect the <strong>{isCommaFour ? 'right' : 'lower'}</strong> USB-C port <strong>(port 1)</strong> to your computer</span>
316319
</li>
317320
<li className="flex gap-3">
318-
<span className="flex-shrink-0 w-7 h-7 rounded-full bg-[#51ff00] text-black flex items-center justify-center font-bold text-sm">3</span>
321+
<span className="flex-shrink-0 w-7 h-7 rounded-full bg-[#51ff00] text-black flex items-center justify-center font-bold text-sm">{isCommaFour ? 'c' : 'd'}</span>
319322
<span>Connect power to the <strong>{isCommaFour ? 'left' : 'upper'}</strong> port <strong>(port 2)</strong></span>
320323
</li>
321324
</ol>
@@ -489,6 +492,14 @@ export default function Flash() {
489492
})
490493
}, [config, imageManager.current])
491494

495+
// Transition to flash screen when connected
496+
useEffect(() => {
497+
if (connected && (wizardScreen === 'connect' || wizardScreen === 'unbind')) {
498+
setWizardScreen('flash')
499+
setWizardStep(getStepIndex('Flash'))
500+
}
501+
}, [connected, wizardScreen])
502+
492503
// Handle user clicking start on landing page
493504
const handleStart = () => {
494505
setStep(StepCode.DEVICE_PICKER)
@@ -521,17 +532,14 @@ export default function Flash() {
521532
setWizardScreen('unbind')
522533
setWizardStep(getStepIndex('Unbind'))
523534
} else {
524-
// Go directly to flash (show WebUSB picker)
525-
setWizardScreen('flash')
526-
setWizardStep(getStepIndex('Flash'))
535+
// Start connection - stay on connect screen until connected
527536
qdlManager.current?.start()
528537
}
529538
}
530539

531540
// Handle linux unbind done
532541
const handleUnbindDone = () => {
533-
setWizardScreen('flash')
534-
setWizardStep(getStepIndex('Flash'))
542+
// Start connection - stay on unbind screen until connected
535543
qdlManager.current?.start()
536544
}
537545

@@ -603,11 +611,17 @@ export default function Flash() {
603611
)
604612
}
605613

614+
606615
const uiState = steps[step] || {}
607616
if (error) {
608617
Object.assign(uiState, errors[ErrorCode.UNKNOWN], errors[error])
609618
}
610-
const { status, description, bgColor = 'bg-gray-400', icon = bolt, iconStyle = 'invert' } = uiState
619+
let { status, description, bgColor = 'bg-gray-400', icon = bolt, iconStyle = 'invert' } = uiState
620+
621+
// Add qcserial hint for Linux + comma 3/3X only
622+
if (error === ErrorCode.LOST_CONNECTION && isLinux && selectedDevice === DeviceType.COMMA_3) {
623+
description += ' Did you forget to unbind the device from qcserial?'
624+
}
611625

612626
let title
613627
if (message && !error) {

src/utils/manager.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ export class FlashManager {
217217
try {
218218
await this.device.connect(usb)
219219
} catch (err) {
220+
// User cancelled the WebUSB dialog or no device was selected - not an error
221+
if (err.name === 'NotFoundError') {
222+
console.info('[Flash] No device selected')
223+
this.#setStep(StepCode.READY)
224+
return
225+
}
220226
console.error('[Flash] Connection error', err)
221227
this.#setError(ErrorCode.LOST_CONNECTION)
222228
this.#setConnected(false)
@@ -421,7 +427,8 @@ export class FlashManager {
421427
async start() {
422428
if (this.step !== StepCode.READY) return
423429
await this.#connect()
424-
if (this.error !== ErrorCode.NONE) return
430+
// Check if connection was cancelled (step went back to READY) or failed
431+
if (this.step === StepCode.READY || this.error !== ErrorCode.NONE) return
425432
let start = performance.now()
426433
await this.#repairPartitionTables()
427434
console.info(`Repaired partition tables in ${((performance.now() - start) / 1000).toFixed(2)}s`)

0 commit comments

Comments
 (0)