Skip to content

Commit 7ef2ffb

Browse files
authored
changed to u8 flashRead variant
1 parent 40d0d03 commit 7ef2ffb

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

cores/esp8266/Updater.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -284,24 +284,8 @@ bool UpdaterClass::end(bool evenIfRemaining){
284284
_hash->begin();
285285
for (uint32_t offset = 0; offset < binSize; offset += sizeof(buff)) {
286286
auto len = std::min(sizeof(buff), binSize - offset);
287-
288-
if (len % 4 == 0) {
289-
ESP.flashRead(_startAddress + offset, reinterpret_cast<uint32_t *>(&buff[0]), len);
290-
_hash->add(buff, len);
291-
}
292-
else {
293-
// Calculate padding needed to make len 4-byte aligned
294-
uint32_t padLen = (len + 3) & ~3; // Rounds up to nearest multiple of 4
295-
296-
// Temporary buffer to satisfy 4-byte alignment requirement
297-
uint8_t tempBuff[padLen] = {0};
298-
299-
// Read into the temporary buffer
300-
ESP.flashRead(_startAddress + offset, reinterpret_cast<uint32_t *>(&tempBuff[0]), padLen); // Note: ESP.flashRead size parameter might be in 4-byte words, not bytes
301-
302-
// Process only the relevant portion of the temp buffer
303-
_hash->add(tempBuff, len); // Ensure only len bytes are processed, not including the padded bytes
304-
}
287+
ESP.flashRead(_startAddress + offset, buff, len);
288+
_hash->add(buff, len);
305289
}
306290
_hash->end();
307291

0 commit comments

Comments
 (0)