Skip to content

Commit 0c1f7f3

Browse files
John Doeigrr
authored andcommitted
make Update erase/write sector by sector as well
1 parent 5d2ed76 commit 0c1f7f3

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@ bool UpdaterClass::begin(size_t size){
5151
return false;
5252
}
5353

54-
//erase the neede space
55-
noInterrupts();
56-
int rc = SPIEraseAreaEx(updateStartAddress, roundedSize);
57-
interrupts();
58-
if (rc){
59-
_error = UPDATE_ERROR_ERASE;
60-
#ifdef DEBUG_UPDATER
61-
printError(DEBUG_UPDATER);
62-
#endif
63-
return false;
64-
}
65-
6654
//initialize
6755
_startAddress = updateStartAddress;
6856
_currentAddress = _startAddress;
@@ -122,7 +110,19 @@ bool UpdaterClass::end(bool evenIfRemaining){
122110
bool UpdaterClass::_writeBuffer(){
123111
WDT_FEED();
124112
noInterrupts();
125-
int rc = SPIWrite(_currentAddress, _buffer, _bufferLen);
113+
int rc = SPIEraseSector(_currentAddress/FLASH_SECTOR_SIZE);
114+
interrupts();
115+
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);
126126
interrupts();
127127
if (rc) {
128128
_error = UPDATE_ERROR_WRITE;

hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
To upload through terminal you can use: curl -F "[email protected]" esp8266-webupdate.local/update
3+
*/
4+
15
#include <ESP8266WiFi.h>
26
#include <WiFiClient.h>
37
#include <ESP8266WebServer.h>

0 commit comments

Comments
 (0)