Skip to content

Commit

Permalink
move flash size check to a function in ESP class,
Browse files Browse the repository at this point in the history
allow real size bigger the IDE for Update
  • Loading branch information
Links2004 committed Dec 17, 2015
1 parent 28dd31a commit f57ab60
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,24 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) {
}
}

/**
* check the Flash settings from IDE against the Real flash size
* @param needsEquals (return only true it equals)
* @return ok or not
*/
bool EspClass::checkFlashConfig(bool needsEquals) {
if(needsEquals) {
if(getFlashChipRealSize() == getFlashChipSize()) {
return true;
}
} else {
if(getFlashChipRealSize() >= getFlashChipSize()) {
return true;
}
}
return false;
}

String EspClass::getResetInfo(void) {
if(resetInfo.reason != 0) {
char buff[200];
Expand Down
2 changes: 2 additions & 0 deletions cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class EspClass {
FlashMode_t getFlashChipMode();
uint32_t getFlashChipSizeByChipId();

bool checkFlashConfig(bool needsEquals = false);

bool flashEraseSector(uint32_t sector);
bool flashWrite(uint32_t offset, uint32_t *data, size_t size);
bool flashRead(uint32_t offset, uint32_t *data, size_t size);
Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool UpdaterClass::begin(size_t size, int command) {
return false;
}

if(ESP.getFlashChipRealSize() != ESP.getFlashChipSize()) {
if(ESP.checkFlashConfig(false)) {
_error = UPDATE_ERROR_FLASH_CONFIG;
#ifdef DEBUG_UPDATER
printError(DEBUG_UPDATER);
Expand Down

0 comments on commit f57ab60

Please sign in to comment.