Skip to content

Commit 74e6e9e

Browse files
committed
Merge remote-tracking branch 'remotes/esp8266/master'
2 parents 83b452b + 254e4d9 commit 74e6e9e

18 files changed

+216
-105
lines changed

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
1414
- Enter ```http://arduino.esp8266.com/stable/package_esp8266com_index.json``` into *Additional Board Manager URLs* field. You can add multiple URLs, separating them with commas.
1515
- Open Boards Manager from Tools > Board menu and install *esp8266* platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
1616

17+
The best place to ask questions related to this core is ESP8266 community forum: http://www.esp8266.com/arduino.
18+
If you find this ESP8266 board manager useful, please consider supporting it with a donation. The ESP8266 Community Forum and IGRR have made this wonderful port available.
19+
[![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/webscr?cmd=_s-xclick&hosted_button_id=4M56YCWV6PX66)
20+
1721
#### Available versions
1822

1923
##### Stable version ![](http://arduino.esp8266.com/stable/badge.svg)
@@ -26,7 +30,6 @@ Boards manager link: `http://arduino.esp8266.com/staging/package_esp8266com_inde
2630

2731
Documentation: [Reference](http://arduino.esp8266.com/staging/doc/reference.html)
2832

29-
3033
### Using git version [![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)
3134

3235
- Install Arduino 1.6.5
@@ -54,10 +57,6 @@ Documentation for latest development version:
5457

5558
### Issues and support ###
5659

57-
The best place to ask questions related to this core is ESP8266 community forum: http://www.esp8266.com/arduino.
58-
If you find the forum useful, please consider supporting it with a donation.
59-
[![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/webscr?cmd=_s-xclick&hosted_button_id=4M56YCWV6PX66)
60-
6160
If you encounter an issue, you are welcome to submit it here on Github: https://github.com/esp8266/Arduino/issues.
6261
Please provide as much context as possible: version which you are using (you can check it in Boards Manager), your sketch code, serial output, board model, IDE settings (board selection, flash size, etc).
6362

boards.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ d1.menu.UploadTool.esptool.upload.verbose=-vv
584584
d1.menu.UploadTool.espota=OTA
585585
d1.menu.UploadTool.espota.upload.tool=espota
586586

587+
d1.menu.UploadSpeed.921600=921600
588+
d1.menu.UploadSpeed.921600.upload.speed=921600
587589
d1.menu.UploadSpeed.115200=115200
588590
d1.menu.UploadSpeed.115200.upload.speed=115200
589591
d1.menu.UploadSpeed.9600=9600
@@ -601,8 +603,7 @@ d1.menu.UploadSpeed.460800.macosx=460800
601603
d1.menu.UploadSpeed.460800.upload.speed=460800
602604
d1.menu.UploadSpeed.512000.windows=512000
603605
d1.menu.UploadSpeed.512000.upload.speed=512000
604-
d1.menu.UploadSpeed.921600=921600
605-
d1.menu.UploadSpeed.921600.upload.speed=921600
606+
606607

607608
d1.menu.FlashSize.4M3M=4M (3M SPIFFS)
608609
d1.menu.FlashSize.4M3M.build.flash_size=4M
@@ -654,6 +655,8 @@ d1_mini.menu.UploadTool.esptool.upload.verbose=-vv
654655
d1_mini.menu.UploadTool.espota=OTA
655656
d1_mini.menu.UploadTool.espota.upload.tool=espota
656657

658+
d1_mini.menu.UploadSpeed.921600=921600
659+
d1_mini.menu.UploadSpeed.921600.upload.speed=921600
657660
d1_mini.menu.UploadSpeed.115200=115200
658661
d1_mini.menu.UploadSpeed.115200.upload.speed=115200
659662
d1_mini.menu.UploadSpeed.9600=9600
@@ -671,8 +674,7 @@ d1_mini.menu.UploadSpeed.460800.macosx=460800
671674
d1_mini.menu.UploadSpeed.460800.upload.speed=460800
672675
d1_mini.menu.UploadSpeed.512000.windows=512000
673676
d1_mini.menu.UploadSpeed.512000.upload.speed=512000
674-
d1_mini.menu.UploadSpeed.921600=921600
675-
d1_mini.menu.UploadSpeed.921600.upload.speed=921600
677+
676678

677679
d1_mini.menu.FlashSize.4M3M=4M (3M SPIFFS)
678680
d1_mini.menu.FlashSize.4M3M.build.flash_size=4M

cores/esp8266/core_esp8266_postmortem.c

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ static void uart1_write_char_d(char c);
3737
static void print_stack(uint32_t start, uint32_t end);
3838
//static void print_pcs(uint32_t start, uint32_t end);
3939

40+
extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
41+
}
42+
43+
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
44+
4045
void __wrap_system_restart_local() {
4146
register uint32_t sp asm("a1");
4247

@@ -92,6 +97,9 @@ void __wrap_system_restart_local() {
9297

9398
// print_pcs(sp + offset, stack_end);
9499
print_stack(sp + offset, stack_end);
100+
101+
custom_crash_callback( &rst_info, sp + offset, stack_end );
102+
95103
delayMicroseconds(10000);
96104
__real_system_restart_local();
97105
}

doc/boards.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ title: Supported Hardware
1010
- [SparkFun ESP8266 Thing](#sparkfun-esp8266-thing)
1111
- [SweetPea ESP-210](#sweetpea-esp-210)
1212
- [Generic ESP8266 modules](#generic-esp8266-modules)
13+
- [WeMos D1](#wemos-d1)
14+
- [WeMos D1 mini](#wemos-d1-mini)
1315

1416
### Adafruit HUZZAH ESP8266 (ESP-12)
1517

@@ -212,4 +214,7 @@ the first value respects the pin setup of the Pins 0, 2 and 15.
212214
note:
213215
- number = ((GPIO15 << 2) | (GPIO0 << 1) | GPIO2);
214216

215-
217+
### WeMos D1
218+
Product page: http://wemos.cc
219+
### WeMos D1 mini
220+
Product page: http://wemos.cc

doc/reference.md

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ NodeMCU 1.0 | 4M | 1M, 3M
167167
Olimex MOD-WIFI-ESP8266(-DEV)| 2M | 1M
168168
SparkFun Thing | 512k | 64k
169169
SweetPea ESP-210 | 4M | 1M, 3M
170+
WeMos D1 & D1 mini | 4M | 1M, 3M
170171

171172
**Note:** to use any of file system functions in the sketch, add the following include to the sketch:
172173

libraries/ESP8266WebServer/src/ESP8266WebServer.cpp

+15-6
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,32 @@
3131
#define DEBUG_OUTPUT Serial
3232

3333

34+
ESP8266WebServer::ESP8266WebServer(IPAddress addr, int port)
35+
: _server(addr, port)
36+
, _firstHandler(0)
37+
, _lastHandler(0)
38+
, _currentArgCount(0)
39+
, _currentArgs(0)
40+
, _headerKeysCount(0)
41+
, _currentHeaders(0)
42+
{
43+
}
44+
3445
ESP8266WebServer::ESP8266WebServer(int port)
3546
: _server(port)
3647
, _firstHandler(0)
3748
, _lastHandler(0)
3849
, _currentArgCount(0)
3950
, _currentArgs(0)
40-
,_headerKeysCount(0)
41-
,_currentHeaders(0)
51+
, _headerKeysCount(0)
52+
, _currentHeaders(0)
4253
{
4354
}
4455

4556
ESP8266WebServer::~ESP8266WebServer() {
46-
if (_currentHeaders)
47-
delete[]_currentHeaders;
57+
if (_currentHeaders)
58+
delete[]_currentHeaders;
4859
_headerKeysCount = 0;
49-
if (!_firstHandler)
50-
return;
5160
RequestHandler* handler = _firstHandler;
5261
while (handler) {
5362
RequestHandler* next = handler->next();

libraries/ESP8266WebServer/src/ESP8266WebServer.h

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef struct {
5959
class ESP8266WebServer
6060
{
6161
public:
62+
ESP8266WebServer(IPAddress addr, int port = 80);
6263
ESP8266WebServer(int port = 80);
6364
~ESP8266WebServer();
6465

libraries/ESP8266WiFi/src/WiFiClientSecure.cpp

+39-38
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ extern "C"
5050
#define SSL_DEBUG_OPTS 0
5151
#endif
5252

53-
#define SSL_RX_BUF_SIZE 4096
5453

5554
class SSLContext {
5655
public:
@@ -59,8 +58,6 @@ class SSLContext {
5958
_ssl_ctx = ssl_ctx_new(SSL_SERVER_VERIFY_LATER | SSL_DEBUG_OPTS, 0);
6059
}
6160
++_ssl_ctx_refcnt;
62-
63-
_rxbuf = new cbuf(SSL_RX_BUF_SIZE);
6461
}
6562

6663
~SSLContext() {
@@ -73,8 +70,6 @@ class SSLContext {
7370
if (_ssl_ctx_refcnt == 0) {
7471
ssl_ctx_free(_ssl_ctx);
7572
}
76-
77-
delete _rxbuf;
7873
}
7974

8075
void ref() {
@@ -92,38 +87,50 @@ class SSLContext {
9287
}
9388

9489
int read(uint8_t* dst, size_t size) {
95-
if (!_rxbuf->getSize()) {
96-
_readAll();
90+
if (!_available) {
91+
if (!_readAll())
92+
return 0;
9793
}
98-
size_t available = _rxbuf->getSize();
99-
size_t will_read = (available < size) ? available : size;
100-
return _rxbuf->read(reinterpret_cast<char*>(dst), will_read);
94+
size_t will_copy = (_available < size) ? _available : size;
95+
memcpy(dst, _read_ptr, will_copy);
96+
_read_ptr += will_copy;
97+
_available -= will_copy;
98+
if (_available == 0) {
99+
_read_ptr = nullptr;
100+
}
101+
return will_copy;
101102
}
102103

103104
int read() {
104-
optimistic_yield(100);
105-
if (!_rxbuf->getSize()) {
106-
_readAll();
105+
if (!_available) {
106+
if (!_readAll())
107+
return -1;
107108
}
108-
return _rxbuf->read();
109+
int result = _read_ptr[0];
110+
++_read_ptr;
111+
--_available;
112+
if (_available == 0) {
113+
_read_ptr = nullptr;
114+
}
115+
return result;
109116
}
110117

111118
int peek() {
112-
if (!_rxbuf->getSize()) {
113-
_readAll();
119+
if (!_available) {
120+
if (!_readAll())
121+
return -1;
114122
}
115-
return _rxbuf->peek();
123+
return _read_ptr[0];
116124
}
117125

118126
int available() {
119-
auto rc = _rxbuf->getSize();
120-
if (rc == 0) {
121-
_readAll();
122-
rc = _rxbuf->getSize();
127+
auto cb = _available;
128+
if (cb == 0) {
129+
cb = _readAll();
123130
} else {
124131
optimistic_yield(100);
125132
}
126-
return rc;
133+
return cb;
127134
}
128135

129136
operator SSL*() {
@@ -135,6 +142,8 @@ class SSLContext {
135142
if (!_ssl)
136143
return 0;
137144

145+
optimistic_yield(100);
146+
138147
uint8_t* data;
139148
int rc = ssl_read(_ssl, &data);
140149
if (rc <= 0) {
@@ -144,25 +153,18 @@ class SSLContext {
144153
}
145154
return 0;
146155
}
147-
148-
149-
if (rc > _rxbuf->room()) {
150-
DEBUGV("WiFiClientSecure rx overflow");
151-
rc = _rxbuf->room();
152-
}
153-
int result = 0;
154-
size_t sizeBefore = _rxbuf->getSize();
155-
if (rc)
156-
result = _rxbuf->write(reinterpret_cast<const char*>(data), rc);
157-
DEBUGV("*** rb: %d + %d = %d\r\n", sizeBefore, rc, _rxbuf->getSize());
158-
return result;
156+
DEBUGV(":wcs ra %d", rc);
157+
_read_ptr = data;
158+
_available = rc;
159+
return _available;
159160
}
160161

161162
static SSL_CTX* _ssl_ctx;
162163
static int _ssl_ctx_refcnt;
163164
SSL* _ssl = nullptr;
164165
int _refcnt = 0;
165-
cbuf* _rxbuf;
166+
const uint8_t* _read_ptr = nullptr;
167+
size_t _available = 0;
166168
};
167169

168170
SSL_CTX* SSLContext::_ssl_ctx = nullptr;
@@ -313,14 +315,13 @@ bool WiFiClientSecure::verify(const char* fp, const char* url) {
313315
while (pos < len && fp[pos] == ' ') {
314316
++pos;
315317
}
316-
DEBUGV("pos:%d ", pos);
317318
if (pos > len - 2) {
318-
DEBUGV("fingerprint too short\r\n");
319+
DEBUGV("pos:%d len:%d fingerprint too short\r\n", pos, len);
319320
return false;
320321
}
321322
uint8_t high, low;
322323
if (!parseHexNibble(fp[pos], &high) || !parseHexNibble(fp[pos+1], &low)) {
323-
DEBUGV("invalid hex sequence: %c%c\r\n", fp[pos], fp[pos+1]);
324+
DEBUGV("pos:%d len:%d invalid hex sequence: %c%c\r\n", pos, len, fp[pos], fp[pos+1]);
324325
return false;
325326
}
326327
pos += 2;

0 commit comments

Comments
 (0)