1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-11 15:22:13 +03:00

Updater: if low on heap memory, use smaller write buffer

This commit is contained in:
Ivan Grokhotkov
2017-05-09 17:33:29 +08:00
committed by Ivan Grokhotkov
parent 9b0ad39e94
commit 01e1c586cb
2 changed files with 24 additions and 15 deletions

View File

@ -116,8 +116,8 @@ class UpdaterClass {
if(_bufferLen + available > remaining()){
available = remaining() - _bufferLen;
}
if(_bufferLen + available > FLASH_SECTOR_SIZE) {
size_t toBuff = FLASH_SECTOR_SIZE - _bufferLen;
if(_bufferLen + available > _bufferSize) {
size_t toBuff = _bufferSize - _bufferLen;
data.read(_buffer + _bufferLen, toBuff);
_bufferLen += toBuff;
if(!_writeBuffer())
@ -151,7 +151,8 @@ class UpdaterClass {
bool _async;
uint8_t _error;
uint8_t *_buffer;
size_t _bufferLen;
size_t _bufferLen; // amount of data written into _buffer
size_t _bufferSize; // total size of _buffer
size_t _size;
uint32_t _startAddress;
uint32_t _currentAddress;