Skip to content

Commit

Permalink
auto upload loader
Browse files Browse the repository at this point in the history
  • Loading branch information
bongbui321 committed Mar 19, 2024
1 parent ecca939 commit 663954f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Binary file removed 6000000000010000_f8ab20526358c4fa_fhprg.bin
Binary file not shown.
20 changes: 16 additions & 4 deletions src/QDL/sahara.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { CommandHandler, cmd_t, sahara_mode_t, status_t, exec_cmd_t } from "./sa
import { concatUint8Array, packGenerator, loadFileFromLocal, readBlobAsBuffer } from "./utils";
import config from "@/config"

let root;

export class Sahara {
cdc;
ch; // CommandHandler
Expand Down Expand Up @@ -156,6 +158,7 @@ export class Sahara {


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

try {
let processed = 0;
//const contentLength = +response.headers.get('Content-Length');
const reader = response.body.getReader();
while (true) {
const { done, value } = await reader.read();
Expand All @@ -192,6 +194,16 @@ export class Sahara {
}
}

async getLoader() {
let fileHandle;
try {
fileHandle = await root.getFileHandle(this.programmer, { create: false })
} catch (e) {
throw `Error getting file handle: ${e}`
}
return await fileHandle.getFile();
}


async uploadLoader(version){
if (!(await this.enterCommandMode(version))) {
Expand All @@ -213,9 +225,9 @@ export class Sahara {
}

console.log("Uploading Programmer...");
// TODO: change to auto download
//let programmer = new Uint8Array(await readBlobAsBuffer(await downloadLoader()));
let programmer = new Uint8Array(await readBlobAsBuffer(await loadFileFromLocal()));
await this.downLoadLoader();
let loaderBlob = await this.getLoader();
let programmer = new Uint8Array(await readBlobAsBuffer(loaderBlob));
if (!(await this.cmdHello(sahara_mode_t.SAHARA_MODE_IMAGE_TX_PENDING, version=version))) {
return "error";
}
Expand Down
4 changes: 2 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const config = {
// release3: 'https://raw.githubusercontent.com/commaai/openpilot/release3/system/hardware/tici/agnos.json',
master: 'https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/agnos.json',
},
edlLoader : {
url: "",
loader: {
url: "https://raw.githubusercontent.com/bkerler/Loaders/main/qualcomm/factory/sdm845_sdm850_sda845/6000000000010000_f8ab20526358c4fa_fhprg.bin",
},
}

Expand Down

0 comments on commit 663954f

Please sign in to comment.