Step by step guide
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.1KB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # step by step guide
  2. __start with [ArduinoOTA basic example](https://github.com/esp8266/Arduino/blob/master/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino)__
  3. ```cpp
  4. void setup() {
  5. WiFi.mode(WIFI_STA);
  6. WiFi.begin(ssid, password);
  7. while (WiFi.waitForConnectResult() != WL_CONNECTED) {
  8. delay(5000);
  9. ESP.restart(); /* reload application */
  10. }
  11. /* register callbacks for OTA events */
  12. ArduinoOTA.onStart([]() { /* ... */ });
  13. ArduinoOTA.onEnd ([]() { /* ... */ });
  14. ArduinoOTA.onError([](ota_error_t error) { /* ... */ });
  15. /* setup OTA for listening on default UDP-port 8266 */
  16. ArduinoOTA.begin();
  17. }
  18. void loop() {
  19. /* check for incoming OTA update */
  20. ArduinoOTA.handle();
  21. }
  22. ```
  23. ___
  24. __open serial port to esp8266 and reset__
  25. ```bash
  26. # example output after reset
  27. ets Jan 8 2013,rst cause:2, boot mode:(3,7)
  28. # load binary
  29. load 0x4010f000, len 3460, room 16
  30. tail 4
  31. chksum 0xcc
  32. load 0x3fff20b8, len 40, room 4
  33. tail 4
  34. chksum 0xc9
  35. csum 0xc9
  36. v00040b70
  37. ~ld
  38. ```
  39. ___
  40. __Boot Messages and Modes, see also [detailed documentation](https://github.com/esp8266/Arduino/blob/master/doc/boards.rst)__
  41. at startup the ESP prints out the current boot mode example:
  42. ```
  43. rst cause:2, boot mode:(3,6)
  44. ```
  45. | rst cause| Description |
  46. |----------|------------------|
  47. | 0 | unknown |
  48. | 1 | normal boot |
  49. | 2 | reset pin |
  50. | 3 | software reset |
  51. | 4 | watchdog reset |
  52. ```
  53. boot mode:(x,y)
  54. ```
  55. | x | GPIO15 | GPIO0 | GPIO2 | Mode |
  56. |----------|----------|---------|---------|-------------|
  57. | 1 | 0V | 0V | 3.3V | Uart |
  58. | 3 | 0V | 3.3V | 3.3V | Flash |
  59. __note:__ __y__ represents the position of the boot file
  60. ___
  61. __modify__ _platformio.ini_
  62. ```ini
  63. ; example platformio.ini
  64. [env:esp01_1m]
  65. platform = espressif8266
  66. board = esp01_1m
  67. framework = arduino
  68. upload_port = COM6
  69. monitor_speed = 74880
  70. ```
  71. ___
  72. __upload compiled binary via uart__
  73. __note__: close serial port
  74. ```bash
  75. $ pio run -t upload
  76. # or use upload button in vscode
  77. ```
  78. __open serial port to esp8266 and check Wi-Fi connection__
  79. ```bash
  80. # monitor output:
  81. Ready
  82. IP address: # your local IP #
  83. ```
  84. __modify platformio.ini accordingly__
  85. ```ini
  86. ; new platformio.ini for OTA
  87. [env:esp01_1m]
  88. platform = espressif8266
  89. board = esp01_1m
  90. framework = arduino
  91. upload_protocol = espota
  92. upload_port = # your local IP #
  93. monitor_speed = 74880
  94. ```
  95. ___
  96. __now you can upload new binaries via OTA__
  97. ```bash
  98. $ pio run -t upload
  99. # or use upload button in vscode
  100. ```
  101. __what`s happening can be observed with [debug_ser.py](debug_ser.py), _PySerial_ needed !__
  102. ```bash
  103. $ python3 debug_ser.py
  104. # serial output:
  105. [OTA] Start updating sketch
  106. [OTA] Progress: 100%
  107. [OTA] End
  108. ets Jan 8 2013,rst cause:2, boot mode:(3,7)
  109. load 0x4010f000, len 3460, room 16
  110. tail 4
  111. chksum 0xcc
  112. load 0x3fff20b8, len 40, room 4
  113. tail 4
  114. chksum 0xc9
  115. csum 0xc9
  116. v0004e770
  117. @cp:B0 # copying new binary into boot flash region
  118. ld
  119. [Program] Booting
  120. [Program] OTA and HTTPServer ready !
  121. [Program] IP address: 192.168.10.108
  122. ```
  123. ___
  124. __Process of updating__
  125. ![ota flash layout](ota_flash.png)