Skip to content

Commit add0f28

Browse files
John DoeJohn Doe
John Doe
authored and
John Doe
committed
speed :) and prevent write if we are not running
1 parent d5dfb22 commit add0f28

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

hardware/esp8266com/esp8266/cores/esp8266/Updater.cpp

+3-15
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,11 @@ bool UpdaterClass::end(bool evenIfRemaining){
108108
}
109109

110110
bool UpdaterClass::_writeBuffer(){
111-
WDT_FEED();
112111
noInterrupts();
113112
int rc = SPIEraseSector(_currentAddress/FLASH_SECTOR_SIZE);
113+
if(!rc) rc = SPIWrite(_currentAddress, _buffer, _bufferLen);
114114
interrupts();
115115
if (rc){
116-
_error = UPDATE_ERROR_ERASE;
117-
#ifdef DEBUG_UPDATER
118-
printError(DEBUG_UPDATER);
119-
#endif
120-
return false;
121-
}
122-
123-
WDT_FEED();
124-
noInterrupts();
125-
rc = SPIWrite(_currentAddress, _buffer, _bufferLen);
126-
interrupts();
127-
if (rc) {
128116
_error = UPDATE_ERROR_WRITE;
129117
_currentAddress = (_startAddress + _size);
130118
#ifdef DEBUG_UPDATER
@@ -139,7 +127,7 @@ bool UpdaterClass::_writeBuffer(){
139127

140128
size_t UpdaterClass::write(uint8_t *data, size_t len){
141129
size_t left = len;
142-
if(hasError())
130+
if(hasError()||!isRunning())
143131
return 0;
144132

145133
if(len > remaining())
@@ -170,7 +158,7 @@ size_t UpdaterClass::write(uint8_t *data, size_t len){
170158
size_t UpdaterClass::writeStream(Stream &data){
171159
size_t written = 0;
172160
size_t toRead = 0;
173-
if(hasError())
161+
if(hasError()||!isRunning())
174162
return 0;
175163

176164
while(remaining()){

hardware/esp8266com/esp8266/cores/esp8266/Updater.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ class UpdaterClass {
1515
public:
1616
UpdaterClass();
1717
/*
18-
Call this to check and erase the space needed for the update
18+
Call this to check the space needed for the update
1919
Will return false if there is not enough space
20-
Or the erase of the flash failed
2120
*/
2221
bool begin(size_t size);
2322

@@ -72,7 +71,7 @@ class UpdaterClass {
7271
template<typename T>
7372
size_t write(T &data){
7473
size_t written = 0;
75-
if(hasError())
74+
if(hasError()||!isRunning())
7675
return 0;
7776
size_t available = data.available();
7877
while(available){

0 commit comments

Comments
 (0)