diff --git a/package.json b/package.json index 50f195cd..ccb9f288 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#52021f0b1ace58673ebca1fae740f6900ebff707", + "@commaai/qdl": "git+https://github.com/commaai/qdl.js.git#9ef437bed19a70fe54f44421ae5fc9a057b4b563", "@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5", "react": "^18.3.1", diff --git a/src/QDL/programmer.bin b/src/QDL/programmer.bin index d10d768a..6cb65c8f 100644 Binary files a/src/QDL/programmer.bin and b/src/QDL/programmer.bin differ diff --git a/src/app/Flash.jsx b/src/app/Flash.jsx index 7b3ad764..36ae7e7c 100644 --- a/src/app/Flash.jsx +++ b/src/app/Flash.jsx @@ -189,7 +189,7 @@ export default function Flash() { .then((res) => res.arrayBuffer()) .then((programmer) => { // Create QDL manager with callbacks that update React state - qdlManager.current = new FlashManager(config.manifests.release, programmer, { + qdlManager.current = new FlashManager(programmer, { onStepChange: setStep, onMessageChange: setMessage, onProgressChange: setProgress, diff --git a/src/config.js b/src/config.js index 41cf34a7..5d760dae 100644 --- a/src/config.js +++ b/src/config.js @@ -1,6 +1,7 @@ const config = { manifests: { - release: 'https://raw.githubusercontent.com/commaai/openpilot/927548621be1be0c2c9063868b93d1f5020904de/system/hardware/tici/all-partitions.json', + release_tizi: 'https://raw.githubusercontent.com/commaai/openpilot/927548621be1be0c2c9063868b93d1f5020904de/system/hardware/tici/all-partitions.json', + release_tici: 'https://raw.githubusercontent.com/commaai/openpilot/927548621be1be0c2c9063868b93d1f5020904de/system/hardware/tici/all-partitions.json', master: 'https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/all-partitions.json', }, loader: { diff --git a/src/utils/manager.js b/src/utils/manager.js index f148b321..23447e54 100644 --- a/src/utils/manager.js +++ b/src/utils/manager.js @@ -2,6 +2,7 @@ import { qdlDevice } from '@commaai/qdl' import { usbClass } from '@commaai/qdl/usblib' import { getManifest } from './manifest' +import config from '../config' import { createSteps, withProgress } from './progress' export const StepCode = { @@ -95,8 +96,8 @@ export class FlashManager { * @param {ArrayBuffer} programmer * @param {FlashManagerCallbacks} callbacks */ - constructor(manifestUrl, programmer, callbacks = {}) { - this.manifestUrl = manifestUrl + constructor(programmer, callbacks = {}) { + this.manifestUrl = null this.callbacks = callbacks this.device = new qdlDevice(programmer) /** @type {import('./image').ImageManager|null} */ @@ -189,21 +190,6 @@ export class FlashManager { return } - if (!this.manifest?.length) { - try { - this.manifest = await getManifest(this.manifestUrl) - if (this.manifest.length === 0) { - throw new Error('Manifest is empty') - } - } catch (err) { - console.error('[Flash] Failed to fetch manifest') - console.error(err) - this.#setError(ErrorCode.UNKNOWN) - return - } - console.info('[Flash] Loaded manifest', this.manifest) - } - this.#setStep(StepCode.READY) } @@ -233,6 +219,35 @@ export class FlashManager { console.info('[Flash] Connected') this.#setConnected(true) + try { + const deviceType = await this.device.getDeviceType() + if (deviceType == 32) { + this.manifestUrl = config.manifests.release_tici + } else { + this.manifestUrl = config.manifests.release_tizi + } + + try { + this.manifest = await getManifest(this.manifestUrl) + if (this.manifest.length === 0) { + throw new Error('Manifest is empty') + } + } catch (err) { + console.error('[Flash] Failed to fetch manifest') + console.error(err) + this.#setConnected(false) + this.#setError(ErrorCode.UNKNOWN) + return + } + console.info('[Flash] Loaded manifest', this.manifest) + + } catch (err) { + console.error('[Flash] Connection lost', err) + this.#setError(ErrorCode.LOST_CONNECTION) + this.#setConnected(false) + return + } + let storageInfo try { storageInfo = await this.device.getStorageInfo()