From c1e8848f2524e74069e20db475db2a12471836eb Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 6 Sep 2024 17:20:38 +0200 Subject: [PATCH] update webinstaller to esptool 0.4.5 --- webinstall/installUtil.js | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/webinstall/installUtil.js b/webinstall/installUtil.js index 14910d8..330310a 100644 --- a/webinstall/installUtil.js +++ b/webinstall/installUtil.js @@ -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 */ @@ -102,10 +102,14 @@ class ESPInstaller{ await this.consoleReader.cancel(); this.consoleReader=undefined; } - await this.consoleDevice.close(); }catch(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; } if (this.transport){ @@ -126,13 +130,17 @@ class ESPInstaller{ } try { this.transport = new Transport(device); - this.esploader = new ESPLoader(this.transport, 115200, this.espLoaderTerminal); - let foundChip = await this.esploader.main_fn(); + this.esploader = new ESPLoader({ + transport:this.transport, + baudrate: 115200, + terminal: this.espLoaderTerminal}); + //this.esploader.debugLogging=true; + let foundChip = await this.esploader.main(); if (!foundChip) { throw new Error("unable to read chip id"); } this.espLoaderTerminal.writeLine(`chip: ${foundChip}`); - await this.esploader.flash_id(); + //await this.esploader.flashId(); this.chipFamily = this.esploader.chip.CHIP_NAME; this.imageChipId = this.esploader.chip.IMAGE_CHIP_ID; this.espLoaderTerminal.writeLine(`chipFamily: ${this.chipFamily}`); @@ -198,12 +206,17 @@ class ESPInstaller{ async writeFlash(fileList){ this.checkConnected(); this.espLoaderTerminal.writeLine(`Flashing....`); - await this.esploader.write_flash( - fileList, - "keep", - "keep", - "keep", - false + await this.esploader.writeFlash({ + fileArray: fileList, + flashSize: "keep", + flashMode: "keep", + flashFreq: "keep", + eraseAll: false, + compress: true, + reportProgress: (fileIndex, written, total)=>{ + this.espLoaderTerminal.writeLine(`file ${fileIndex}: ${written}/${total}`); + } + } ) await this.resetTransport(); this.espLoaderTerminal.writeLine(`Done.`);