Skip to content

Commit 51e1e34

Browse files
Merge branch 'master' into reducei2ciram
2 parents 3552bfc + 8dd068e commit 51e1e34

File tree

97 files changed

+2271
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2271
-729
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ tools/xtensa-lx106-elf/
44
tools/mkspiffs/
55
tools/mklittlefs/
66
tools/python/
7+
tools/python3/
78
package/versions/
89
exclude.txt
910
tools/sdk/lib/liblwip_src.a

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ jobs:
107107
script: $TRAVIS_BUILD_DIR/tests/buildm.sh
108108
env: CC=gcc-7 CXX=g++-7
109109

110+
- name: "Mac OSX can build sketches"
111+
os: osx
112+
stage: build
113+
script: $TRAVIS_BUILD_DIR/tests/build.sh
114+
env: MACOSX=1 BUILD_PARITY=custom mod=500 rem=1
115+
116+
- name: "Windows can build sketches"
117+
os: windows
118+
stage: build
119+
script: $TRAVIS_BUILD_DIR/tests/build.sh
120+
env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1
121+
110122
- name: "Boards"
111123
stage: build
112124
script: $TRAVIS_BUILD_DIR/tests/ci/build_boards.sh

boards.txt

+346-196
Large diffs are not rendered by default.

cores/esp8266/AddrList.h

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct netifWrapper
128128
const char* ifmac () const { return (const char*)_netif->hwaddr; }
129129
int ifnumber () const { return _netif->num; }
130130
bool ifUp () const { return !!(_netif->flags & NETIF_FLAG_UP); }
131+
CONST netif* interface () const { return _netif; }
131132

132133
const ip_addr_t* ipFromNetifNum () const
133134
{

cores/esp8266/Arduino.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ using std::max;
251251
using std::isinf;
252252
using std::isnan;
253253

254-
#define _min(a,b) ((a)<(b)?(a):(b))
255-
#define _max(a,b) ((a)>(b)?(a):(b))
254+
#define _min(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a < _b? _a : _b; })
255+
#define _max(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a > _b? _a : _b; })
256256

257257
uint16_t makeWord(uint16_t w);
258258
uint16_t makeWord(byte h, byte l);

cores/esp8266/Esp.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ class EspClass {
201201
bool eraseConfig();
202202

203203
#ifndef CORE_MOCK
204-
inline
205-
#endif
204+
inline uint32_t getCycleCount() __attribute__((always_inline));
205+
#else
206206
uint32_t getCycleCount();
207+
#endif
207208
};
208209

209210
#ifndef CORE_MOCK

cores/esp8266/HardwareSerial.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ unsigned long HardwareSerial::testBaudrate()
121121

122122
unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
123123
{
124-
time_t startMillis = millis();
124+
esp8266::polledTimeout::oneShotFastMs timeOut(timeoutMillis);
125125
unsigned long detectedBaudrate;
126-
while ((time_t) millis() - startMillis < timeoutMillis) {
126+
while (!timeOut) {
127127
if ((detectedBaudrate = testBaudrate())) {
128128
break;
129129
}

cores/esp8266/Print.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ size_t Print::write(const uint8_t *buffer, size_t size) {
4545

4646
size_t n = 0;
4747
while (size--) {
48-
size_t ret = write(*buffer++);
48+
size_t ret = write(pgm_read_byte(buffer++));
4949
if (ret == 0) {
5050
// Write of last byte didn't complete, abort additional processing
5151
break;

cores/esp8266/Print.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Print {
5656
size_t write(const char *str) {
5757
if(str == NULL)
5858
return 0;
59-
return write((const uint8_t *) str, strlen(str));
59+
return write((const uint8_t *) str, strlen_P(str));
6060
}
6161
virtual size_t write(const uint8_t *buffer, size_t size);
6262
size_t write(const char *buffer, size_t size) {

cores/esp8266/StreamString.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ size_t StreamString::write(const uint8_t *data, size_t size) {
3232
*(wbuffer() + newlen) = 0x00; // add null for string end
3333
return size;
3434
}
35+
DEBUGV(":stream2string: OOM (%d->%d)\n", length(), newlen+1);
3536
}
3637
return 0;
3738
}

cores/esp8266/Updater.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "Updater.h"
2-
#include "Arduino.h"
32
#include "eboot_command.h"
43
#include <esp8266_peri.h>
54

@@ -11,10 +10,10 @@
1110
#endif
1211

1312
#if ARDUINO_SIGNING
14-
#include "../../libraries/ESP8266WiFi/src/BearSSLHelpers.h"
15-
static BearSSL::PublicKey signPubKey(signing_pubkey);
16-
static BearSSL::HashSHA256 hash;
17-
static BearSSL::SigningVerifier sign(&signPubKey);
13+
namespace esp8266 {
14+
extern UpdaterHashClass& updaterSigningHash;
15+
extern UpdaterVerifyClass& updaterSigningVerifier;
16+
}
1817
#endif
1918

2019
extern "C" {
@@ -39,7 +38,7 @@ UpdaterClass::UpdaterClass()
3938
, _progress_callback(nullptr)
4039
{
4140
#if ARDUINO_SIGNING
42-
installSignature(&hash, &sign);
41+
installSignature(&esp8266::updaterSigningHash, &esp8266::updaterSigningVerifier);
4342
#endif
4443
}
4544

cores/esp8266/WString.cpp

+14-19
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ unsigned char String::changeBuffer(unsigned int maxStrLen) {
185185
size_t oldSize = capacity() + 1; // include NULL.
186186
if (isSSO()) {
187187
// Copy the SSO buffer into allocated space
188-
memmove(newbuffer, sso.buff, sizeof(sso.buff));
188+
memmove_P(newbuffer, sso.buff, sizeof(sso.buff));
189189
}
190190
if (newSize > oldSize)
191191
{
@@ -210,7 +210,7 @@ String & String::copy(const char *cstr, unsigned int length) {
210210
return *this;
211211
}
212212
setLen(length);
213-
memmove(wbuffer(), cstr, length + 1);
213+
memmove_P(wbuffer(), cstr, length + 1);
214214
return *this;
215215
}
216216

@@ -228,7 +228,7 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length) {
228228
void String::move(String &rhs) {
229229
if(buffer()) {
230230
if(capacity() >= rhs.len()) {
231-
memmove(wbuffer(), rhs.buffer(), rhs.length() + 1);
231+
memmove_P(wbuffer(), rhs.buffer(), rhs.length() + 1);
232232
setLen(rhs.len());
233233
rhs.invalidate();
234234
return;
@@ -241,7 +241,7 @@ void String::move(String &rhs) {
241241
}
242242
if (rhs.isSSO()) {
243243
setSSO(true);
244-
memmove(sso.buff, rhs.sso.buff, sizeof(sso.buff));
244+
memmove_P(sso.buff, rhs.sso.buff, sizeof(sso.buff));
245245
} else {
246246
setSSO(false);
247247
setBuffer(rhs.wbuffer());
@@ -313,7 +313,7 @@ unsigned char String::concat(const String &s) {
313313
return 1;
314314
if (!reserve(newlen))
315315
return 0;
316-
memmove(wbuffer() + len(), buffer(), len());
316+
memmove_P(wbuffer() + len(), buffer(), len());
317317
setLen(newlen);
318318
wbuffer()[len()] = 0;
319319
return 1;
@@ -330,12 +330,7 @@ unsigned char String::concat(const char *cstr, unsigned int length) {
330330
return 1;
331331
if(!reserve(newlen))
332332
return 0;
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);
333+
memmove_P(wbuffer() + len(), cstr, length + 1);
339334
setLen(newlen);
340335
return 1;
341336
}
@@ -739,21 +734,21 @@ void String::replace(const String& find, const String& replace) {
739734
char *foundAt;
740735
if(diff == 0) {
741736
while((foundAt = strstr(readFrom, find.buffer())) != NULL) {
742-
memmove(foundAt, replace.buffer(), replace.len());
737+
memmove_P(foundAt, replace.buffer(), replace.len());
743738
readFrom = foundAt + replace.len();
744739
}
745740
} else if(diff < 0) {
746741
char *writeTo = wbuffer();
747742
while((foundAt = strstr(readFrom, find.buffer())) != NULL) {
748743
unsigned int n = foundAt - readFrom;
749-
memmove(writeTo, readFrom, n);
744+
memmove_P(writeTo, readFrom, n);
750745
writeTo += n;
751-
memmove(writeTo, replace.buffer(), replace.len());
746+
memmove_P(writeTo, replace.buffer(), replace.len());
752747
writeTo += replace.len();
753748
readFrom = foundAt + find.len();
754749
setLen(len() + diff);
755750
}
756-
memmove(writeTo, readFrom, strlen(readFrom)+1);
751+
memmove_P(writeTo, readFrom, strlen(readFrom)+1);
757752
} else {
758753
unsigned int size = len(); // compute size needed for result
759754
while((foundAt = strstr(readFrom, find.buffer())) != NULL) {
@@ -767,9 +762,9 @@ void String::replace(const String& find, const String& replace) {
767762
int index = len() - 1;
768763
while(index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
769764
readFrom = wbuffer() + index + find.len();
770-
memmove(readFrom + diff, readFrom, len() - (readFrom - buffer()));
765+
memmove_P(readFrom + diff, readFrom, len() - (readFrom - buffer()));
771766
int newLen = len() + diff;
772-
memmove(wbuffer() + index, replace.buffer(), replace.len());
767+
memmove_P(wbuffer() + index, replace.buffer(), replace.len());
773768
setLen(newLen);
774769
wbuffer()[newLen] = 0;
775770
index--;
@@ -797,7 +792,7 @@ void String::remove(unsigned int index, unsigned int count) {
797792
char *writeTo = wbuffer() + index;
798793
unsigned int newlen = len() - count;
799794
setLen(newlen);
800-
memmove(writeTo, wbuffer() + index + count, newlen - index);
795+
memmove_P(writeTo, wbuffer() + index + count, newlen - index);
801796
wbuffer()[newlen] = 0;
802797
}
803798

@@ -829,7 +824,7 @@ void String::trim(void) {
829824
unsigned int newlen = end + 1 - begin;
830825
setLen(newlen);
831826
if(begin > buffer())
832-
memmove(wbuffer(), begin, newlen);
827+
memmove_P(wbuffer(), begin, newlen);
833828
wbuffer()[newlen] = 0;
834829
}
835830

cores/esp8266/abi.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
3232
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
3333

3434

35-
#ifndef __cpp_exceptions
35+
#if !defined(__cpp_exceptions) && !defined(NEW_OOM_ABORT)
3636
void *operator new(size_t size)
3737
{
3838
void *ret = malloc(size);
@@ -52,7 +52,7 @@ void *operator new[](size_t size)
5252
}
5353
return ret;
5454
}
55-
#endif
55+
#endif // arduino's std::new legacy
5656

5757
void __cxa_pure_virtual(void)
5858
{

cores/esp8266/core_esp8266_eboot_command.cpp

+3-24
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,15 @@
2121

2222
#include <stddef.h>
2323
#include <stdbool.h>
24+
#include "coredecls.h"
2425
#include "eboot_command.h"
2526

26-
extern "C" {
2727

28-
static uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
29-
{
30-
uint32_t i;
31-
bool bit;
32-
uint8_t c;
33-
34-
while (length--) {
35-
c = *data++;
36-
for (i = 0x80; i > 0; i >>= 1) {
37-
bit = crc & 0x80000000;
38-
if (c & i) {
39-
bit = !bit;
40-
}
41-
crc <<= 1;
42-
if (bit) {
43-
crc ^= 0x04c11db7;
44-
}
45-
}
46-
}
47-
return crc;
48-
}
28+
extern "C" {
4929

5030
static uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd)
5131
{
52-
return crc_update(0xffffffff, (const uint8_t*) cmd,
53-
offsetof(struct eboot_command, crc32));
32+
return crc32((const uint8_t*) cmd, offsetof(struct eboot_command, crc32));
5433
}
5534

5635
int eboot_command_read(struct eboot_command* cmd)

cores/esp8266/core_esp8266_features.h

+34-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,37 @@
3232

3333
#define WIFI_HAS_EVENT_CALLBACK
3434

35+
#ifdef __cplusplus
36+
37+
#include <stdlib.h> // malloc()
38+
#include <stddef.h> // size_t
39+
40+
namespace arduino
41+
{
42+
extern "C++"
43+
template <typename T, typename ...TConstructorArgs>
44+
T* new0 (size_t n, TConstructorArgs... TconstructorArgs)
45+
{
46+
// n==0: single allocation, otherwise it is an array
47+
size_t offset = n? sizeof(size_t): 0;
48+
size_t arraysize = n? n: 1;
49+
T* ptr = (T*)malloc(offset + (arraysize * sizeof(T)));
50+
if (ptr)
51+
{
52+
if (n)
53+
*(size_t*)(ptr) = n;
54+
for (size_t i = 0; i < arraysize; i++)
55+
new (ptr + offset + i * sizeof(T)) T(TconstructorArgs...);
56+
return ptr + offset;
57+
}
58+
return nullptr;
59+
}
60+
}
61+
62+
#define arduino_new(Type, ...) arduino::new0<Type>(0, ##__VA_ARGS__)
63+
#define arduino_newarray(Type, n, ...) arduino::new0<Type>(n, ##__VA_ARGS__)
64+
65+
#endif // __cplusplus
3566

3667
#ifndef __STRINGIFY
3768
#define __STRINGIFY(a) #a
@@ -54,11 +85,12 @@
5485
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
5586
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
5687

57-
inline uint32_t esp_get_cycle_count() {
88+
inline uint32_t esp_get_cycle_count() __attribute__((always_inline));
89+
inline uint32_t esp_get_cycle_count() {
5890
uint32_t ccount;
5991
__asm__ __volatile__("rsr %0,ccount":"=a"(ccount));
6092
return ccount;
6193
}
6294
#endif // not CORE_MOCK
6395

64-
#endif
96+
#endif // CORE_ESP8266_FEATURES_H

0 commit comments

Comments
 (0)