1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

make Update erase/write sector by sector as well

This commit is contained in:
John Doe 2015-07-04 01:20:33 +03:00 committed by Ivan Grokhotkov
parent 9d0a690421
commit 703ab8df64
2 changed files with 17 additions and 13 deletions

View File

@ -51,18 +51,6 @@ bool UpdaterClass::begin(size_t size){
return false; return false;
} }
//erase the neede space
noInterrupts();
int rc = SPIEraseAreaEx(updateStartAddress, roundedSize);
interrupts();
if (rc){
_error = UPDATE_ERROR_ERASE;
#ifdef DEBUG_UPDATER
printError(DEBUG_UPDATER);
#endif
return false;
}
//initialize //initialize
_startAddress = updateStartAddress; _startAddress = updateStartAddress;
_currentAddress = _startAddress; _currentAddress = _startAddress;
@ -122,7 +110,19 @@ bool UpdaterClass::end(bool evenIfRemaining){
bool UpdaterClass::_writeBuffer(){ bool UpdaterClass::_writeBuffer(){
WDT_FEED(); WDT_FEED();
noInterrupts(); noInterrupts();
int rc = SPIWrite(_currentAddress, _buffer, _bufferLen); int rc = SPIEraseSector(_currentAddress/FLASH_SECTOR_SIZE);
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(); interrupts();
if (rc) { if (rc) {
_error = UPDATE_ERROR_WRITE; _error = UPDATE_ERROR_WRITE;

View File

@ -1,3 +1,7 @@
/*
To upload through terminal you can use: curl -F "image=@firmware.bin" esp8266-webupdate.local/update
*/
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <WiFiClient.h> #include <WiFiClient.h>
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>