Skip to content

Commit eb7b2b9

Browse files
Merge branch 'master' into reducei2ciram
2 parents 0cdca29 + a8873c2 commit eb7b2b9

31 files changed

+211
-24
lines changed

boards.txt

+4
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ generic.menu.led.14=14
365365
generic.menu.led.14.build.led=-DLED_BUILTIN=14
366366
generic.menu.led.15=15
367367
generic.menu.led.15.build.led=-DLED_BUILTIN=15
368+
generic.menu.led.16=16
369+
generic.menu.led.16.build.led=-DLED_BUILTIN=16
368370
generic.menu.sdk.nonosdk222_100=nonos-sdk 2.2.1+100 (testing)
369371
generic.menu.sdk.nonosdk222_100.build.sdk=NONOSDK22y
370372
generic.menu.sdk.nonosdk221=nonos-sdk 2.2.1 (legacy)
@@ -639,6 +641,8 @@ esp8285.menu.led.14=14
639641
esp8285.menu.led.14.build.led=-DLED_BUILTIN=14
640642
esp8285.menu.led.15=15
641643
esp8285.menu.led.15.build.led=-DLED_BUILTIN=15
644+
esp8285.menu.led.16=16
645+
esp8285.menu.led.16.build.led=-DLED_BUILTIN=16
642646
esp8285.menu.ip.lm2f=v2 Lower Memory
643647
esp8285.menu.ip.lm2f.build.lwip_include=lwip2/include
644648
esp8285.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat

cores/esp8266/Arduino.h

+4
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ extern "C" void configTime(long timezone, int daylightOffset_sec,
303303

304304
#include "pins_arduino.h"
305305

306+
#ifndef PUYA_SUPPORT
307+
#define PUYA_SUPPORT 1
308+
#endif
309+
306310
#endif
307311

308312
#ifdef DEBUG_ESP_OOM

cores/esp8266/FS.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ bool FS::gc() {
272272
return _impl->gc();
273273
}
274274

275+
bool FS::check() {
276+
if (!_impl) {
277+
return false;
278+
}
279+
return _impl->check();
280+
}
281+
275282
bool FS::format() {
276283
if (!_impl) {
277284
return false;

cores/esp8266/FS.h

+3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ class FS
221221
bool rmdir(const char* path);
222222
bool rmdir(const String& path);
223223

224+
// Low-level FS routines, not needed by most applications
224225
bool gc();
226+
bool check();
225227

226228
friend class ::SDClass; // More of a frenemy, but SD needs internal implementation to get private FAT bits
227229
protected:
@@ -241,6 +243,7 @@ using fs::SeekCur;
241243
using fs::SeekEnd;
242244
using fs::FSInfo;
243245
using fs::FSConfig;
246+
using fs::SPIFFSConfig;
244247
#endif //FS_NO_GLOBALS
245248

246249
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPIFFS)

cores/esp8266/FSImpl.h

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class FSImpl {
8585
virtual bool mkdir(const char* path) = 0;
8686
virtual bool rmdir(const char* path) = 0;
8787
virtual bool gc() { return true; } // May not be implemented in all file systems.
88+
virtual bool check() { return true; } // May not be implemented in all file systems.
8889
};
8990

9091
} // namespace fs

cores/esp8266/Updater.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ bool UpdaterClass::end(bool evenIfRemaining){
205205
#endif
206206
if (sigLen != _verify->length()) {
207207
_setError(UPDATE_ERROR_SIGN);
208-
_reset();
209208
return false;
210209
}
211210

@@ -231,7 +230,6 @@ bool UpdaterClass::end(bool evenIfRemaining){
231230
uint8_t *sig = (uint8_t*)malloc(sigLen);
232231
if (!sig) {
233232
_setError(UPDATE_ERROR_SIGN);
234-
_reset();
235233
return false;
236234
}
237235
ESP.flashRead(_startAddress + binSize, (uint32_t *)sig, sigLen);
@@ -244,7 +242,6 @@ bool UpdaterClass::end(bool evenIfRemaining){
244242
#endif
245243
if (!_verify->verify(_hash, (void *)sig, sigLen)) {
246244
_setError(UPDATE_ERROR_SIGN);
247-
_reset();
248245
return false;
249246
}
250247
#ifdef DEBUG_UPDATER
@@ -254,7 +251,6 @@ bool UpdaterClass::end(bool evenIfRemaining){
254251
_md5.calculate();
255252
if (strcasecmp(_target_md5.c_str(), _md5.toString().c_str())) {
256253
_setError(UPDATE_ERROR_MD5);
257-
_reset();
258254
return false;
259255
}
260256
#ifdef DEBUG_UPDATER
@@ -467,7 +463,6 @@ size_t UpdaterClass::writeStream(Stream &data) {
467463
if(toRead == 0) { //Timeout
468464
_currentAddress = (_startAddress + _size);
469465
_setError(UPDATE_ERROR_STREAM);
470-
_reset();
471466
return written;
472467
}
473468
}
@@ -494,6 +489,7 @@ void UpdaterClass::_setError(int error){
494489
#ifdef DEBUG_UPDATER
495490
printError(DEBUG_UPDATER);
496491
#endif
492+
_reset(); // Any error condition invalidates the entire update, so clear partial status
497493
}
498494

499495
void UpdaterClass::printError(Print &out){

cores/esp8266/WString.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,12 @@ unsigned char String::concat(const char *cstr, unsigned int length) {
330330
return 1;
331331
if(!reserve(newlen))
332332
return 0;
333-
memmove(wbuffer() + len(), cstr, length + 1);
333+
if (cstr >= wbuffer() && cstr < wbuffer() + len())
334+
// compatible with SSO in ram #6155 (case "x += x.c_str()")
335+
memmove(wbuffer() + len(), cstr, length + 1);
336+
else
337+
// compatible with source in flash #6367
338+
memcpy_P(wbuffer() + len(), cstr, length + 1);
334339
setLen(newlen);
335340
return 1;
336341
}

cores/esp8266/abi.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,29 @@ extern int umm_last_fail_alloc_size;
3131
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
3232
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
3333

34+
35+
#ifndef __cpp_exceptions
36+
void *operator new(size_t size)
37+
{
38+
void *ret = malloc(size);
39+
if (0 != size && 0 == ret) {
40+
umm_last_fail_alloc_addr = __builtin_return_address(0);
41+
umm_last_fail_alloc_size = size;
42+
}
43+
return ret;
44+
}
45+
46+
void *operator new[](size_t size)
47+
{
48+
void *ret = malloc(size);
49+
if (0 != size && 0 == ret) {
50+
umm_last_fail_alloc_addr = __builtin_return_address(0);
51+
umm_last_fail_alloc_size = size;
52+
}
53+
return ret;
54+
}
55+
#endif
56+
3457
void __cxa_pure_virtual(void)
3558
{
3659
panic();

cores/esp8266/core_esp8266_i2s.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ bool i2s_rxtx_begin(bool enableRx, bool enableTx) {
507507
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_I2SI_WS);
508508
}
509509

510-
_i2s_sample_rate = 0;
511510
if (!i2s_slc_begin()) {
512511
// OOM in SLC memory allocations, tear it all down and abort!
513512
i2s_end();
@@ -530,7 +529,13 @@ bool i2s_rxtx_begin(bool enableRx, bool enableTx) {
530529
// I2STXCMM, I2SRXCMM=0 => Dual channel mode
531530
I2SCC &= ~((I2STXCMM << I2STXCM) | (I2SRXCMM << I2SRXCM)); // Set RX/TX CHAN_MOD=0
532531

533-
i2s_set_rate(44100);
532+
// Ensure a sane clock is set, but don't change any pre-existing ones.
533+
// But we also need to make sure the other bits weren't reset by a previous
534+
// reset. So, store the present one, clear the flag, then set the same
535+
// value (writing all needed config bits in the process
536+
uint32_t save_rate = _i2s_sample_rate;
537+
_i2s_sample_rate = 0;
538+
i2s_set_rate(save_rate ? save_rate : 44100);
534539

535540
if (rx) {
536541
// Need to prime the # of samples to receive in the engine

cores/esp8266/spiffs_api.h

+5
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ class SPIFFSImpl : public FSImpl
219219
return SPIFFS_gc_quick( &_fs, 0 ) == SPIFFS_OK;
220220
}
221221

222+
bool check() override
223+
{
224+
return SPIFFS_check(&_fs) == SPIFFS_OK;
225+
}
226+
222227
protected:
223228
friend class SPIFFSFileImpl;
224229
friend class SPIFFSDirImpl;

cores/esp8266/uart.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
#include "Arduino.h"
4444
#include <pgmspace.h>
45-
#include "../../libraries/GDBStub/src/GDBStub.h"
45+
#include "gdb_hooks.h"
4646
#include "uart.h"
4747
#include "esp8266_peri.h"
4848
#include "user_interface.h"

doc/esp8266wifi/server-class.rst

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ Methods documented for the `Server Class <https://www.arduino.cc/en/Reference/Wi
1414

1515
Methods and properties described further down are specific to ESP8266. They are not covered in `Arduino WiFi library <https://www.arduino.cc/en/Reference/WiFi>`__ documentation. Before they are fully documented please refer to information below.
1616

17+
write (write to all clients) not supported
18+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
Please note that the ``write`` method on the ``WiFiServer`` object is not implemented and returns failure always. Use the returned
21+
``WiFiClient`` object from the ``WiFiServer::available()`` method to communicate with individual clients. If you need to send
22+
the exact same packets to a series of clients, your application must maintain a list of connected clients and iterate over them manually.
23+
1724
setNoDelay
1825
~~~~~~~~~~
1926

doc/filesystem.rst

+25
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,31 @@ block size - ``pageSize`` — filesystem logical page size - ``maxOpenFiles``
402402
``maxPathLength`` — max file name length (including one byte for zero
403403
termination)
404404

405+
gc
406+
~~
407+
408+
.. code:: cpp
409+
410+
SPIFFS.gc()
411+
412+
Only implemented in SPIFFS. Performs a quick garbage collection operation on SPIFFS,
413+
possibly making writes perform faster/better in the future. On very full or very fragmented
414+
filesystems, using this call can avoid or reduce issues where SPIFFS reports free space
415+
but is unable to write additional data to a file. See `this discussion
416+
<https://github.com/esp8266/Arduino/pull/6340#discussion_r307042268>` for more info.
417+
418+
check
419+
~~~~~
420+
421+
.. code:: cpp
422+
423+
SPIFFS.begin();
424+
SPIFFS.check();
425+
426+
Only implemented in SPIFFS. Performs an in-depth check of the filesystem metadata and
427+
correct what is repairable. Not normally needed, and not guaranteed to actually fix
428+
anything should there be corruption.
429+
405430
Directory object (Dir)
406431
----------------------
407432

libraries/ArduinoOTA/ArduinoOTA.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void ArduinoOTAClass::_runUpdate() {
330330
if (Update.end()) {
331331
client.print("OK");
332332
client.stop();
333-
delay(10);
333+
delay(1000);
334334
#ifdef OTA_DEBUG
335335
OTA_DEBUG.printf("Update Success\n");
336336
#endif

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ void HTTPClient::setRedirectLimit(uint16_t limit)
558558

559559
/**
560560
* use HTTP1.0
561-
* @param timeout
561+
* @param useHTTP10 bool
562562
*/
563563
void HTTPClient::useHTTP10(bool useHTTP10)
564564
{

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static const char serverIndex[] PROGMEM =
1616
</form>
1717
</body></html>)";
1818
static const char successResponse[] PROGMEM =
19-
"<META http-equiv=\"refresh\" content=\"15;URL=/\">Update Success! Rebooting...\n";
19+
"<META http-equiv=\"refresh\" content=\"15;URL=/\">Update Success! Rebooting...";
2020

2121
template <typename ServerType>
2222
ESP8266HTTPUpdateServerTemplate<ServerType>::ESP8266HTTPUpdateServerTemplate(bool serial_debug)

libraries/ESP8266WebServer/src/ESP8266WebServer.h

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class ESP8266WebServerTemplate
135135
void sendContent(const String& content);
136136
void sendContent_P(PGM_P content);
137137
void sendContent_P(PGM_P content, size_t size);
138+
void sendContent(const char *content) { sendContent_P(content); }
139+
void sendContent(const char *content, size_t size) { sendContent_P(content, size); }
138140

139141
static String credentialHash(const String& username, const String& realm, const String& password);
140142

libraries/GDBStub/src/GDBStub.h

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <stdint.h>
66
#include <stddef.h>
77

8+
#include <gdb_hooks.h>
89
#include "internal/gdbstub-cfg.h"
910

1011
#ifdef __cplusplus

libraries/LittleFS/lib/littlefs

platform.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ build.sslflags=
3434

3535
build.exception_flags=-fno-exceptions
3636
build.stdcpp_lib=-lstdc++
37+
build.stdcpp_level=-std=gnu++11
3738

3839
build.float=-u _printf_float -u _scanf_float
3940
build.led=
@@ -57,7 +58,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc
5758
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 {build.stdcpp_lib} -lm -lc -lgcc
5859

5960
compiler.cpp.cmd=xtensa-lx106-elf-g++
60-
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags}
61+
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 {build.stdcpp_level} -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags}
6162

6263
compiler.as.cmd=xtensa-lx106-elf-as
6364

tests/host/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ MOCK_ARDUINO_LIBS := $(addprefix common/,\
287287
MockEsp.cpp \
288288
MockEEPROM.cpp \
289289
MockSPI.cpp \
290+
strl.cpp \
290291
)
291292

292293
CPP_SOURCES_CORE_EMU = \

tests/host/common/ArduinoMain.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static struct option options[] =
152152
void cleanup ()
153153
{
154154
mock_stop_spiffs();
155-
// mock_stop_littlefs();
155+
mock_stop_littlefs();
156156
mock_stop_uart();
157157
}
158158

@@ -182,7 +182,7 @@ int main (int argc, char* const argv [])
182182

183183
for (;;)
184184
{
185-
int n = getopt_long(argc, argv, "hlcfbvi:S:s:", options, NULL);
185+
int n = getopt_long(argc, argv, "hlcfbvi:S:s:L:", options, NULL);
186186
if (n < 0)
187187
break;
188188
switch (n)
@@ -239,7 +239,7 @@ int main (int argc, char* const argv [])
239239
name += "-littlefs";
240240
name += String(littlefs_kb > 0? littlefs_kb: -littlefs_kb, DEC);
241241
name += "KB";
242-
// mock_start_littlefs(name, littlefs_kb);
242+
mock_start_littlefs(name, littlefs_kb);
243243
}
244244

245245
// setup global global_ipv4_netfmt

tests/host/common/mock.h

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#ifdef __cplusplus
3838
#include <vector>
3939
#endif
40+
#include <stddef.h>
4041

4142

4243
#ifdef __cplusplus
@@ -49,6 +50,8 @@ char* ltoa (long val, char *s, int radix);
4950
}
5051
#endif
5152

53+
size_t strlcat(char *dst, const char *src, size_t size);
54+
size_t strlcpy(char *dst, const char *src, size_t size);
5255

5356
// exotic typedefs used in the sdk
5457

0 commit comments

Comments
 (0)