mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
speed :) and prevent write if we are not running
This commit is contained in:
parent
703ab8df64
commit
1741bc68b6
@ -108,23 +108,11 @@ bool UpdaterClass::end(bool evenIfRemaining){
|
||||
}
|
||||
|
||||
bool UpdaterClass::_writeBuffer(){
|
||||
WDT_FEED();
|
||||
noInterrupts();
|
||||
int rc = SPIEraseSector(_currentAddress/FLASH_SECTOR_SIZE);
|
||||
if(!rc) rc = SPIWrite(_currentAddress, _buffer, _bufferLen);
|
||||
interrupts();
|
||||
if (rc){
|
||||
_error = UPDATE_ERROR_ERASE;
|
||||
#ifdef DEBUG_UPDATER
|
||||
printError(DEBUG_UPDATER);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
WDT_FEED();
|
||||
noInterrupts();
|
||||
rc = SPIWrite(_currentAddress, _buffer, _bufferLen);
|
||||
interrupts();
|
||||
if (rc) {
|
||||
_error = UPDATE_ERROR_WRITE;
|
||||
_currentAddress = (_startAddress + _size);
|
||||
#ifdef DEBUG_UPDATER
|
||||
@ -139,7 +127,7 @@ bool UpdaterClass::_writeBuffer(){
|
||||
|
||||
size_t UpdaterClass::write(uint8_t *data, size_t len){
|
||||
size_t left = len;
|
||||
if(hasError())
|
||||
if(hasError()||!isRunning())
|
||||
return 0;
|
||||
|
||||
if(len > remaining())
|
||||
@ -170,7 +158,7 @@ size_t UpdaterClass::write(uint8_t *data, size_t len){
|
||||
size_t UpdaterClass::writeStream(Stream &data){
|
||||
size_t written = 0;
|
||||
size_t toRead = 0;
|
||||
if(hasError())
|
||||
if(hasError()||!isRunning())
|
||||
return 0;
|
||||
|
||||
while(remaining()){
|
||||
|
@ -15,9 +15,8 @@ class UpdaterClass {
|
||||
public:
|
||||
UpdaterClass();
|
||||
/*
|
||||
Call this to check and erase the space needed for the update
|
||||
Call this to check the space needed for the update
|
||||
Will return false if there is not enough space
|
||||
Or the erase of the flash failed
|
||||
*/
|
||||
bool begin(size_t size);
|
||||
|
||||
@ -72,7 +71,7 @@ class UpdaterClass {
|
||||
template<typename T>
|
||||
size_t write(T &data){
|
||||
size_t written = 0;
|
||||
if(hasError())
|
||||
if(hasError()||!isRunning())
|
||||
return 0;
|
||||
size_t available = data.available();
|
||||
while(available){
|
||||
|
Loading…
x
Reference in New Issue
Block a user