Skip to content

Commit

Permalink
Update esptool-js to 0.2.0 (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Jan 18, 2023
1 parent f1fb9a2 commit d09d54b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 53 deletions.
36 changes: 11 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "Apache-2.0",
"scripts": {
"prepublishOnly": "script/build",
"postinstall": "patch -Ntu node_modules/esptool-js/ESPLoader.js -i patches/0001-import-pako-and-not-change-baud.patch || true"
"postinstall": "patch -Ntu node_modules/esptool-js/lib/esploader.js -i patches/0001-not-change-baud.patch || true"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.18.6",
Expand All @@ -31,7 +31,7 @@
"@material/mwc-formfield": "^0.27.0",
"@material/mwc-icon-button": "^0.27.0",
"@material/mwc-textfield": "^0.27.0",
"esptool-js": "github:espressif/esptool-js#076af269f44daa5b7823031221f39bf22124c129",
"esptool-js": "^0.2.0",
"improv-wifi-serial-sdk": "^2.4.0",
"lit": "^2.5.0",
"pako": "^2.1.0",
Expand Down
16 changes: 0 additions & 16 deletions patches/0001-import-pako-and-not-change-baud.patch

This file was deleted.

11 changes: 11 additions & 0 deletions patches/0001-not-change-baud.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- node_modules/esptool-js/lib/esploader.js 2023-01-18 15:30:02
+++ node_modules/esptool-js/lib/esploader.fixed.js 2023-01-18 15:31:47
@@ -677,7 +677,7 @@
await this.chip._post_connect(this);
}
await this.run_stub();
- await this.change_baud();
+ // await this.change_baud();
return chip;
}
parse_flash_size_arg(flsz) {
28 changes: 18 additions & 10 deletions src/flash.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// @ts-ignore-next-line
import { Transport } from "esptool-js/webserial.js";
// @ts-ignore-next-line
import { ESPLoader } from "esptool-js/ESPLoader.js";
import { Transport, ESPLoader } from "esptool-js";
import {
Build,
FlashError,
Expand Down Expand Up @@ -41,7 +38,12 @@ export const flash = async (
});

const transport = new Transport(port);
const esploader = new ESPLoader(transport, 115200);
const esploader = new ESPLoader(
transport,
115200,
// Wrong type, fixed in https://github.com/espressif/esptool-js/pull/75/files
undefined as any
);

// For debugging
(window as any).esploader = esploader;
Expand All @@ -68,7 +70,7 @@ export const flash = async (
return;
}

chipFamily = await esploader.chip.CHIP_NAME;
chipFamily = esploader.chip.CHIP_NAME as any;

if (!esploader.chip.ROM_TEXT) {
fireStateEvent({
Expand Down Expand Up @@ -184,9 +186,15 @@ export const flash = async (
let totalWritten = 0;

try {
await esploader.write_flash({
await esploader.write_flash(
fileArray,
reportProgress(fileIndex: number, written: number, total: number) {
"keep",
"keep",
"keep",
false,
true,
// report progress
(fileIndex: number, written: number, total: number) => {
const uncompressedWritten =
(written / total) * fileArray[fileIndex].data.length;

Expand All @@ -209,8 +217,8 @@ export const flash = async (
percentage: newPct,
},
});
},
});
}
);
} catch (err: any) {
fireStateEvent({
state: FlashStateType.ERROR,
Expand Down

0 comments on commit d09d54b

Please sign in to comment.