Skip to content

Commit 8b3f496

Browse files
authored
fix SPIFFS when not enabled in build options (#5249)
1 parent 8e24806 commit 8b3f496

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

cores/esp8266/spiffs_api.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,6 @@ bool isSpiffsFilenameValid(const char* name)
111111
// these symbols should be defined in the linker script for each flash layout
112112
#ifndef CORE_MOCK
113113
#ifdef ARDUINO
114-
extern "C" uint32_t _SPIFFS_start;
115-
extern "C" uint32_t _SPIFFS_end;
116-
extern "C" uint32_t _SPIFFS_page;
117-
extern "C" uint32_t _SPIFFS_block;
118-
119-
#define SPIFFS_PHYS_ADDR ((uint32_t) (&_SPIFFS_start) - 0x40200000)
120-
#define SPIFFS_PHYS_SIZE ((uint32_t) (&_SPIFFS_end) - (uint32_t) (&_SPIFFS_start))
121-
#define SPIFFS_PHYS_PAGE ((uint32_t) &_SPIFFS_page)
122-
#define SPIFFS_PHYS_BLOCK ((uint32_t) &_SPIFFS_block)
123-
124114
#ifndef SPIFFS_MAX_OPEN_FILES
125115
#define SPIFFS_MAX_OPEN_FILES 5
126116
#endif

cores/esp8266/spiffs_api.h

+16
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535

3636
using namespace fs;
3737

38+
#ifdef ARDUINO
39+
extern "C" uint32_t _SPIFFS_start;
40+
extern "C" uint32_t _SPIFFS_end;
41+
extern "C" uint32_t _SPIFFS_page;
42+
extern "C" uint32_t _SPIFFS_block;
43+
44+
#define SPIFFS_PHYS_ADDR ((uint32_t) (&_SPIFFS_start) - 0x40200000)
45+
#define SPIFFS_PHYS_SIZE ((uint32_t) (&_SPIFFS_end) - (uint32_t) (&_SPIFFS_start))
46+
#define SPIFFS_PHYS_PAGE ((uint32_t) &_SPIFFS_page)
47+
#define SPIFFS_PHYS_BLOCK ((uint32_t) &_SPIFFS_block)
48+
#endif
49+
3850
extern int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src);
3951
extern int32_t spiffs_hal_erase(uint32_t addr, uint32_t size);
4052
extern int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst);
@@ -114,6 +126,10 @@ class SPIFFSImpl : public FSImpl
114126

115127
bool begin() override
116128
{
129+
#if defined(ARDUINO) && !defined(CORE_MOCK)
130+
if (&_SPIFFS_end <= &_SPIFFS_start)
131+
return false;
132+
#endif
117133
if (SPIFFS_mounted(&_fs) != 0) {
118134
return true;
119135
}

0 commit comments

Comments
 (0)