1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

flash-size agnostic builds (#6690)

* flash: mapping definition by sketch at runtime depending on flash chip size and user configuration
This commit is contained in:
david gauchard
2022-02-10 18:25:18 +01:00
committed by GitHub
parent 3027acaf11
commit f60defc3d3
22 changed files with 552 additions and 542 deletions

View File

@ -31,7 +31,7 @@ extern "C" {
#include "spi_flash.h"
}
extern "C" uint32_t _EEPROM_start;
#include <flash_hal.h>
EEPROMClass::EEPROMClass(uint32_t sector)
: _sector(sector)
@ -39,7 +39,7 @@ EEPROMClass::EEPROMClass(uint32_t sector)
}
EEPROMClass::EEPROMClass(void)
: _sector((((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
: _sector(((EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
{
}

View File

@ -93,7 +93,7 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
if (_serial_output)
Serial.printf("Update: %s\n", upload.filename.c_str());
if (upload.name == "filesystem") {
size_t fsSize = ((size_t) &_FS_end - (size_t) &_FS_start);
size_t fsSize = ((size_t)FS_end - (size_t)FS_start);
close_all_fs();
if (!Update.begin(fsSize, U_FS)){//start with max available size
if (_serial_output) Update.printError(Serial);

View File

@ -25,9 +25,7 @@
#include "ESP8266httpUpdate.h"
#include <StreamString.h>
extern "C" uint32_t _FS_start;
extern "C" uint32_t _FS_end;
#include <flash_hal.h>
ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
: _httpClientTimeout(8000)
@ -234,7 +232,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
if(len > 0) {
bool startUpdate = true;
if(spiffs) {
size_t spiffsSize = ((size_t) &_FS_end - (size_t) &_FS_start);
size_t spiffsSize = ((size_t)FS_end - (size_t)FS_start);
if(len > (int) spiffsSize) {
DEBUG_HTTP_UPDATE("[httpUpdate] spiffsSize to low (%d) needed: %d\n", spiffsSize, len);
startUpdate = false;
@ -292,6 +290,9 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
}
// it makes no sense to check flash size in auto flash mode
// (sketch size would have to be set in bin header, instead of flash size)
#if !FLASH_MAP_SUPPORT
if (buf[0] == 0xe9) {
uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] & 0xf0) >> 4);
@ -303,6 +304,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
return HTTP_UPDATE_FAILED;
}
}
#endif
}
if(runUpdate(*tcp, len, md5, command)) {
ret = HTTP_UPDATE_OK;