Skip to content

Commit 2f75f0b

Browse files
committed
Troublehooting of OTA from IDE
Update ota_updates.md Update ota_updates.md
1 parent a73e167 commit 2f75f0b

File tree

3 files changed

+63
-10
lines changed

3 files changed

+63
-10
lines changed
17.6 KB
Loading

doc/ota_updates/ota_updates.md

+63-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ title: OTA Update
1111
* [Requirements](#requirements)
1212
* [Application Example](#application-example)
1313
* [Classic OTA](#classic-ota)
14+
* [Troubleshooting](#troubleshooting)
1415
* [ArduinoOTA](#arduinoota)
1516
* [Web Browser](#web-browser)
1617
* [Requirements](#requirements-1)
@@ -42,7 +43,7 @@ Arduino IDE option is intended primarily for software development phase. The two
4243

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

45-
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 a safe manner. Chapters below provide additional information regarding security and safety of OTA process.
46+
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 a safe manner. Chapters below provide additional information regarding security and safety of OTA process.
4647

4748

4849
### Security
@@ -79,13 +80,14 @@ void onError(OTA_CALLBACK_ERROR (fn));
7980

8081
### Basic Requirements
8182

82-
Flash chip size needs a size thats is able to hold the old sketch (currently running) and the new sketch (OTA) at the same time.
83-
keep in mind that the File system and EEPROM for example needs space too (one time) see [flash layout](../filesystem.md#flash-layout).
83+
Flash chip size needs a size that is able to hold the old sketch (currently running) and the new sketch (OTA) at the same time.
84+
Keep in mind that the File system and EEPROM for example needs space too (one time) see [flash layout](../filesystem.md#flash-layout).
8485
```cpp
8586
ESP.getFreeSketchSpace();
8687
```
8788
can be used for checking the free space for the new sketch.
8889

90+
For overview of memory layout, where new sketch is stored and how it is copied during OTA process see [Update process - memory view]( https://github.com/esp8266/Arduino/blob/master/doc/ota_updates/ota_updates.md#update-process---memory-view).
8991

9092

9193
The following chapters provide more details and specific methods of doing OTA.
@@ -125,11 +127,11 @@ Instructions below demonstrate how to configure both [Classic OTA](#classic-ota-
125127
![Python installation set up](ota-ide-python-configuration.png)
126128

127129
2. Now prepare the sketch and configuration for the upload over a serial port.
128-
- Start Arduino IDE and load sketch DNS_SD_Arduino_OTA.ino available under File > Examples > ESP8266mDNS
130+
- Start Arduino IDE and load sketch DNS_SD_Arduino_OTA.ino available under File > Examples > ESP8266mDNS
129131
![OTA sketch selection](ota-ide-sketch-selection.png)
130132

131133
**Note:** This sketch is available only for 1.6.5-947-g39819f0 (of July 23, 2015) and 1.6.5-1160-gef26c5f (of Sep 30, 2015) versions of platform packages 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.
132-
- Update SSID and password in the sketch so the module can join your Wi-Fi network
134+
- Update SSID and password in the sketch so the module can join your Wi-Fi network
133135
![ssid and pass entry](ota-ide-ssid-pass-entry.png)
134136
- Configure upload parameters as below (you may need to adjust configuration if you are using a different module):
135137
![configuration of serial upload](ota-ide-serial-upload-configuration.png)
@@ -155,6 +157,57 @@ Instructions below demonstrate how to configure both [Classic OTA](#classic-ota-
155157
**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.
156158

157159

160+
#### Troubleshooting
161+
162+
If OTA update fails, first step is to check for error messages that may be shown in upload window of Arduino IDE. If this is not providing any useful hints try to upload again while checking what is shown by ESP on serial port. Serial Monitor from IDE will not be useful in that case. When attempting to open it, you will likely see the following:
163+
164+
![Arduino IDE network terminal window](ota-ide-network-terminal.png)
165+
166+
This window is for Arduino Yún and not yet implemented for esp8266/Arduino. It shows up because IDE is attempting to open Serial Monitor using network port you have selected for OTA upload.
167+
168+
Instead you need an external serial monitor. If you are a Windows user check out [Termite](http://www.compuphase.com/software_termite.htm). This is handy, slick and simple RS232 terminal that does not impose RTS or DTR flow control. Such flow control may cause issues if you are using respective lines to toggle GPIO0 and RESET pins on ESP for upload.
169+
170+
Select COM port and baud rate on external terminal program as if you were using Arduino Serial Monitor. Please see typical settings for [Termite](http://www.compuphase.com/software_termite.htm) below:
171+
172+
![Termite settings](termite-configuration.png)
173+
174+
Then run OTA from IDE and look what is displayed on terminal. Successful OTA process looks like below (sketch and free memory sizes as well as IP addresses depend on your particular s/w and h/w configuration):
175+
176+
```
177+
Arduino OTA Test
178+
Sketch size: 346664
179+
Free size: 700416
180+
IP address: 192.168.1.100
181+
Update Start: ip:192.168.1.10, port:48266, size:346672
182+
Update Success: 6113
183+
Rebooting...
184+
185+
ets Jan 8 2013,rst cause:1, boot mode:(3,7)
186+
187+
load 0x4010f000, len 1264, room 16
188+
tail 0
189+
chksum 0x42
190+
csum 0x42
191+
@cp:0
192+
ld
193+
194+
Arduino OTA Test
195+
Sketch size: 346664
196+
Free size: 700416
197+
IP address: 192.168.1.100
198+
```
199+
200+
If upload fails you will likely see errors caught by the uploader, exception and the stack dump, or both.
201+
202+
The most common causes of OTA failure are as follows:
203+
* not enough physical memory on the chip (e.g. ESP01 with 512K flash memory is not enough for OTA),
204+
* too much memory declared for SPIFFS so new sketch will not fit between existing sketch and SPIFFS – see [Update process - memory view]( https://github.com/esp8266/Arduino/blob/master/doc/ota_updates/ota_updates.md#update-process---memory-view),
205+
* too little memory declared in Arduino IDE for your selected board (i.e. less than physical size).
206+
207+
For more details regarding flash memory layout please check [File system]( https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md).
208+
For overview where new sketch is stored, how it is copied and how memory is organized for the purpose of OTA see [Update process - memory view]( https://github.com/esp8266/Arduino/blob/master/doc/ota_updates/ota_updates.md#update-process---memory-view).
209+
210+
158211
#### ArduinoOTA
159212

160213
1. Upload and install the following software:
@@ -183,7 +236,7 @@ Updates described in this chapter are done with a web browser that can be useful
183236

184237
### Implementation Overview
185238

186-
Updates with a web browswer are implemented using ```ESP8266HTTPUpdateServer``` class together with ```ESP8266WebServer``` and ```ESP8266mDNS``` classes. The following code is required to get it work:
239+
Updates with a web browser are implemented using ```ESP8266HTTPUpdateServer``` class together with ```ESP8266WebServer``` and ```ESP8266mDNS``` classes. The following code is required to get it work:
187240

188241
setup()
189242

@@ -222,10 +275,10 @@ You can use another module if it meets “Flash chip size is 2x the size of the
222275

223276
2. Prepare the sketch and configuration for initial upload with a serial port.
224277
- Start Arduino IDE and load sketch WebUpdater.ino available under File > Examples > ESP8266HTTPUpdateServer.
225-
- Update ssid and pass in the sketch so the module can join your Wi-Fi network.
278+
- Update SSID and password in the sketch so the module can join your Wi-Fi network.
226279
- Open File > Preferences, look for “Show verbose output during:” and check out “compilation” option.
227280

228-
![Preferences - enablig verbose output during compilation](ota-web-show-verbose-compilation.png)
281+
![Preferences - enabling verbose output during compilation](ota-web-show-verbose-compilation.png)
229282

230283
**Note:** This setting will be required in step 5 below. You can uncheck this setting afterwards.
231284

@@ -315,7 +368,7 @@ For the simple updater the server only needs to deliver the binary file for upda
315368
##### Advanced updater
316369

317370
For advanced update management a script needs to run at the server side, for example a PHP script.
318-
At every update request the the ESP sends some information in HTTP headers to the server.
371+
At every update request the ESP sends some information in HTTP headers to the server.
319372

320373
Example header data:
321374
```
@@ -329,7 +382,7 @@ Example header data:
329382
[HTTP_X_ESP8266_VERSION] => DOOR-7-g14f53a19
330383
```
331384

332-
With this information the script now can check if a update is needed. It is also possible to deliver different binaries based on the MAC address for example.
385+
With this information the script now can check if an update is needed. It is also possible to deliver different binaries based on the MAC address for example.
333386

334387
Script example:
335388

31 KB
Loading

0 commit comments

Comments
 (0)