Skip to content

Commit

Permalink
fix: now local uf2 is copied instead of read
Browse files Browse the repository at this point in the history
Signed-off-by: AlexDygma <[email protected]>
  • Loading branch information
AlexDygma committed Jan 21, 2025
1 parent f6e3815 commit 3335119
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/api/flash/defyFlasher/rp2040-flasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class Rp2040 {
log.info("flashing rp2040 with rom bootloader", this.device);
ipcRenderer.invoke("list-drives").then(result => {
const finalPath = path.join(result, "default.uf2");
// console.log("RESULTS!!!", result, file, " to ", finalPath);
// log.info("RESULTS!!!", result, "default.uf2", " to ", finalPath);
fs.writeFileSync(finalPath, Buffer.from(new Uint8Array(firmware)));
stateUpdate(3, 80);
finished(false, "");
Expand Down
2 changes: 1 addition & 1 deletion src/main/setup/configureIPCs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const configureIPCs = () => {
});

ipcMain.handle("list-drives", async (event, options) => {
const data = listDrivesHandler(event, options);
const data = await listDrivesHandler(event, options);
return data;
});

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/controller/FirmwareSelection/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const obtainLocalFWFiles = (customFWPath: string) => {
result = fromHexString(filedata);
}
if (customFWPath.includes(".uf2")) {
result = fs.readFileSync(customFWPath, { encoding: "binary" });
result = customFWPath;
}
return result;
};
Expand Down Expand Up @@ -232,7 +232,7 @@ export const downloadFirmware = async (
"Wired_neuron.uf2",
firmwareList[selectedFirmware].assets.find((asset: { name: string }) => asset.name === "Wired_neuron.uf2").url,
)) as Array<string>)
: (obtainLocalFWFiles(path.join(customFirmwareFolder, "Wired_neuron.uf2")) as Array<string>);
: [obtainLocalFWFiles(path.join(customFirmwareFolder, "Wired_neuron.uf2")) as string];
}
filenameSides =
typeSelected === "default"
Expand Down
17 changes: 10 additions & 7 deletions src/renderer/controller/FlashingProcedure/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,16 @@ export const uploadDefyWired = async (context: Context.ContextType) => {
stateUpdate("neuron", 10, context);
await context.flashSides.prepareNeuron();
stateUpdate("neuron", 30, context);
await ipcRenderer.invoke("list-drives", true).then(rsl => {
stateUpdate("neuron", 60, context);
const finalPath = path.join(rsl, "default.uf2");
// log.info("RESULTS!!!", rsl, context.firmwares.fw, " to ", finalPath);
fs.writeFileSync(finalPath, Buffer.from(new Uint8Array(context.firmwares?.fw)));
stateUpdate("neuron", 80, context);
});
const rsl = await ipcRenderer.invoke("list-drives", true);
stateUpdate("neuron", 60, context);
const finalPath = path.join(rsl, "default.uf2");
// log.info("RESULTS!!!", rsl, new Uint8Array(context.firmwares.fw), " to ", finalPath);
if (context.firmwares.fw.length === 1) {
fs.copyFileSync(context.firmwares.fw[0], finalPath);
} else {
fs.writeFileSync(finalPath, Buffer.from(new Uint8Array(context.firmwares?.fw)), { encoding: "utf8", flag: "w" });
}
stateUpdate("neuron", 80, context);
stateUpdate("neuron", 100, context);
} catch (error) {
log.warn("error when flashing Neuron");
Expand Down

0 comments on commit 3335119

Please sign in to comment.