Skip to content

Commit 663954f

Browse files
committed
auto upload loader
1 parent ecca939 commit 663954f

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed
-664 KB
Binary file not shown.

src/QDL/sahara.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { CommandHandler, cmd_t, sahara_mode_t, status_t, exec_cmd_t } from "./sa
22
import { concatUint8Array, packGenerator, loadFileFromLocal, readBlobAsBuffer } from "./utils";
33
import config from "@/config"
44

5+
let root;
6+
57
export class Sahara {
68
cdc;
79
ch; // CommandHandler
@@ -156,6 +158,7 @@ export class Sahara {
156158

157159

158160
async downLoadLoader() {
161+
root = await navigator.storage.getDirectory();
159162
let writable;
160163
try {
161164
const fileHandle = await root.getFileHandle(this.programmer, { create: true });
@@ -172,7 +175,6 @@ export class Sahara {
172175

173176
try {
174177
let processed = 0;
175-
//const contentLength = +response.headers.get('Content-Length');
176178
const reader = response.body.getReader();
177179
while (true) {
178180
const { done, value } = await reader.read();
@@ -192,6 +194,16 @@ export class Sahara {
192194
}
193195
}
194196

197+
async getLoader() {
198+
let fileHandle;
199+
try {
200+
fileHandle = await root.getFileHandle(this.programmer, { create: false })
201+
} catch (e) {
202+
throw `Error getting file handle: ${e}`
203+
}
204+
return await fileHandle.getFile();
205+
}
206+
195207

196208
async uploadLoader(version){
197209
if (!(await this.enterCommandMode(version))) {
@@ -213,9 +225,9 @@ export class Sahara {
213225
}
214226

215227
console.log("Uploading Programmer...");
216-
// TODO: change to auto download
217-
//let programmer = new Uint8Array(await readBlobAsBuffer(await downloadLoader()));
218-
let programmer = new Uint8Array(await readBlobAsBuffer(await loadFileFromLocal()));
228+
await this.downLoadLoader();
229+
let loaderBlob = await this.getLoader();
230+
let programmer = new Uint8Array(await readBlobAsBuffer(loaderBlob));
219231
if (!(await this.cmdHello(sahara_mode_t.SAHARA_MODE_IMAGE_TX_PENDING, version=version))) {
220232
return "error";
221233
}

src/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ const config = {
33
// release3: 'https://raw.githubusercontent.com/commaai/openpilot/release3/system/hardware/tici/agnos.json',
44
master: 'https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/agnos.json',
55
},
6-
edlLoader : {
7-
url: "",
6+
loader: {
7+
url: "https://raw.githubusercontent.com/bkerler/Loaders/main/qualcomm/factory/sdm845_sdm850_sda845/6000000000010000_f8ab20526358c4fa_fhprg.bin",
88
},
99
}
1010

0 commit comments

Comments
 (0)