| 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; |
| 308 | const limit = 512; // for WebUSB, no limit is needed. But, Web Serial overflows if this is much bigger. |
| 309 | |
| 310 | while (size) { |
| 311 | const use = (size > limit) ? limit : size; |
| 312 | const part = await this.readPart(offset, use); |
| 313 | result.set(part, position); |
| 314 | position += use; |
| 315 | offset += use; |
| 316 | size -= use; |
| 317 | } |
| 318 | |
| 319 | return result; |
| 320 | } |
| 321 | async readPart(offset, size) { |
| 322 | // ROM loader is limited to sector boundaries but RAM loader supports arbitrary offsets |
| 323 | // if ((offset % 4096) || (size % 4096)) |