MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / erase

Method erase

tools/xsbug/esptool.js:288–304  ·  view source on GitHub ↗
(offset, size)

Source from the content-addressed store, hash-verified

286 this.#serial.set({DTR: false, RTS: false});
287 }
288 async erase(offset, size) {
289 if ((undefined === offset) && (undefined === size)) {
290 await this.command(Bootloader.ERASE_FLASH);
291 this.parseReply(await this.getReply(120 * 1000), Bootloader.ERASE_FLASH);
292 return;
293 }
294
295 if ((offset % 4096) || (size % 4096))
296 throw new Error("must be aligned to sectors");
297
298 const payload = new DataView(new ArrayBuffer(2 * 4));
299 payload.setUint32(0, offset, 1);
300 payload.setUint32(4, size, 1);
301 const timeout = Math.max(100, 50 + (size / 1_000_000) * 30_000); // 30 seconds per MB
302 await this.command(Bootloader.ERASE_REGION, new Uint8Array(payload.buffer));
303 this.parseReply(await this.getReply(timeout), Bootloader.ERASE_REGION);
304 }
305 async read(offset, size) {
306 const result = new Uint8Array(size);
307 let position = 0;

Callers 8

lfs_bd_eraseFunction · 0.80
lfs_bd_eraseFunction · 0.80
archive.jsFile · 0.80
map.jsFile · 0.80
readwriteerase.jsFile · 0.80
erase.jsFile · 0.80
getTimeEstimateFunction · 0.80
downloadGIFMethod · 0.80

Calls 4

commandMethod · 0.95
parseReplyMethod · 0.95
getReplyMethod · 0.95
maxMethod · 0.80

Tested by

no test coverage detected