Skip to content

Commit 55c23cf

Browse files
Merge branch 'master' into xmc_flash
2 parents d49a4ec + 453eb2d commit 55c23cf

File tree

15 files changed

+1179
-944
lines changed

15 files changed

+1179
-944
lines changed

boards.txt

Lines changed: 119 additions & 123 deletions
Large diffs are not rendered by default.

cores/esp8266/CallBackList.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#ifndef __CALLBACKLIST_H__
2+
#define __CALLBACKLIST_H__
3+
4+
5+
/*
6+
CallBackList, An implemention for handling callback execution
7+
8+
Copyright (c) 2019 Herman Reintke. All rights reserved.
9+
This file is part of the esp8266 core for Arduino environment.
10+
11+
This library is free software; you can redistribute it and/or
12+
modify it under the terms of the GNU Lesser General Public
13+
License as published by the Free Software Foundation; either
14+
version 2.1 of the License, or (at your option) any later version.
15+
16+
This library is distributed in the hope that it will be useful,
17+
but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19+
Lesser General Public License for more details.
20+
21+
You should have received a copy of the GNU Lesser General Public
22+
License along with this library; if not, write to the Free Software
23+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24+
*/
25+
26+
#include <Arduino.h>
27+
#include <memory>
28+
#include <list>
29+
#include <utility>
30+
31+
namespace experimental
32+
{
33+
namespace CBListImplentation
34+
{
35+
36+
template<class cbFunctionT>
37+
class CallBackList
38+
{
39+
public:
40+
CallBackList (){};
41+
42+
struct CallBackInfo
43+
{
44+
CallBackInfo(cbFunctionT f) : cbFunction(f, true){};
45+
CallBackInfo(cbFunctionT f, bool ar) : cbFunction(f), _allowRemove(ar) {};
46+
cbFunctionT cbFunction;
47+
bool _allowRemove = true;
48+
bool allowRemove()
49+
{
50+
return _allowRemove;
51+
}
52+
};
53+
using CallBackHandler = std::shared_ptr<CallBackInfo> ;
54+
std::list<CallBackHandler> callBackEventList;
55+
56+
CallBackHandler add(cbFunctionT af, bool ad = true) {
57+
CallBackHandler handler = std::make_shared<CallBackInfo>(CallBackInfo(af,ad));
58+
callBackEventList.emplace_back(handler);
59+
return handler;
60+
}
61+
62+
void remove(CallBackHandler& dh) {
63+
callBackEventList.remove(dh);
64+
}
65+
66+
template<typename... Args>
67+
void execute(Args... params) {
68+
for(auto it = std::begin(callBackEventList); it != std::end(callBackEventList); ) {
69+
CallBackHandler &handler = *it;
70+
if (handler->allowRemove() && handler.unique()) {
71+
it = callBackEventList.erase(it);
72+
}
73+
else {
74+
handler->cbFunction(params...);
75+
++it;
76+
}
77+
}
78+
}
79+
};
80+
81+
} //CBListImplementation
82+
}//experimental
83+
84+
#endif // __CALLBACKLIST_H__

cores/esp8266/FS.h

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

246246
} // namespace fs
247247

248+
extern "C"
249+
{
250+
void close_all_fs(void);
251+
void littlefs_request_end(void);
252+
void spiffs_request_end(void);
253+
}
254+
248255
#ifndef FS_NO_GLOBALS
249256
using fs::FS;
250257
using fs::File;

cores/esp8266/FSnoop.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* no-op implementations
3+
* used/linked when no strong implementation already exists elsewhere
4+
*/
5+
6+
#include <FS.h>
7+
8+
extern "C"
9+
{
10+
11+
void close_all_fs(void)
12+
{
13+
littlefs_request_end();
14+
spiffs_request_end();
15+
}
16+
17+
// default weak definitions
18+
// they are overriden in their respective real implementation
19+
// hint: https://github.com/esp8266/Arduino/pull/6699#issuecomment-549085382
20+
21+
void littlefs_request_end(void) __attribute__((weak));
22+
void littlefs_request_end(void)
23+
{
24+
//ets_printf("debug: noop: littlefs_request_end\n");
25+
}
26+
27+
void spiffs_request_end(void) __attribute__((weak));
28+
void spiffs_request_end(void)
29+
{
30+
//ets_printf("debug: noop: spiffs_request_end\n");
31+
}
32+
33+
}

cores/esp8266/core_esp8266_main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ void preloop_update_frequency() {
9191
#endif
9292
}
9393

94+
extern "C" bool can_yield() {
95+
return cont_can_yield(g_pcont);
96+
}
9497

9598
static inline void esp_yield_within_cont() __attribute__((always_inline));
9699
static void esp_yield_within_cont() {
@@ -99,7 +102,7 @@ static void esp_yield_within_cont() {
99102
}
100103

101104
extern "C" void esp_yield() {
102-
if (cont_can_yield(g_pcont)) {
105+
if (can_yield()) {
103106
esp_yield_within_cont();
104107
}
105108
}
@@ -110,7 +113,7 @@ extern "C" void esp_schedule() {
110113
}
111114

112115
extern "C" void __yield() {
113-
if (cont_can_yield(g_pcont)) {
116+
if (can_yield()) {
114117
esp_schedule();
115118
esp_yield_within_cont();
116119
}
@@ -122,7 +125,7 @@ extern "C" void __yield() {
122125
extern "C" void yield(void) __attribute__ ((weak, alias("__yield")));
123126

124127
extern "C" void optimistic_yield(uint32_t interval_us) {
125-
if (cont_can_yield(g_pcont) &&
128+
if (can_yield() &&
126129
(system_get_time() - s_micros_at_task_start) > interval_us)
127130
{
128131
yield();

cores/esp8266/coredecls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414

1515
extern bool timeshift64_is_set;
1616

17+
bool can_yield();
1718
void esp_yield();
1819
void esp_schedule();
1920
void tune_timeshift64 (uint64_t now_us);

cores/esp8266/spiffs_api.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ FS SPIFFS = FS(FSImplPtr(new spiffs_impl::SPIFFSImpl(
141141
FS_PHYS_PAGE,
142142
FS_PHYS_BLOCK,
143143
SPIFFS_MAX_OPEN_FILES)));
144+
145+
extern "C" void spiffs_request_end(void)
146+
{
147+
// override default weak function
148+
//ets_printf("debug: not weak spiffs end\n");
149+
SPIFFS.end();
150+
}
151+
144152
#endif // ARDUINO
145153
#endif // !CORE_MOCK
146154

cores/esp8266/spiffs_api.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class SPIFFSImpl : public FSImpl
8080
memset(&_fs, 0, sizeof(_fs));
8181
}
8282

83+
~SPIFFSImpl()
84+
{
85+
end();
86+
}
87+
8388
FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) override;
8489
bool exists(const char* path) override;
8590
DirImplPtr openDir(const char* path) override;

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h

Lines changed: 1 addition & 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,7 @@ 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+
close_all_fs();
9997
if (!Update.begin(fsSize, U_FS)){//start with max available size
10098
if (_serial_output) Update.printError(Serial);
10199
}

0 commit comments

Comments
 (0)