Skip to content

Commit 4946465

Browse files
Merge branch 'master' into to_2.5.0-4
2 parents dc80836 + 29bedfa commit 4946465

17 files changed

+80
-30
lines changed

cores/esp8266/AddrList.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ class AddressListIterator
167167
bool operator== (AddressListIterator& o) { return netIf.equal(*o); }
168168
bool operator!= (AddressListIterator& o) { return !netIf.equal(*o); }
169169

170-
AddressListIterator& operator= (const AddressListIterator& o) { netIf = o.netIf; return *this; }
171-
172170
AddressListIterator operator++ (int)
173171
{
174172
AddressListIterator ret = *this;

cores/esp8266/Arduino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void ets_intr_unlock();
159159
// level 15 will disable ALL interrupts,
160160
// level 0 will enable ALL interrupts,
161161
//
162-
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;}))
162+
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
163163
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
164164

165165
#define interrupts() xt_rsil(0)

cores/esp8266/IPAddress.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class IPAddress: public Printable {
136136
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
137137
IPAddress& operator=(const uint8_t *address);
138138
IPAddress& operator=(uint32_t address);
139+
IPAddress& operator=(const IPAddress&) = default;
139140

140141
virtual size_t printTo(Print& p) const;
141142
String toString() const;

cores/esp8266/WString.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class String {
8282
return 0;
8383
}
8484
}
85+
inline void clear(void) {
86+
setLen(0);
87+
}
88+
inline bool isEmpty(void) const {
89+
return length() == 0;
90+
}
8591

8692
// creates a copy of the assigned value. if the value is null or
8793
// invalid, or if the memory allocation fails, the string will be

cores/esp8266/core_esp8266_postmortem.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ static void uart0_write_char_d(char c);
5252
static void uart1_write_char_d(char c);
5353
static void print_stack(uint32_t start, uint32_t end);
5454

55+
// using numbers different from "REASON_" in user_interface.h (=0..6)
56+
enum rst_reason_sw
57+
{
58+
REASON_USER_SWEXCEPTION_RST = 254
59+
};
60+
static int s_user_reset_reason = REASON_DEFAULT_RST;
61+
5562
// From UMM, the last caller of a malloc/realloc/calloc which failed:
5663
extern void *umm_last_fail_alloc_addr;
5764
extern int umm_last_fail_alloc_size;
@@ -86,24 +93,20 @@ void __wrap_system_restart_local() {
8693
register uint32_t sp asm("a1");
8794
uint32_t sp_dump = sp;
8895

89-
if (gdb_present()) {
90-
/* When GDBStub is present, exceptions are handled by GDBStub,
91-
but Soft WDT will still call this function.
92-
Trigger an exception to break into GDB.
93-
TODO: check why gdb_do_break() or asm("break.n 0") do not
94-
break into GDB here. */
95-
raise_exception();
96-
}
97-
9896
struct rst_info rst_info;
9997
memset(&rst_info, 0, sizeof(rst_info));
100-
system_rtc_mem_read(0, &rst_info, sizeof(rst_info));
101-
if (rst_info.reason != REASON_SOFT_WDT_RST &&
102-
rst_info.reason != REASON_EXCEPTION_RST &&
103-
rst_info.reason != REASON_WDT_RST)
98+
if (s_user_reset_reason == REASON_DEFAULT_RST)
10499
{
105-
return;
100+
system_rtc_mem_read(0, &rst_info, sizeof(rst_info));
101+
if (rst_info.reason != REASON_SOFT_WDT_RST &&
102+
rst_info.reason != REASON_EXCEPTION_RST &&
103+
rst_info.reason != REASON_WDT_RST)
104+
{
105+
rst_info.reason = REASON_DEFAULT_RST;
106+
}
106107
}
108+
else
109+
rst_info.reason = s_user_reset_reason;
107110

108111
// TODO: ets_install_putc1 definition is wrong in ets_sys.h, need cast
109112
ets_install_putc1((void *)&uart_write_char_d);
@@ -128,6 +131,9 @@ void __wrap_system_restart_local() {
128131
else if (rst_info.reason == REASON_SOFT_WDT_RST) {
129132
ets_printf_P(PSTR("\nSoft WDT reset\n"));
130133
}
134+
else {
135+
ets_printf_P(PSTR("\nGeneric Reset\n"));
136+
}
131137

132138
uint32_t cont_stack_start = (uint32_t) &(g_pcont->stack);
133139
uint32_t cont_stack_end = (uint32_t) g_pcont->stack_end;
@@ -222,7 +228,13 @@ static void uart1_write_char_d(char c) {
222228
}
223229

224230
static void raise_exception() {
225-
__asm__ __volatile__ ("syscall");
231+
if (gdb_present())
232+
__asm__ __volatile__ ("syscall"); // triggers GDB when enabled
233+
234+
s_user_reset_reason = REASON_USER_SWEXCEPTION_RST;
235+
ets_printf_P(PSTR("\nUser exception (panic/abort/assert)"));
236+
__wrap_system_restart_local();
237+
226238
while (1); // never reached, needed to satisfy "noreturn" attribute
227239
}
228240

cores/esp8266/core_esp8266_wiring_digital.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ extern void initPins() {
252252

253253
extern void pinMode(uint8_t pin, uint8_t mode) __attribute__ ((weak, alias("__pinMode")));
254254
extern void digitalWrite(uint8_t pin, uint8_t val) __attribute__ ((weak, alias("__digitalWrite")));
255-
extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead")));
255+
extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead"), nothrow));
256256
extern void attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode) __attribute__ ((weak, alias("__attachInterrupt")));
257257
extern void attachInterruptArg(uint8_t pin, voidFuncPtrArg handler, void* arg, int mode) __attribute__((weak, alias("__attachInterruptArg")));
258258
extern void detachInterrupt(uint8_t pin) __attribute__ ((weak, alias("__detachInterrupt")));

cores/esp8266/umm_malloc/umm_malloc_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void* realloc_loc (void* p, size_t s, const char* file, int line);
9191
#define UMM_BEST_FIT
9292

9393
/* Start addresses and the size of the heap */
94-
extern char _heap_start;
94+
extern char _heap_start[];
9595
#define UMM_MALLOC_CFG__HEAP_ADDR ((uint32_t)&_heap_start)
9696
#define UMM_MALLOC_CFG__HEAP_SIZE ((size_t)(0x3fffc000 - UMM_MALLOC_CFG__HEAP_ADDR))
9797

doc/esp8266wifi/bearssl-client-secure-class.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ See the `BearSSL_CertStore` example for full details as the `BearSSL::CertStore`
109109
Supported Crypto
110110
~~~~~~~~~~~~~~~~
111111

112-
Please see the `BearSSL website <htps://bearssl.org>`__ for detailed cryptographic information. In general, TLS 1.2, TLS 1.1, and TLS 1.0 are supported with RSA and Elliptic Curve keys and a very rich set of hashing and symmetric encryption codes. Please note that Elliptic Curve (EC) key operations take a significant amount of time.
112+
Please see the `BearSSL website <https://bearssl.org>`__ for detailed cryptographic information. In general, TLS 1.2, TLS 1.1, and TLS 1.0 are supported with RSA and Elliptic Curve keys and a very rich set of hashing and symmetric encryption codes. Please note that Elliptic Curve (EC) key operations take a significant amount of time.
113113

114114

115115
BearSSL::WiFiClientSecure Class
@@ -139,6 +139,8 @@ setFingerprint(const uint8_t fp[20]) / setFingerprint(const char \*fpStr)
139139

140140
Verify the SHA1 fingerprint of the certificate returned matches this one. If the server certificate changes, it will fail. If an array of 20 bytes are sent in, it is assumed they are the binary SHA1 values. If a `char*` string is passed in, it is parsed as a series of human-readable hex values separated by spaces or colons (e.g. `setFingerprint("00:01:02:03:...:1f");`)
141141

142+
This fingerprint is calcuated on the raw X509 certificate served by the server. In very rare cases, these certificates have certain encodings which should be normalized before taking a fingerprint (but in order to preserve memory BearSSL does not do this normalization since it would need RAM for an entire copy of the cert), and the fingerprint BearSSL calculates will not match the fingerprint OpenSSL calculates. In this case, you can enable SSL debugging and get a dump of BearSSL's calculated fingerprint and use that one in your code, or use full certificate validation. See the `original issue and debug here <https://github.com/esp8266/Arduino/issues/6209>`__.
143+
142144
setTrustAnchors(BearSSL::X509List \*ta)
143145
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144146

libraries/ESP8266WiFi/src/WiFiClientSecureAxTLS.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ extern "C" int __ax_port_read(int fd, uint8_t* buffer, size_t count)
473473
}
474474
return cb;
475475
}
476-
extern "C" void ax_port_read() __attribute__ ((weak, alias("__ax_port_read")));
476+
extern "C" int ax_port_read(int fd, uint8_t* buffer, size_t count) __attribute__ ((weak, alias("__ax_port_read")));
477477

478478
extern "C" int __ax_port_write(int fd, uint8_t* buffer, size_t count)
479479
{
@@ -489,15 +489,15 @@ extern "C" int __ax_port_write(int fd, uint8_t* buffer, size_t count)
489489
}
490490
return cb;
491491
}
492-
extern "C" void ax_port_write() __attribute__ ((weak, alias("__ax_port_write")));
492+
extern "C" int ax_port_write(int fd, uint8_t* buffer, size_t count) __attribute__ ((weak, alias("__ax_port_write")));
493493

494494
extern "C" int __ax_get_file(const char *filename, uint8_t **buf)
495495
{
496496
(void) filename;
497497
*buf = 0;
498498
return 0;
499499
}
500-
extern "C" void ax_get_file() __attribute__ ((weak, alias("__ax_get_file")));
500+
extern "C" int ax_get_file(const char *filename, uint8_t **buf) __attribute__ ((weak, alias("__ax_get_file")));
501501

502502
extern "C" void __ax_wdt_feed()
503503
{

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ extern "C" {
654654
if (!xc->done_cert) {
655655
br_sha1_update(&xc->sha1_cert, buf, len);
656656
br_x509_decoder_push(&xc->ctx, (const void*)buf, len);
657+
#ifdef DEBUG_ESP_SSL
658+
DEBUG_BSSL("CERT: ");
659+
for (size_t i=0; i<len; i++) {
660+
DEBUG_ESP_PORT.printf_P(PSTR("%02x "), buf[i] & 0xff);
661+
}
662+
DEBUG_ESP_PORT.printf_P(PSTR("\n"));
663+
#endif
657664
}
658665
}
659666

@@ -676,7 +683,24 @@ extern "C" {
676683
char res[20];
677684
br_sha1_out(&xc->sha1_cert, res);
678685
if (xc->match_fingerprint && memcmp(res, xc->match_fingerprint, sizeof(res))) {
686+
#ifdef DEBUG_ESP_SSL
679687
DEBUG_BSSL("insecure_end_chain: Received cert FP doesn't match\n");
688+
char buff[3 * sizeof(res) + 1]; // 3 chars per byte XX_, and null
689+
buff[0] = 0;
690+
for (size_t i=0; i<sizeof(res); i++) {
691+
char hex[4]; // XX_\0
692+
snprintf(hex, sizeof(hex), "%02x ", xc->match_fingerprint[i] & 0xff);
693+
strlcat(buff, hex, sizeof(buff));
694+
}
695+
DEBUG_BSSL("insecure_end_chain: expected %s\n", buff);
696+
buff[0] =0;
697+
for (size_t i=0; i<sizeof(res); i++) {
698+
char hex[4]; // XX_\0
699+
snprintf(hex, sizeof(hex), "%02x ", res[i] & 0xff);
700+
strlcat(buff, hex, sizeof(buff));
701+
}
702+
DEBUG_BSSL("insecure_end_chain: received %s\n", buff);
703+
#endif
680704
return BR_ERR_X509_NOT_TRUSTED;
681705
}
682706

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class WiFiClientSecure : public WiFiClient {
3737
WiFiClientSecure(const WiFiClientSecure &rhs);
3838
~WiFiClientSecure() override;
3939

40+
WiFiClientSecure& operator=(const WiFiClientSecure&) = default; // The shared-ptrs handle themselves automatically
41+
4042
int connect(IPAddress ip, uint16_t port) override;
4143
int connect(const String& host, uint16_t port) override;
4244
int connect(const char* name, uint16_t port) override;

libraries/ESP8266WiFi/src/WiFiServerSecureBearSSL.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class WiFiServerSecure : public WiFiServer {
6262
void setServerKeyAndCert(const uint8_t *key, int keyLen, const uint8_t *cert, int certLen);
6363
void setServerKeyAndCert_P(const uint8_t *key, int keyLen, const uint8_t *cert, int certLen);
6464

65+
WiFiServerSecure& operator=(const WiFiServerSecure&) = default;
66+
6567
using ClientType = WiFiClientSecure;
6668

6769
private:

libraries/GDBStub/src/internal/gdbstub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ void ATTR_GDBINIT gdbstub_set_uart_isr_callback(void (*func)(void*, uint8_t), vo
900900

901901

902902
//gdbstub initialization routine.
903-
void ATTR_GDBINIT gdbstub_init() {
903+
void gdbstub_init() {
904904
#if GDBSTUB_REDIRECT_CONSOLE_OUTPUT
905905
os_install_putc1(gdbstub_semihost_putchar1);
906906
#endif
@@ -923,4 +923,4 @@ bool ATTR_GDBEXTERNFN gdb_present() {
923923
}
924924

925925
void ATTR_GDBFN gdb_do_break() { gdbstub_do_break(); }
926-
void ATTR_GDBINIT gdb_init() __attribute__((alias("gdbstub_init")));
926+
void gdb_init() __attribute__((alias("gdbstub_init")));

package/build_boards_manager_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ new_json=package_esp8266com_index.json
156156

157157
set +e
158158
# Merge the old and new, then drop any obsolete package versions
159-
python ../../merge_packages.py $new_json $old_json | python ../../drop_versions.py - platforms 1.6.5-947-g39819f0 2.5.0-beta1 2.5.0-beta2 2.5.0-beta3 2.4.0-rc1 2.4.0-rc2 >tmp && mv tmp $new_json && rm $old_json
159+
python ../../merge_packages.py $new_json $old_json | python ../../drop_versions.py - tools 1.20.0-26-gb404fb9 >tmp && mv tmp $new_json && rm $old_json
160160

161161
# Verify the JSON file can be read, fail if it's not OK
162162
set -e

package/drop_versions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
from __future__ import print_function
55
import json
66
import sys
7+
from collections import OrderedDict
78

89
def load_package(filename):
910
if filename == "-":
10-
pkg = json.load(sys.stdin)['packages'][0]
11+
pkg = json.load(sys.stdin, object_pairs_hook=OrderedDict)['packages'][0]
1112
else:
12-
pkg = json.load(open(filename))['packages'][0]
13+
pkg = json.load(open(filename), object_pairs_hook=OrderedDict)['packages'][0]
1314
print("Loaded package {0} from {1}".format(pkg['name'], filename), file=sys.stderr)
1415
print("{0} platform(s), {1} tools".format(len(pkg['platforms']), len(pkg['tools'])), file=sys.stderr)
1516
return pkg

tools/sdk/ld/eagle.app.v6.common.ld.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ SECTIONS
129129

130130
*(.text.app_entry*) /* The main startup code */
131131

132+
*(.text.gdbstub*, .text.gdb_init) /* Any GDB hooks */
133+
132134
/* all functional callers are placed in IRAM (including SPI/IRQ callbacks/etc) here */
133135
*(.text._ZNKSt8functionIF*EE*) /* std::function<any(...)>::operator()() const */
134136
} >iram1_0_seg :iram1_0_phdr

0 commit comments

Comments
 (0)