From ff00b7dc18765d0a0d3d1ea504f587e3cc5badb9 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 26 Dec 2025 12:22:29 -0800 Subject: [PATCH 1/6] bump qdl.js --- bun.lock | 4 ++-- deploy-preview.sh | 1 + package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bun.lock b/bun.lock index d76cbb66..2eaf4747 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "@commaai/flash", "dependencies": { - "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#21d7be79fa5178f253d32a0879bd8bdd4fa37e30", + "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#6ff80673f8c3e9c66b1ce088ae93c7e5360cc588", "@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5", "react": "^18.3.1", @@ -81,7 +81,7 @@ "@babel/types": ["@babel/types@7.28.5", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA=="], - "@commaai/qdl": ["@commaai/qdl@github:commaai/qdl.js#21d7be7", { "dependencies": { "@incognitojam/tiny-struct": "npm:@jsr/incognitojam__tiny-struct@^0.1.2", "arg": "^5.0.2", "crc-32": "^1.2.2", "fast-xml-parser": "^5.0.8", "usb": "^2.15.0" }, "peerDependencies": { "typescript": "^5.7.3" }, "bin": { "simg2img.js": "dist/bin/simg2img.js", "qdl.js": "dist/bin/qdl.js" } }, "commaai-qdl.js-21d7be7"], + "@commaai/qdl": ["@commaai/qdl@github:commaai/qdl.js#6ff8067", { "dependencies": { "@incognitojam/tiny-struct": "npm:@jsr/incognitojam__tiny-struct@^0.1.2", "arg": "^5.0.2", "crc-32": "^1.2.2", "fast-xml-parser": "^5.0.8", "usb": "^2.15.0" }, "peerDependencies": { "typescript": "^5.7.3" }, "bin": { "simg2img.js": "dist/bin/simg2img.js", "qdl.js": "dist/bin/qdl.js" } }, "commaai-qdl.js-6ff8067"], "@csstools/color-helpers": ["@csstools/color-helpers@5.1.0", "", {}, "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA=="], diff --git a/deploy-preview.sh b/deploy-preview.sh index fc035f67..9716b669 100755 --- a/deploy-preview.sh +++ b/deploy-preview.sh @@ -3,6 +3,7 @@ set -e BRANCH="${1:-$(git branch --show-current)}" +bun install bun run build bunx wrangler pages deploy dist --project-name=connect --branch="$BRANCH" diff --git a/package.json b/package.json index 73aed3a3..d5480c58 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=20.11.0" }, "dependencies": { - "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#21d7be79fa5178f253d32a0879bd8bdd4fa37e30", + "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#6ff80673f8c3e9c66b1ce088ae93c7e5360cc588", "@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5", "react": "^18.3.1", From 4fe40acd4c40d8cd7d54eb90e7034452a49d4075 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 26 Dec 2025 12:36:01 -0800 Subject: [PATCH 2/6] flash one system --- src/utils/manager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/manager.js b/src/utils/manager.js index 618ff8db..2d137759 100644 --- a/src/utils/manager.js +++ b/src/utils/manager.js @@ -392,17 +392,17 @@ export class FlashManager { try { for await (const image of systemImages) { - const [onDownload, onFlash] = createSteps([1, image.hasAB ? 2 : 1], this.#setProgress.bind(this)) + // Flash system to slot A only (large, slow), other A/B partitions to both slots + const flashBothSlots = image.hasAB && image.name !== 'system' + const [onDownload, onFlash] = createSteps([1, flashBothSlots ? 2 : 1], this.#setProgress.bind(this)) this.#setMessage(`Downloading ${image.name}`) await this.imageManager.downloadImage(image, onDownload) const blob = await this.imageManager.getImage(image) onDownload(1.0) - // Flash image to each slot - const slots = image.hasAB ? ['_a', '_b'] : [''] + const slots = flashBothSlots ? ['_a', '_b'] : (image.hasAB ? ['_a'] : ['']) for (const [slot, onSlotProgress] of withProgress(slots, onFlash)) { - // NOTE: userdata image name does not match partition name const partitionName = `${image.name.startsWith('userdata_') ? 'userdata' : image.name}${slot}` this.#setMessage(`Flashing ${partitionName}`) From 9a1a4c11c8573afdcf067ffb1cf1e1eb8c9101b2 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 26 Dec 2025 12:44:13 -0800 Subject: [PATCH 3/6] fix set slot fail --- src/utils/manager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/manager.js b/src/utils/manager.js index 2d137759..98aadcf3 100644 --- a/src/utils/manager.js +++ b/src/utils/manager.js @@ -428,6 +428,7 @@ export class FlashManager { if (!await this.device.setActiveSlot('a')) { console.error('[Flash] Failed to update slot') this.#setError(ErrorCode.FINALIZING_FAILED) + return } // Reboot the device From 5d22b205144c951fa978971c8d727a6cd0c96ec0 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 26 Dec 2025 12:55:34 -0800 Subject: [PATCH 4/6] lil more --- .gitignore | 2 ++ bun.lock | 4 ++-- package.json | 2 +- src/utils/manager.js | 6 ++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 08c27c0c..a2dbc283 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +/qdl.js/ diff --git a/bun.lock b/bun.lock index 2eaf4747..1c1abd37 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "@commaai/flash", "dependencies": { - "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#6ff80673f8c3e9c66b1ce088ae93c7e5360cc588", + "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#ef82d1e517cbd7da0f816a6cf1f576841b66d63c", "@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5", "react": "^18.3.1", @@ -81,7 +81,7 @@ "@babel/types": ["@babel/types@7.28.5", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA=="], - "@commaai/qdl": ["@commaai/qdl@github:commaai/qdl.js#6ff8067", { "dependencies": { "@incognitojam/tiny-struct": "npm:@jsr/incognitojam__tiny-struct@^0.1.2", "arg": "^5.0.2", "crc-32": "^1.2.2", "fast-xml-parser": "^5.0.8", "usb": "^2.15.0" }, "peerDependencies": { "typescript": "^5.7.3" }, "bin": { "simg2img.js": "dist/bin/simg2img.js", "qdl.js": "dist/bin/qdl.js" } }, "commaai-qdl.js-6ff8067"], + "@commaai/qdl": ["@commaai/qdl@github:commaai/qdl.js#ef82d1e", { "dependencies": { "@incognitojam/tiny-struct": "npm:@jsr/incognitojam__tiny-struct@^0.1.2", "arg": "^5.0.2", "crc-32": "^1.2.2", "fast-xml-parser": "^5.0.8", "usb": "^2.15.0" }, "peerDependencies": { "typescript": "^5.7.3" }, "bin": { "simg2img.js": "dist/bin/simg2img.js", "qdl.js": "dist/bin/qdl.js" } }, "commaai-qdl.js-ef82d1e"], "@csstools/color-helpers": ["@csstools/color-helpers@5.1.0", "", {}, "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA=="], diff --git a/package.json b/package.json index d5480c58..a2c3255d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=20.11.0" }, "dependencies": { - "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#6ff80673f8c3e9c66b1ce088ae93c7e5360cc588", + "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#ef82d1e517cbd7da0f816a6cf1f576841b66d63c", "@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5", "react": "^18.3.1", diff --git a/src/utils/manager.js b/src/utils/manager.js index 98aadcf3..2733678b 100644 --- a/src/utils/manager.js +++ b/src/utils/manager.js @@ -425,8 +425,10 @@ export class FlashManager { this.#setMessage('Finalizing...') // Set bootable LUN and update active partitions - if (!await this.device.setActiveSlot('a')) { - console.error('[Flash] Failed to update slot') + try { + await this.device.setActiveSlot('a') + } catch (err) { + console.error('[Flash] Failed to update slot', err) this.#setError(ErrorCode.FINALIZING_FAILED) return } From 032200a55051351a4288063a6e75a1f8dc25eb21 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 26 Dec 2025 13:54:13 -0800 Subject: [PATCH 5/6] don't set the slot --- .gitignore | 2 ++ bun.lock | 4 ++-- package.json | 2 +- src/utils/manager.js | 7 ++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a2dbc283..9e045450 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,6 @@ yarn-error.log* *.tsbuildinfo next-env.d.ts +/edl/ /qdl.js/ +/provisioning/ diff --git a/bun.lock b/bun.lock index 1c1abd37..55714d56 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "@commaai/flash", "dependencies": { - "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#ef82d1e517cbd7da0f816a6cf1f576841b66d63c", + "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#7177fde779bc6764727130969af1841d71a4c43c", "@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5", "react": "^18.3.1", @@ -81,7 +81,7 @@ "@babel/types": ["@babel/types@7.28.5", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA=="], - "@commaai/qdl": ["@commaai/qdl@github:commaai/qdl.js#ef82d1e", { "dependencies": { "@incognitojam/tiny-struct": "npm:@jsr/incognitojam__tiny-struct@^0.1.2", "arg": "^5.0.2", "crc-32": "^1.2.2", "fast-xml-parser": "^5.0.8", "usb": "^2.15.0" }, "peerDependencies": { "typescript": "^5.7.3" }, "bin": { "simg2img.js": "dist/bin/simg2img.js", "qdl.js": "dist/bin/qdl.js" } }, "commaai-qdl.js-ef82d1e"], + "@commaai/qdl": ["@commaai/qdl@github:commaai/qdl.js#7177fde", { "dependencies": { "@incognitojam/tiny-struct": "npm:@jsr/incognitojam__tiny-struct@^0.1.2", "arg": "^5.0.2", "crc-32": "^1.2.2", "fast-xml-parser": "^5.0.8", "usb": "^2.15.0" }, "peerDependencies": { "typescript": "^5.7.3" }, "bin": { "simg2img.js": "dist/bin/simg2img.js", "qdl.js": "dist/bin/qdl.js" } }, "commaai-qdl.js-7177fde"], "@csstools/color-helpers": ["@csstools/color-helpers@5.1.0", "", {}, "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA=="], diff --git a/package.json b/package.json index a2c3255d..adaa696d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=20.11.0" }, "dependencies": { - "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#ef82d1e517cbd7da0f816a6cf1f576841b66d63c", + "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#7177fde779bc6764727130969af1841d71a4c43c", "@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5", "react": "^18.3.1", diff --git a/src/utils/manager.js b/src/utils/manager.js index 2733678b..4c6b2f25 100644 --- a/src/utils/manager.js +++ b/src/utils/manager.js @@ -424,11 +424,12 @@ export class FlashManager { this.#setProgress(-1) this.#setMessage('Finalizing...') - // Set bootable LUN and update active partitions + // Set bootable LUN to slot A (LUN 1) + // GPT images already have correct A/B flags, no need to manipulate them try { - await this.device.setActiveSlot('a') + await this.device.setBootableLun(1) } catch (err) { - console.error('[Flash] Failed to update slot', err) + console.error('[Flash] Failed to set bootable LUN', err) this.#setError(ErrorCode.FINALIZING_FAILED) return } From b3186ab9831fa6da32696f324bad21e25e4d20ab Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 26 Dec 2025 14:05:55 -0800 Subject: [PATCH 6/6] debug --- src/app/Flash.jsx | 92 +++++++++++++++++++++++++++++++++++++++++++- src/utils/manager.js | 84 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 1 deletion(-) diff --git a/src/app/Flash.jsx b/src/app/Flash.jsx index 07324745..fa836b1e 100644 --- a/src/app/Flash.jsx +++ b/src/app/Flash.jsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from 'react' -import { FlashManager, StepCode, ErrorCode, DeviceType } from '../utils/manager' +import { FlashManager, StepCode, ErrorCode, DeviceType, DUMP_GPT_MODE } from '../utils/manager' import { useImageManager } from '../utils/image' import { isLinux, isWindows } from '../utils/platform' import config from '../config' @@ -517,6 +517,91 @@ function LinuxUnbind({ onNext }) { ) } +// GPT Dump diagnostic mode +function GptDumpMode({ qdlManager, imageManager }) { + const [gptDump, setGptDump] = useState(null) + const [loading, setLoading] = useState(false) + const [copied, setCopied] = useState(false) + const [ready, setReady] = useState(false) + + useEffect(() => { + if (!imageManager.current) return + fetch(config.loader.url) + .then((res) => res.arrayBuffer()) + .then((programmer) => { + qdlManager.current = new FlashManager(programmer, {}) + qdlManager.current.initialize(imageManager.current).then(() => setReady(true)) + }) + }, [imageManager.current]) + + const handleDump = async () => { + setLoading(true) + const result = await qdlManager.current.dumpGpt() + setGptDump(result) + setLoading(false) + } + + const handleCopy = () => { + navigator.clipboard.writeText(gptDump) + setCopied(true) + setTimeout(() => setCopied(false), 2000) + } + + return ( +
+
+

GPT Diagnostic Mode

+

+ Connect your device to dump partition table info +

+
+ + {!gptDump ? ( + + ) : ( + <> +