mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
parent
9a096f828d
commit
0389657614
@ -168,9 +168,14 @@ bool UpdaterClass::end(bool evenIfRemaining){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool UpdaterClass::_writeBuffer(){
|
bool UpdaterClass::_writeBuffer(){
|
||||||
|
|
||||||
|
yield();
|
||||||
|
bool result = ESP.flashEraseSector(_currentAddress/FLASH_SECTOR_SIZE);
|
||||||
|
yield();
|
||||||
|
if (result) {
|
||||||
|
result = ESP.flashWrite(_currentAddress, (uint32_t*) _buffer, _bufferLen);
|
||||||
|
}
|
||||||
yield();
|
yield();
|
||||||
bool result = ESP.flashEraseSector(_currentAddress/FLASH_SECTOR_SIZE) &&
|
|
||||||
ESP.flashWrite(_currentAddress, (uint32_t*) _buffer, _bufferLen);
|
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
_error = UPDATE_ERROR_WRITE;
|
_error = UPDATE_ERROR_WRITE;
|
||||||
@ -223,14 +228,17 @@ size_t UpdaterClass::writeStream(Stream &data) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while(remaining()) {
|
while(remaining()) {
|
||||||
toRead = FLASH_SECTOR_SIZE - _bufferLen;
|
toRead = data.readBytes(_buffer + _bufferLen, (FLASH_SECTOR_SIZE - _bufferLen));
|
||||||
toRead = data.readBytes(_buffer + _bufferLen, toRead);
|
if(toRead == 0) { //Timeout
|
||||||
if(toRead == 0){ //Timeout
|
delay(100);
|
||||||
|
toRead = data.readBytes(_buffer + _bufferLen, (FLASH_SECTOR_SIZE - _bufferLen));
|
||||||
|
if(toRead == 0) { //Timeout
|
||||||
_error = UPDATE_ERROR_STREAM;
|
_error = UPDATE_ERROR_STREAM;
|
||||||
_currentAddress = (_startAddress + _size);
|
_currentAddress = (_startAddress + _size);
|
||||||
#ifdef DEBUG_UPDATER
|
#ifdef DEBUG_UPDATER
|
||||||
printError(DEBUG_UPDATER);
|
printError(DEBUG_UPDATER);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
_bufferLen += toRead;
|
_bufferLen += toRead;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user