Skip to content

Commit 20f372a

Browse files
committed
Merge pull request #2 from esp8266/master
pull master
2 parents 0372d0d + 3c7431b commit 20f372a

22 files changed

+348
-127
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

+56
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

@@ -162,3 +164,57 @@ ESPxx Hardware
162164

163165
### Improved Stability
164166
![ESP improved stability](ESP_improved_stability.png)
167+
168+
### Boot Messages and Modes
169+
170+
The ESP module checks at every boot the Pins 0, 2 and 15.
171+
based on them its boots in different modes:
172+
173+
| GPIO15 | GPIO0 | GPIO2 | Mode |
174+
| ------ | ----- | ----- | -------------------------------- |
175+
| 0V | 0V | 3.3V | Uart Bootloader |
176+
| 0V | 3.3V | 3.3V | Boot sketch (SPI flash) |
177+
| 3.3V | x | x | SDIO mode (not used for Arduino) |
178+
179+
180+
at startup the ESP prints out the current boot mode example:
181+
```
182+
rst cause:2, boot mode:(3,6)
183+
```
184+
185+
note:
186+
- GPIO2 is used as TX output and the internal Pullup is enabled on boot.
187+
188+
#### rst cause
189+
190+
| Number | Description |
191+
| ------ | ---------------------- |
192+
| 0 | unknown |
193+
| 1 | normal boot |
194+
| 2 | reset pin |
195+
| 3 | software reset |
196+
| 4 | watchdog reset |
197+
198+
199+
#### boot mode
200+
201+
the first value respects the pin setup of the Pins 0, 2 and 15.
202+
203+
| Number | GPIO15 | GPIO0 | GPIO2 | Mode |
204+
| ------ | ------ | ----- | ----- | ---------- |
205+
| 0 | 0V | 0V | 0V | Not valid |
206+
| 1 | 0V | 0V | 3.3V | Uart |
207+
| 2 | 0V | 3.3V | 0V | Not valid |
208+
| 3 | 0V | 3.3V | 3.3V | Flash |
209+
| 4 | 3.3V | 0V | 0V | SDIO |
210+
| 5 | 3.3V | 0V | 3.3V | SDIO |
211+
| 6 | 3.3V | 3.3V | 0V | SDIO |
212+
| 7 | 3.3V | 3.3V | 3.3V | SDIO |
213+
214+
note:
215+
- number = ((GPIO15 << 2) | (GPIO0 << 1) | GPIO2);
216+
217+
### WeMos D1
218+
Product page: http://wemos.cc
219+
### WeMos D1 mini
220+
Product page: http://wemos.cc

doc/ota_updates/ota_updates.md

+61-15
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,50 @@ title: OTA Update
1010

1111
## Introduction
1212

13-
OTA (Over the Air) update is the process of loading the firmware to ESP module using WiFi connection rather that a serial port. Such functionality became extremely useful in case of limited or no physical access to the module. There is no imposed protection on OTA update process. Such protection should be implemented by developer to ensure that updates are allowed only from legitimate / trusted source.
13+
OTA (Over the Air) update is the process of loading the firmware to ESP module using WiFi connection rather that a serial port. Such functionality became extremely useful in case of limited or no physical access to the module.
1414

1515
OTA may be done from:
1616
- [Arduino IDE](#arduino-ide)
1717
- [HTTP server](#http-server)
1818

1919
In any case first firmware upload have to be done over a serial port. If OTA routines are correctly implemented in sketch, then all subsequent uploads may be done over the air.
2020

21-
The following chapters provide more details and both methods of doing OTA.
21+
There is no imposed security on OTA process from being hacked. It is up to developer to ensure that updates are allowed only from legitimate / trusted source. Once update is complete module restarts and new code is executed. Developer should ensure that application running on module is shut down and restarted in safe manner. Chapters below provide additinal information regarding security and safety of OTA process.
22+
23+
### Security
24+
25+
Module has to be exposed wirelessly to get it updated with a new code. That poses chances of module being violently hacked and loaded with some other firmware. To reduce likelihood of being hacked consider protecting your uploads with a password, selecting certain OTA port, etc.
26+
27+
Check functionality provided with [ArduinoOTA](https://github.com/esp8266/Arduino/tree/master/libraries/ArduinoOTA) library that may improve security:
28+
```cpp
29+
void setPort(uint16_t port);
30+
void setHostname(const char *hostname);
31+
void setPassword(const char *password);
32+
```
33+
If possible implement other means of protection from being hacked, e.g. exposing module for uploads only according to specific schedule, trigger OTA only be user pressing dedicated “Update” button, etc.
34+
35+
### Safety
36+
37+
OTA process takes ESP’s resources and bandwidth during upload. Then module is restarted and a new sketch executed. Analyse and test how it affects functionality of your existing and new sketch.
38+
39+
If ESP is placed in remote location and controlling some equipment, you should put additional attention what happens if operation of this equipment is suddenly interrupted by update process. Therefore decide how to put this equipment into safe state before starting the update. For instance your module may be controlling a garden watering system in a sequence. If this sequence is not properly shut down and a water valve left open, your garden may be flooded if this valve is not closed after OTA is finished and module restarts.
40+
41+
The following functions are provided with [ArduinoOTA](https://github.com/esp8266/Arduino/tree/master/libraries/ArduinoOTA) library and intended to handle functionality of your application during specific stages of OTA on or on an OTA error:
42+
```cpp
43+
void onStart(OTA_CALLBACK(fn));
44+
void onEnd(OTA_CALLBACK(fn));
45+
void onProgress(OTA_CALLBACK_PROGRESS(fn));
46+
void onError(OTA_CALLBACK_ERROR (fn));
47+
```
48+
49+
The following chapters provide more details and specific methods of doing OTA.
2250

2351

2452
## Basic Requirements
2553

2654
- Flash chip size is 2x the size of the sketch.
2755

56+
2857
## Arduino IDE
2958

3059
Uploading modules wirelessly from Arduino IDE is intended for the following typical scenarios:
@@ -37,52 +66,69 @@ Uploading modules wirelessly from Arduino IDE is intended for the following typi
3766

3867
#### Let's Do It
3968

40-
OTA process will be demonstrated using:
41-
- DNS_SD_Arduino_OTA.ino sketch available from Arduino IDE
42-
- NodeMCU 1.0 board with ESP-12E module
69+
Currently there are two software configurations that support OTA updates
70+
- [Classic OTA](#classic-ota-configuration): Arduino IDE 1.6.5 and [stable](https://github.com/esp8266/Arduino#staging-version-) (July 23, 2015) or [staging](https://github.com/esp8266/Arduino#staging-version-) (Sep 30, 2015) platform package that provides first OTA implementation, yet without support for [ArduinoOTA](https://github.com/esp8266/Arduino/tree/master/libraries/ArduinoOTA) library. This particular configuration is intended for less experienced users. It soon will be depreciated once implementation below is fully released.
71+
- [ArduinoOTA](#arduinoota-configuration): Arduino-PR-4107-BUILD-421 and latest git version of platform package that includes [ArduinoOTA](https://github.com/esp8266/Arduino/tree/master/libraries/ArduinoOTA) library. This configuration features preliminary build of Arduino IDE and is intended for more experienced users. Please mid your step.
72+
73+
Instructions below demonstrate how to configure both [Classic OTA](#classic-ota-configuration) and [ArduinoOTA](#arduinoota-configuration) using NodeMCU 1.0 board with ESP-12E.
74+
75+
##### Classic OTA Configuration
4376

4477
1. Before you begin, please make sure that you have the following installed:
4578
- Arduino IDE and ESP8266 board support as described under https://github.com/esp8266/Arduino#installing-with-boards-manager
46-
- Python 2.7.10 (do not install Python 3.5.0 that is not supported):
47-
1. Upload Python from https://www.python.org/
48-
2. Start installer
49-
3. Select “Add python.exe to Path” (see below – that option is not selected by default)
50-
4. Complete remaining steps of installation
51-
79+
- [Python](https://www.python.org/) 2.7.10 (do not install Python 3.5.0 that is not supported):
80+
81+
**Note:** Windows users should select “Add python.exe to Path” (see below – this option is not selected by default)
82+
5283
![Python installation set up](ota-ide-python-configuration.png)
5384

5485
2. Now prepare the sketch and configuration for the upload over a serial port.
5586

5687
- Start Arduino IDE and load sketch DNS_SD_Arduino_OTA.ino available under File > Examples > ESP8266mDNS
5788

58-
![OTA sketch selection](ota-ide-sketch-selection.png)
89+
![OTA sketch selection](ota-ide-sketch-selection.png)
90+
91+
**Note:** This sketch is available only for stable (July 23, 2015) and staging (Sep 30, 2015) releases installed in Arduino IDE using https://github.com/esp8266/Arduino#installing-with-boards-manager. It was removed in [#980](https://github.com/esp8266/Arduino/pull/980) from Github repository.
5992

6093
- Update ssid and pass in the sketch so the module can join your WiFi network
6194

62-
![ssid and pass entry](ota-ide-ssid-pass-entry.png)
95+
![ssid and pass entry](ota-ide-ssid-pass-entry.png)
6396

6497
- Configure upload parameters as below (you may need to adjust configuration if you are using a different module):
6598

66-
![configuration of serial upload](ota-ide-serial-upload-configuration.png)
99+
![configuration of serial upload](ota-ide-serial-upload-configuration.png)
67100

68101
3. Upload the sketch (Ctrl+U). Once done open Serial Monitor (Ctrl+Shift+M) and check if the module has joined your WiFi network.
69102

70103
![check if module joined network](ota-ide-module-joined-wifi.png)
71104

72-
4. Only if module is connected, after a dozen (or two dozens) of seconds the esp8266-ota port will show up in Arduino IDE:
105+
4. Only if module is connected to network, after a couple of seconds, the esp8266-ota port will show up in Arduino IDE:
73106

74107
![selection og OTA port](ota-ide-ota-port-selection.png)
75108

76109
5. Now get ready for your first OTA upload by changing configuration settings as follows:
77110

78111
![configuration of OTA upload](ota-ide-ota-upload-configuration.png)
79112

113+
**Note:** If you do not see “Upload Using: OTA” option available for “NodeMCU 1.0 (ESP-12E Module)” board, please upload the latest [boards.txt](https://github.com/esp8266/Arduino/blob/master/boards.txt) file from Github repository, replace existing file and restart Arduino IDE.
114+
80115
6. If you have successfully completed all the above steps, you can upload (Ctrl+U) the same (or any other) sketch over OTA:
81116

82117
![OTA upload complete](ota-ide-ota-upload-complete.png)
83118

84119
**Note** To be able to upload your sketch over and over again using OTA, you need to embed OTA routines inside. Please use DNS_SD_Arduino_OTA.ino as an example.
85120

121+
##### ArduinoOTA Configuration
122+
123+
1. Get the following software:
124+
- Arduino-PR-4107-BUILD-421 - https://github.com/esp8266/Arduino/pull/984#issuecomment-155905800
125+
- Latest git version of pacakge - https://github.com/esp8266/Arduino#using-git-version-
126+
- Python 2.7.10
127+
128+
2. Proceed to step 2 under [Classic OTA Configuration](#classic-ota-configuration) using BasicOTA.ino or OTALeds.ino skech instead.
129+
130+
3. Carry on with remaining steps.
131+
86132

87133
## HTTP Server
88134

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/ESP8266WiFi.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern "C" {
3131
#include "IPAddress.h"
3232
#include "WiFiClient.h"
3333
#include "WiFiServer.h"
34+
#include "WiFiClientSecure.h"
3435

3536
#define WIFI_SCAN_RUNNING (-1)
3637
#define WIFI_SCAN_FAILED (-2)

0 commit comments

Comments
 (0)