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

Commit

Permalink
Increased timeout to 16MB spiffs flash problem (#127)
Browse files Browse the repository at this point in the history
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
  • Loading branch information
robdobsn and balloob committed Jun 10, 2022
1 parent fc6af70 commit 8a86662
Showing 1 changed file with 8 additions and 6 deletions.
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
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

0 comments on commit 8a86662

Please sign in to comment.