Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Increased timeout to 16MB spiffs flash problem #127

Merged
merged 6 commits into from
Jun 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/esp_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ export class ESPLoader extends EventTarget {
let compressedFilesize = 0;

let dataToFlash;
let timeout = DEFAULT_TIMEOUT;

if (compress) {
dataToFlash = deflate(new Uint8Array(binaryData), {
Expand All @@ -565,7 +566,7 @@ export class ESPLoader extends EventTarget {
this.logger.log(
`Writing data with filesize: ${uncompressedFilesize}. Compressed Size: ${compressedFilesize}`
);
await this.flashDeflBegin(
timeout = await this.flashDeflBegin(
uncompressedFilesize,
compressedFilesize,
offset
Expand Down Expand Up @@ -607,7 +608,7 @@ export class ESPLoader extends EventTarget {
}
}
if (compress) {
await this.flashDeflBlock(block, seq);
await this.flashDeflBlock(block, seq, timeout);
} else {
await this.flashBlock(block, seq);
}
Expand Down Expand Up @@ -654,7 +655,8 @@ export class ESPLoader extends EventTarget {
await this.checkCommand(
ESP_FLASH_DEFL_DATA,
pack("<IIII", data.length, seq, 0, 0).concat(data),
this.checksum(data)
this.checksum(data),
timeout
);
}

Expand Down Expand Up @@ -747,16 +749,16 @@ export class ESPLoader extends EventTarget {

if (this.IS_STUB) {
writeSize = size; // stub expects number of bytes here, manages erasing internally
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if-check also checks for write size, not just timeout. You're changing how that is determined based on it being a stub now too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are correct - my mistake. I have now moved the timeout logic to be the other way around so the writeSize calculation is as it was previously.

timeout = DEFAULT_TIMEOUT;
timeout = timeoutPerMb(ERASE_REGION_TIMEOUT_PER_MB, writeSize); // ROM performs the erase up front
} else {
writeSize = eraseBlocks * flashWriteSize; // ROM expects rounded up to erase block size
timeout = timeoutPerMb(ERASE_REGION_TIMEOUT_PER_MB, writeSize); // ROM performs the erase up front
timeout = DEFAULT_TIMEOUT;
}
buffer = pack("<IIII", writeSize, numBlocks, flashWriteSize, offset);

await this.checkCommand(ESP_FLASH_DEFL_BEGIN, buffer, 0, timeout);

return numBlocks;
return timeout;
}

async flashFinish() {
Expand Down