Skip to content

Commit 4372fa8

Browse files
committed
define two weak functions defaulting to no-op
redefine them to do something useful when either spiffs or littlefs are used
1 parent 14262af commit 4372fa8

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

cores/esp8266/FS.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ class FS
245245

246246
} // namespace fs
247247

248+
extern "C"
249+
{
250+
void littlefs_weak_end(void);
251+
void spiffs_weak_end(void);
252+
}
253+
248254
#ifndef FS_NO_GLOBALS
249255
using fs::FS;
250256
using fs::File;

cores/esp8266/spiffs_api.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ bool isSpiffsFilenameValid(const char* name)
127127

128128
}; // namespace
129129

130+
extern "C" void spiffs_weak_end(void)
131+
{
132+
//ets_printf("debug: not weak spiffs end\n");
133+
SPIFFS.end();
134+
}
135+
130136
// these symbols should be defined in the linker script for each flash layout
131137
#ifndef CORE_MOCK
132138
#ifdef ARDUINO

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <WiFiUdp.h>
66
#include <flash_hal.h>
77
#include <FS.h>
8-
#include <LittleFS.h>
98
#include "StreamString.h"
109
#include "ESP8266HTTPUpdateServer.h"
1110

@@ -94,8 +93,8 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
9493
Serial.printf("Update: %s\n", upload.filename.c_str());
9594
if (upload.name == "filesystem") {
9695
size_t fsSize = ((size_t) &_FS_end - (size_t) &_FS_start);
97-
SPIFFS.end();
98-
LittleFS.end();
96+
spiffs_weak_end();
97+
littlefs_weak_end();
9998
if (!Update.begin(fsSize, U_FS)){//start with max available size
10099
if (_serial_output) Update.printError(Serial);
101100
}

libraries/LittleFS/src/LittleFS.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ int LittleFSImpl::lfs_flash_sync(const struct lfs_config *c) {
181181

182182
}; // namespace
183183

184+
extern "C" void littlefs_weak_end(void)
185+
{
186+
//ets_printf("debug: not weak littlefs end\n");
187+
LittleFS.end();
188+
}
189+
184190
// these symbols should be defined in the linker script for each flash layout
185191
#ifndef CORE_MOCK
186192
#ifdef ARDUINO

0 commit comments

Comments
 (0)