Skip to content

Commit 85d836b

Browse files
Merge branch 'master' into bugfix/ESP8266HTTPClient
2 parents 25f3a84 + 0a031ce commit 85d836b

Some content is hidden

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

52 files changed

+648
-129
lines changed

boards.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -761,15 +761,15 @@ esp8285.menu.baud.3000000.upload.speed=3000000
761761
espduino.name=ESPDuino (ESP-13 Module)
762762
espduino.build.board=ESP8266_ESP13
763763
espduino.build.variant=ESPDuino
764-
espduino.menu.ResetMethod.v2=ESPduino-V2
765-
espduino.menu.ResetMethod.v2.upload.resetmethod=nodemcu
766764
espduino.menu.ResetMethod.v1=ESPduino-V1
767765
espduino.menu.ResetMethod.v1.upload.resetmethod=ck
766+
espduino.menu.ResetMethod.v2=ESPduino-V2
767+
espduino.menu.ResetMethod.v2.upload.resetmethod=nodemcu
768+
espduino.menu.UploadTool.espota=OTA
769+
espduino.menu.UploadTool.espota.upload.tool=espota
768770
espduino.menu.UploadTool.esptool=Serial
769771
espduino.menu.UploadTool.esptool.upload.tool=esptool
770772
espduino.menu.UploadTool.esptool.upload.verbose=--trace
771-
espduino.menu.UploadTool.espota=OTA
772-
espduino.menu.UploadTool.espota.upload.tool=espota
773773
espduino.upload.tool=esptool
774774
espduino.upload.maximum_data_size=81920
775775
espduino.upload.wait_for_upload_port=true
@@ -4592,20 +4592,20 @@ wifinfo.build.board=WIFINFO
45924592
wifinfo.build.variant=wifinfo
45934593
wifinfo.menu.ESPModule.ESP07192=ESP07 (1M/192K SPIFFS)
45944594
wifinfo.menu.ESPModule.ESP07192.build.board=ESP8266_ESP07
4595-
wifinfo.menu.ESPModule.ESP07192.build.flash_size=1M
45964595
wifinfo.menu.ESPModule.ESP07192.build.flash_ld=eagle.flash.1m192.ld
4597-
wifinfo.menu.ESPModule.ESP07192.build.spiffs_start=0xCB000
4598-
wifinfo.menu.ESPModule.ESP07192.build.spiffs_end=0xFB000
4596+
wifinfo.menu.ESPModule.ESP07192.build.flash_size=1M
45994597
wifinfo.menu.ESPModule.ESP07192.build.spiffs_blocksize=4096
4598+
wifinfo.menu.ESPModule.ESP07192.build.spiffs_end=0xFB000
4599+
wifinfo.menu.ESPModule.ESP07192.build.spiffs_start=0xCB000
46004600
wifinfo.menu.ESPModule.ESP07192.upload.maximum_size=827376
46014601
wifinfo.menu.ESPModule.ESP12=ESP12 (4M/1M SPIFFS)
46024602
wifinfo.menu.ESPModule.ESP12.build.board=ESP8266_ESP12
4603-
wifinfo.menu.ESPModule.ESP12.build.flash_size=4M
46044603
wifinfo.menu.ESPModule.ESP12.build.flash_ld=eagle.flash.4m1m.ld
4605-
wifinfo.menu.ESPModule.ESP12.build.spiffs_start=0x300000
4606-
wifinfo.menu.ESPModule.ESP12.build.spiffs_end=0x3FB000
4604+
wifinfo.menu.ESPModule.ESP12.build.flash_size=4M
46074605
wifinfo.menu.ESPModule.ESP12.build.spiffs_blocksize=8192
4606+
wifinfo.menu.ESPModule.ESP12.build.spiffs_end=0x3FB000
46084607
wifinfo.menu.ESPModule.ESP12.build.spiffs_pagesize=256
4608+
wifinfo.menu.ESPModule.ESP12.build.spiffs_start=0x300000
46094609
wifinfo.menu.ESPModule.ESP12.upload.maximum_size=1044464
46104610
wifinfo.upload.tool=esptool
46114611
wifinfo.upload.maximum_data_size=81920
@@ -4839,16 +4839,16 @@ arduino-esp8266.name=Arduino
48394839
arduino-esp8266.build.board=ESP8266_ARDUINO
48404840
arduino-esp8266.menu.BoardModel.primo=Primo
48414841
arduino-esp8266.menu.BoardModel.primo.build.board=ESP8266_ARDUINO_PRIMO
4842-
arduino-esp8266.menu.BoardModel.primo.build.variant=arduino_spi
48434842
arduino-esp8266.menu.BoardModel.primo.build.extra_flags=-DF_CRYSTAL=40000000 -DESP8266
4844-
arduino-esp8266.menu.BoardModel.unowifideved=Uno WiFi
4845-
arduino-esp8266.menu.BoardModel.unowifideved.build.board=ESP8266_ARDUINO_UNOWIFI
4846-
arduino-esp8266.menu.BoardModel.unowifideved.build.variant=arduino_uart
4847-
arduino-esp8266.menu.BoardModel.unowifideved.build.extra_flags=-DF_CRYSTAL=40000000 -DESP8266
4843+
arduino-esp8266.menu.BoardModel.primo.build.variant=arduino_spi
48484844
arduino-esp8266.menu.BoardModel.starottodeved=Star OTTO
4849-
arduino-esp8266.menu.BoardModel.starottodeved.build.variant=arduino_uart
48504845
arduino-esp8266.menu.BoardModel.starottodeved.build.board=ESP8266_ARDUINO_STAR_OTTO
48514846
arduino-esp8266.menu.BoardModel.starottodeved.build.extra_flags=-DF_CRYSTAL=40000000 -DESP8266
4847+
arduino-esp8266.menu.BoardModel.starottodeved.build.variant=arduino_uart
4848+
arduino-esp8266.menu.BoardModel.unowifideved=Uno WiFi
4849+
arduino-esp8266.menu.BoardModel.unowifideved.build.board=ESP8266_ARDUINO_UNOWIFI
4850+
arduino-esp8266.menu.BoardModel.unowifideved.build.extra_flags=-DF_CRYSTAL=40000000 -DESP8266
4851+
arduino-esp8266.menu.BoardModel.unowifideved.build.variant=arduino_uart
48524852
arduino-esp8266.upload.tool=esptool
48534853
arduino-esp8266.upload.maximum_data_size=81920
48544854
arduino-esp8266.upload.wait_for_upload_port=true

cores/esp8266/Print.cpp

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/Updater.cpp

Lines changed: 5 additions & 6 deletions
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/uart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ uart_write(uart_t* uart, const char* buf, size_t size)
495495
size_t ret = size;
496496
const int uart_nr = uart->uart_nr;
497497
while (size--)
498-
uart_do_write_char(uart_nr, *buf++);
498+
uart_do_write_char(uart_nr, pgm_read_byte(buf++));
499499

500500
return ret;
501501
}

doc/eclipse/makefile.init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ESP8266_BASE = $(ARDUINO_BASE)/hardware/esp8266com/esp8266
1414
ESP8266_TOOLS = $(ESP8266_BASE)/tools
1515
XTENSA_TOOLS_ROOT = $(ESP8266_TOOLS)/xtensa-lx106-elf/bin
1616

17-
PYTHON_BIN = python
17+
PYTHON_BIN = python3
1818
ESPTOOL_PY_BIN = $(ESP8266_TOOLS)/esptool.py
1919
ESPOTA_PY_BIN = $(ESP8266_TOOLS)/espota.py
2020
ESPTOOL_BIN = $(ESP8266_TOOLS)/esptool/esptool.exe

doc/installing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Prerequisites
4343

4444
- Arduino 1.6.8 (or newer, current working version is 1.8.5)
4545
- git
46-
- Python 2.7 (https://python.org)
46+
- Python 3.x (https://python.org)
4747
- terminal, console, or command prompt (depending on your OS)
4848
- Internet connection
4949

@@ -110,7 +110,7 @@ Instructions - Windows 10
110110
.. code:: bash
111111
112112
cd esp8266/tools
113-
python get.py
113+
python3 get.py
114114
115115
- Restart Arduino
116116
@@ -184,7 +184,7 @@ Instructions - Other OS
184184
.. code:: bash
185185
186186
cd esp8266/tools
187-
python get.py
187+
python3 get.py
188188
189189
- Restart Arduino
190190

doc/ota_updates/readme.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Instructions below show configuration of OTA on NodeMCU 1.0 (ESP-12E Module) boa
193193
- esp8266/Arduino platform package 2.0.0 or newer - for instructions
194194
follow
195195
https://github.com/esp8266/Arduino#installing-with-boards-manager
196-
- Python 2.7 - https://www.python.org/
196+
- Python 3.x - https://www.python.org/
197197

198198
**Note:** Windows users should select “Add python.exe to Path”
199199
(see below – this option is not selected by default).

libraries/ESP8266HTTPClient/examples/BasicHttpsClient/BasicHttpsClient.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <ESP8266HTTPClient.h>
1414

1515
#include <WiFiClientSecureBearSSL.h>
16-
// Fingerprint for demo URL, expires on June 2, 2019, needs to be updated well before this date
17-
const uint8_t fingerprint[20] = {0x5A, 0xCF, 0xFE, 0xF0, 0xF1, 0xA6, 0xF4, 0x5F, 0xD2, 0x11, 0x11, 0xC6, 0x1D, 0x2F, 0x0E, 0xBC, 0x39, 0x8D, 0x50, 0xE0};
16+
// Fingerprint for demo URL, expires on June 2, 2021, needs to be updated well before this date
17+
const uint8_t fingerprint[20] = {0x40, 0xaf, 0x00, 0x6b, 0xec, 0x90, 0x22, 0x41, 0x8e, 0xa3, 0xad, 0xfa, 0x1a, 0xe8, 0x25, 0x41, 0x1d, 0x1a, 0x54, 0xb3};
1818

1919
ESP8266WiFiMulti WiFiMulti;
2020

libraries/ESP8266WiFi/examples/BearSSL_CertStore/certs-from-mozilla.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22

33
# This script pulls the list of Mozilla trusted certificate authorities
44
# from the web at the "mozurl" below, parses the file to grab the PEM
@@ -7,16 +7,18 @@
77
# and use them for your outgoing SSL connections.
88
#
99
# Script by Earle F. Philhower, III. Released to the public domain.
10-
10+
from __future__ import print_function
1111
import csv
1212
import os
13+
import sys
1314
from subprocess import Popen, PIPE, call
14-
import urllib2
1515
try:
16-
# for Python 2.x
16+
from urllib.request import urlopen
17+
except:
18+
from urllib2 import urlopen
19+
try:
1720
from StringIO import StringIO
18-
except ImportError:
19-
# for Python 3.x
21+
except:
2022
from io import StringIO
2123

2224
# Mozilla's URL for the CSV file with included PEM certs
@@ -25,9 +27,12 @@
2527
# Load the manes[] and pems[] array from the URL
2628
names = []
2729
pems = []
28-
response = urllib2.urlopen(mozurl)
30+
response = urlopen(mozurl)
2931
csvData = response.read()
30-
csvReader = csv.reader(StringIO(csvData))
32+
if sys.version_info[0] > 2:
33+
csvData = csvData.decode('utf-8')
34+
csvFile = StringIO(csvData)
35+
csvReader = csv.reader(csvFile)
3136
for row in csvReader:
3237
names.append(row[0]+":"+row[1]+":"+row[2])
3338
pems.append(row[30])
@@ -46,10 +51,10 @@
4651
for i in range(0, len(pems)):
4752
certName = "data/ca_%03d.der" % (idx);
4853
thisPem = pems[i].replace("'", "")
49-
print names[i] + " -> " + certName
54+
print(names[i] + " -> " + certName)
5055
ssl = Popen(['openssl','x509','-inform','PEM','-outform','DER','-out', certName], shell = False, stdin = PIPE)
5156
pipe = ssl.stdin
52-
pipe.write(thisPem)
57+
pipe.write(thisPem.encode('utf-8'))
5358
pipe.close()
5459
ssl.wait()
5560
if os.path.exists(certName):
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
// NAPT example released to public domain
3+
4+
#if LWIP_FEATURES && !LWIP_IPV6
5+
6+
#define HAVE_NETDUMP 0
7+
8+
#ifndef STASSID
9+
#define STASSID "mynetwork"
10+
#define STAPSK "mynetworkpassword"
11+
#endif
12+
13+
#include <ESP8266WiFi.h>
14+
#include <lwip/napt.h>
15+
#include <lwip/dns.h>
16+
#include <dhcpserver.h>
17+
18+
#define NAPT 1000
19+
#define NAPT_PORT 10
20+
21+
#if HAVE_NETDUMP
22+
23+
#include <NetDump.h>
24+
25+
void dump(int netif_idx, const char* data, size_t len, int out, int success) {
26+
(void)success;
27+
Serial.print(out ? F("out ") : F(" in "));
28+
Serial.printf("%d ", netif_idx);
29+
30+
// optional filter example: if (netDump_is_ARP(data))
31+
{
32+
netDump(Serial, data, len);
33+
//netDumpHex(Serial, data, len);
34+
}
35+
}
36+
#endif
37+
38+
void setup() {
39+
Serial.begin(115200);
40+
Serial.printf("\n\nNAPT Range extender\n");
41+
Serial.printf("Heap on start: %d\n", ESP.getFreeHeap());
42+
43+
#if HAVE_NETDUMP
44+
phy_capture = dump;
45+
#endif
46+
47+
// first, connect to STA so we can get a proper local DNS server
48+
WiFi.mode(WIFI_STA);
49+
WiFi.begin(STASSID, STAPSK);
50+
while (WiFi.status() != WL_CONNECTED) {
51+
Serial.print('.');
52+
delay(500);
53+
}
54+
Serial.printf("\nSTA: %s (dns: %s / %s)\n",
55+
WiFi.localIP().toString().c_str(),
56+
WiFi.dnsIP(0).toString().c_str(),
57+
WiFi.dnsIP(1).toString().c_str());
58+
59+
// give DNS servers to AP side
60+
dhcps_set_dns(0, WiFi.dnsIP(0));
61+
dhcps_set_dns(1, WiFi.dnsIP(1));
62+
63+
WiFi.softAPConfig( // enable AP, with android-compatible google domain
64+
IPAddress(172, 217, 28, 254),
65+
IPAddress(172, 217, 28, 254),
66+
IPAddress(255, 255, 255, 0));
67+
WiFi.softAP(STASSID "extender", STAPSK);
68+
Serial.printf("AP: %s\n", WiFi.softAPIP().toString().c_str());
69+
70+
Serial.printf("Heap before: %d\n", ESP.getFreeHeap());
71+
err_t ret = ip_napt_init(NAPT, NAPT_PORT);
72+
Serial.printf("ip_napt_init(%d,%d): ret=%d (OK=%d)\n", NAPT, NAPT_PORT, (int)ret, (int)ERR_OK);
73+
if (ret == ERR_OK) {
74+
ret = ip_napt_enable_no(SOFTAP_IF, 1);
75+
Serial.printf("ip_napt_enable_no(SOFTAP_IF): ret=%d (OK=%d)\n", (int)ret, (int)ERR_OK);
76+
if (ret == ERR_OK) {
77+
Serial.printf("WiFi Network '%s' with same password is now NATed behind '%s'\n", STASSID "extender", STASSID);
78+
}
79+
}
80+
Serial.printf("Heap after napt init: %d\n", ESP.getFreeHeap());
81+
if (ret != ERR_OK) {
82+
Serial.printf("NAPT initialization failed\n");
83+
}
84+
}
85+
86+
#else
87+
88+
void setup() {
89+
Serial.begin(115200);
90+
Serial.printf("\n\nNAPT not supported in this configuration\n");
91+
}
92+
93+
#endif
94+
95+
void loop() {
96+
}
97+

libraries/ESP8266WiFi/src/BearSSLHelpers.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2121
*/
2222

23+
#include "BearSSLHelpers.h"
2324
#include <memory>
2425
#include <vector>
2526
#include <bearssl/bearssl.h>
@@ -28,7 +29,10 @@
2829
#include <string.h>
2930
#include <Arduino.h>
3031
#include <StackThunk.h>
31-
#include "BearSSLHelpers.h"
32+
#include <Updater_Signing.h>
33+
#ifndef ARDUINO_SIGNING
34+
#define ARDUINO_SIGNING 0
35+
#endif
3236

3337
namespace brssl {
3438
// Code here is pulled from brssl sources, with the copyright and license
@@ -901,3 +905,17 @@ make_stack_thunk(br_ssl_engine_sendrec_buf);
901905
#endif
902906

903907
};
908+
909+
#if ARDUINO_SIGNING
910+
namespace {
911+
static BearSSL::PublicKey signingPubKey(signing_pubkey);
912+
static BearSSL::HashSHA256 __signingHash;
913+
static BearSSL::SigningVerifier __signingVerifier(&signingPubKey);
914+
};
915+
916+
namespace esp8266 {
917+
UpdaterHashClass& updaterSigningHash = __signingHash;
918+
UpdaterVerifyClass& updaterSigningVerifier = __signingVerifier;
919+
};
920+
#endif
921+

libraries/ESP8266WiFi/src/BearSSLHelpers.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <bearssl/bearssl.h>
2727
#include <Updater.h>
2828

29-
3029
// Internal opaque structures, not needed by user applications
3130
namespace brssl {
3231
class public_key;

libraries/ESP8266WiFi/src/include/ClientContext.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,10 @@ class ClientContext
609609
(void) err;
610610
(void) pcb;
611611
assert(pcb == _pcb);
612-
assert(_delaying);
613-
_delaying = false;
614-
esp_schedule(); // break current delay()
612+
if (_delaying) {
613+
_delaying = false;
614+
esp_schedule(); // break current delay()
615+
}
615616
return ERR_OK;
616617
}
617618

0 commit comments

Comments
 (0)