Skip to content

Commit 6d1d0ab

Browse files
committed
Merge pull request #1024 from Links2004/docu
Included desription of ArduinoOTA support and other corrections listed
2 parents 77428ba + 63d6de5 commit 6d1d0ab

File tree

1 file changed

+61
-15
lines changed

1 file changed

+61
-15
lines changed

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

0 commit comments

Comments
 (0)