From d62d143cecca54b8aea72eab960abd3a92aa3bb4 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sun, 14 Oct 2018 23:18:21 +0200 Subject: [PATCH 1/4] fix #5246 - also add optional SPIFFS.begin(false): will not try to format (default is true) --- cores/esp8266/spiffs_api.cpp | 10 ---------- cores/esp8266/spiffs_api.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/cores/esp8266/spiffs_api.cpp b/cores/esp8266/spiffs_api.cpp index 390a6412fd..fa4d331304 100644 --- a/cores/esp8266/spiffs_api.cpp +++ b/cores/esp8266/spiffs_api.cpp @@ -110,16 +110,6 @@ bool isSpiffsFilenameValid(const char* name) // these symbols should be defined in the linker script for each flash layout #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 4ce8d3e6ba..fb37cfc975 100644 --- a/cores/esp8266/spiffs_api.h +++ b/cores/esp8266/spiffs_api.h @@ -35,6 +35,16 @@ using namespace fs; +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) + 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 +124,14 @@ class SPIFFSImpl : public FSImpl bool begin() override { + return begin(true); + } + + bool begin(bool autoformat) + { + if (_SPIFFS_start <= _SPIFFS_end) + return false; + if (SPIFFS_mounted(&_fs) != 0) { return true; } @@ -124,6 +142,9 @@ class SPIFFSImpl : public FSImpl if (_tryMount()) { return true; } + if (!autoformat) { + return false; + } auto rc = SPIFFS_format(&_fs); if (rc != SPIFFS_OK) { DEBUGV("SPIFFS_format: rc=%d, err=%d\r\n", rc, _fs.err_code); From a3fa654af01c9fc388bd39c3bcb626fc87c7d8c2 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sun, 14 Oct 2018 23:34:56 +0200 Subject: [PATCH 2/4] remove autoformat --- cores/esp8266/spiffs_api.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cores/esp8266/spiffs_api.h b/cores/esp8266/spiffs_api.h index fb37cfc975..bf60d3f089 100644 --- a/cores/esp8266/spiffs_api.h +++ b/cores/esp8266/spiffs_api.h @@ -124,12 +124,7 @@ class SPIFFSImpl : public FSImpl bool begin() override { - return begin(true); - } - - bool begin(bool autoformat) - { - if (_SPIFFS_start <= _SPIFFS_end) + if (&_SPIFFS_end <= &_SPIFFS_start) return false; if (SPIFFS_mounted(&_fs) != 0) { @@ -142,9 +137,6 @@ class SPIFFSImpl : public FSImpl if (_tryMount()) { return true; } - if (!autoformat) { - return false; - } auto rc = SPIFFS_format(&_fs); if (rc != SPIFFS_OK) { DEBUGV("SPIFFS_format: rc=%d, err=%d\r\n", rc, _fs.err_code); From c76c336a3b9f31ef575373a96bf57595ca3f919a Mon Sep 17 00:00:00 2001 From: david gauchard Date: Mon, 15 Oct 2018 02:26:45 +0200 Subject: [PATCH 3/4] fix host tests --- cores/esp8266/spiffs_api.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cores/esp8266/spiffs_api.h b/cores/esp8266/spiffs_api.h index bf60d3f089..087548fa3a 100644 --- a/cores/esp8266/spiffs_api.h +++ b/cores/esp8266/spiffs_api.h @@ -35,6 +35,7 @@ using namespace fs; +#ifdef ARDUINO extern "C" uint32_t _SPIFFS_start; extern "C" uint32_t _SPIFFS_end; extern "C" uint32_t _SPIFFS_page; @@ -44,6 +45,7 @@ extern "C" uint32_t _SPIFFS_block; #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); @@ -124,9 +126,10 @@ class SPIFFSImpl : public FSImpl bool begin() override { +#ifdef ARDUINO if (&_SPIFFS_end <= &_SPIFFS_start) return false; - +#endif if (SPIFFS_mounted(&_fs) != 0) { return true; } From cdd492cf9e5d15c47831bf8ca0d54a5490896d0b Mon Sep 17 00:00:00 2001 From: david gauchard Date: Thu, 6 Dec 2018 21:46:10 +0100 Subject: [PATCH 4/4] fix CI --- cores/esp8266/spiffs_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/spiffs_api.h b/cores/esp8266/spiffs_api.h index b43eb7b57a..08f9eb8791 100644 --- a/cores/esp8266/spiffs_api.h +++ b/cores/esp8266/spiffs_api.h @@ -126,7 +126,7 @@ class SPIFFSImpl : public FSImpl bool begin() override { -#ifdef ARDUINO +#if defined(ARDUINO) && !defined(CORE_MOCK) if (&_SPIFFS_end <= &_SPIFFS_start) return false; #endif