Skip to content

Commit bf25815

Browse files
committed
Couple improvements in FlashManager
1 parent edaf6d8 commit bf25815

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/lib/EspTool/FlashManager.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Latin1 from 'crypto-js/enc-latin1';
22
import HashMD5 from 'crypto-js/md5';
33
import {
44
ESPLoader,
5-
type FlashOptions,
65
type IEspLoaderTerminal,
76
type LoaderOptions,
87
Transport,
@@ -306,22 +305,23 @@ export default class FlashManager {
306305
onProgress(written / total);
307306
}
308307

309-
const flashOptions = {
310-
fileArray: [
311-
{
308+
try {
309+
await this.loader.writeFlash({
310+
fileArray: [{
312311
data: arrayBufferToString(data),
313312
address: 0,
313+
}],
314+
flashSize: 'keep',
315+
flashMode: 'keep',
316+
flashFreq: 'keep',
317+
eraseAll,
318+
compress: true,
319+
reportProgress,
320+
calculateMD5Hash: (image) => {
321+
this.terminal.writeLine('Validating image...');
322+
return HashMD5(Latin1.parse(image)).toString();
314323
},
315-
],
316-
flashSize: 'keep',
317-
eraseAll,
318-
compress: true,
319-
reportProgress,
320-
calculateMD5Hash: (image) => HashMD5(Latin1.parse(image)).toString(),
321-
} as FlashOptions;
322-
323-
try {
324-
await this.loader.writeFlash(flashOptions);
324+
});
325325
this.terminal.writeLine('Flash complete');
326326
return true;
327327
} catch (e) {

0 commit comments

Comments
 (0)