Skip to content

Commit

Permalink
fix: sides now flash without instabilities (#452)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Parcet <[email protected]>
  • Loading branch information
AlexDygma authored Jun 26, 2023
1 parent 0e72cc1 commit 231af48
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/api/flash/defyFlasher/sideFlasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class sideFlaser {
for (let i = 0; i < this.firmwareSides.length; i = i + 256) {
// console.log(`Addres ${i} of ${this.firmwareSides.length}`);
serialport.write("upgrade.keyscanner.sendWrite ");
if (wiredOrWireless == "wireless") await sleep(2);
if (wiredOrWireless == "wireless") await sleep(4);
const writeAction = new Uint8Array(new Uint32Array([info.flashStart + i, 256]).buffer);
const data = this.firmwareSides.slice(i, i + 256);
const crc = new Uint8Array(new Uint32Array([crc32("CRC-32", data)]).buffer);
Expand All @@ -159,20 +159,32 @@ export default class sideFlaser {
// console.log("write sent: ", buffer);
// console.log("write sent, %", (step / totalsteps) * 100);
serialport.write(buffer);
if (wiredOrWireless == "wireless") await sleep(2);
await readLine();
if (wiredOrWireless == "wireless") await sleep(4);
let ack = await readLine();
ack = ack + (await readLine());
// console.log("ack received: ", ack);
if (ack.trim() === "false") {
break;
if (!ack.includes("true") || ack.includes("false")) {
let retries = 3;
while (retries > 0 && (!ack.includes("true") || ack.includes("false"))) {
if (wiredOrWireless == "wireless") sleep(1000);
serialport.write("upgrade.keyscanner.sendWrite ");
if (wiredOrWireless == "wireless") sleep(10);
serialport.write(buffer);
if (wiredOrWireless == "wireless") sleep(10);
ack = await readLine();
ack = ack + (await readLine());
console.log(`received ${ack} after ${3 - retries} retires`);
retries--;
}
}
stateUpd(side, (step / totalsteps) * 100);
step++;
// }
}
serialport.write("upgrade.keyscanner.validate\n");
await readLine();
validate = await readLine();
validate = validate + (await readLine());
console.log("result of validation", validate);
// retry++;
// }

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/controller/FlashingSM/FWSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const FocusAPIRead = async () => {
let data = {};
try {
let focus = new Focus();
data.bootloader = focus.device.bootloader;
data.bootloader = focus.device ? focus.device.bootloader : false;
data.info = focus.device.info;
if (data.bootloader) return data;
data.version = await focus.command("version");
Expand Down

0 comments on commit 231af48

Please sign in to comment.