update webinstaller to esptool 0.4.5

This commit is contained in:
andreas 2024-09-06 17:20:38 +02:00
parent 20b108ac45
commit c1e8848f25
1 changed files with 24 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import {ESPLoader,Transport} from "https://cdn.jsdelivr.net/npm/esptool-js@0.2.1/bundle.js"; import {ESPLoader,Transport} from "https://cdn.jsdelivr.net/npm/esptool-js@0.4.5/bundle.js";
/** /**
* write all messages to the console * write all messages to the console
*/ */
@ -102,10 +102,14 @@ class ESPInstaller{
await this.consoleReader.cancel(); await this.consoleReader.cancel();
this.consoleReader=undefined; this.consoleReader=undefined;
} }
await this.consoleDevice.close();
}catch(e){ }catch(e){
console.log(`error cancel serial read ${e}`); console.log(`error cancel serial read ${e}`);
} }
try{
await this.consoleDevice.close();
}catch(e){
console.log('error closing console device', this.consoleDevice,e);
}
this.consoleDevice=undefined; this.consoleDevice=undefined;
} }
if (this.transport){ if (this.transport){
@ -126,13 +130,17 @@ class ESPInstaller{
} }
try { try {
this.transport = new Transport(device); this.transport = new Transport(device);
this.esploader = new ESPLoader(this.transport, 115200, this.espLoaderTerminal); this.esploader = new ESPLoader({
let foundChip = await this.esploader.main_fn(); transport:this.transport,
baudrate: 115200,
terminal: this.espLoaderTerminal});
//this.esploader.debugLogging=true;
let foundChip = await this.esploader.main();
if (!foundChip) { if (!foundChip) {
throw new Error("unable to read chip id"); throw new Error("unable to read chip id");
} }
this.espLoaderTerminal.writeLine(`chip: ${foundChip}`); this.espLoaderTerminal.writeLine(`chip: ${foundChip}`);
await this.esploader.flash_id(); //await this.esploader.flashId();
this.chipFamily = this.esploader.chip.CHIP_NAME; this.chipFamily = this.esploader.chip.CHIP_NAME;
this.imageChipId = this.esploader.chip.IMAGE_CHIP_ID; this.imageChipId = this.esploader.chip.IMAGE_CHIP_ID;
this.espLoaderTerminal.writeLine(`chipFamily: ${this.chipFamily}`); this.espLoaderTerminal.writeLine(`chipFamily: ${this.chipFamily}`);
@ -198,12 +206,17 @@ class ESPInstaller{
async writeFlash(fileList){ async writeFlash(fileList){
this.checkConnected(); this.checkConnected();
this.espLoaderTerminal.writeLine(`Flashing....`); this.espLoaderTerminal.writeLine(`Flashing....`);
await this.esploader.write_flash( await this.esploader.writeFlash({
fileList, fileArray: fileList,
"keep", flashSize: "keep",
"keep", flashMode: "keep",
"keep", flashFreq: "keep",
false eraseAll: false,
compress: true,
reportProgress: (fileIndex, written, total)=>{
this.espLoaderTerminal.writeLine(`file ${fileIndex}: ${written}/${total}`);
}
}
) )
await this.resetTransport(); await this.resetTransport();
this.espLoaderTerminal.writeLine(`Done.`); this.espLoaderTerminal.writeLine(`Done.`);