diff --git a/cores/esp8266/spiffs_api.cpp b/cores/esp8266/spiffs_api.cpp index a8e522f03..f3fcfa235 100644 --- a/cores/esp8266/spiffs_api.cpp +++ b/cores/esp8266/spiffs_api.cpp @@ -111,16 +111,6 @@ bool isSpiffsFilenameValid(const char* name) // these symbols should be defined in the linker script for each flash layout #ifndef CORE_MOCK #ifdef ARDUINO -extern "C" uint32_t _SPIFFS_start; -extern "C" uint32_t _SPIFFS_end; -extern "C" uint32_t _SPIFFS_page; -extern "C" uint32_t _SPIFFS_block; - -#define SPIFFS_PHYS_ADDR ((uint32_t) (&_SPIFFS_start) - 0x40200000) -#define SPIFFS_PHYS_SIZE ((uint32_t) (&_SPIFFS_end) - (uint32_t) (&_SPIFFS_start)) -#define SPIFFS_PHYS_PAGE ((uint32_t) &_SPIFFS_page) -#define SPIFFS_PHYS_BLOCK ((uint32_t) &_SPIFFS_block) - #ifndef SPIFFS_MAX_OPEN_FILES #define SPIFFS_MAX_OPEN_FILES 5 #endif diff --git a/cores/esp8266/spiffs_api.h b/cores/esp8266/spiffs_api.h index 3a0cb032e..08f9eb879 100644 --- a/cores/esp8266/spiffs_api.h +++ b/cores/esp8266/spiffs_api.h @@ -35,6 +35,18 @@ using namespace fs; +#ifdef ARDUINO +extern "C" uint32_t _SPIFFS_start; +extern "C" uint32_t _SPIFFS_end; +extern "C" uint32_t _SPIFFS_page; +extern "C" uint32_t _SPIFFS_block; + +#define SPIFFS_PHYS_ADDR ((uint32_t) (&_SPIFFS_start) - 0x40200000) +#define SPIFFS_PHYS_SIZE ((uint32_t) (&_SPIFFS_end) - (uint32_t) (&_SPIFFS_start)) +#define SPIFFS_PHYS_PAGE ((uint32_t) &_SPIFFS_page) +#define SPIFFS_PHYS_BLOCK ((uint32_t) &_SPIFFS_block) +#endif + extern int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src); extern int32_t spiffs_hal_erase(uint32_t addr, uint32_t size); extern int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst); @@ -114,6 +126,10 @@ public: bool begin() override { +#if defined(ARDUINO) && !defined(CORE_MOCK) + if (&_SPIFFS_end <= &_SPIFFS_start) + return false; +#endif if (SPIFFS_mounted(&_fs) != 0) { return true; }