ota.rst 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Over The Air Updates (OTA)
  2. ==========================
  3. OTA Process Overview
  4. ^^^^^^^^^^^^^^^^^^^^
  5. The OTA update mechanism allows a device to update itself based on data received while the normal firmware is running
  6. (for example, over WiFi or Bluetooth.)
  7. OTA requires configuring the :doc:`Partition Table </partition-tables>` of the device with at least two "OTA app slot"
  8. partitions (ie `ota_0` and `ota_1`) and an "OTA Data Partition".
  9. The OTA operation functions write a new app firmware image to whichever OTA app slot is not currently being used for
  10. booting. Once the image is verified, the OTA Data partition is updated to specify that this image should be used for the
  11. next boot.
  12. .. _ota_data_partition:
  13. OTA Data Partition
  14. ^^^^^^^^^^^^^^^^^^
  15. An OTA data partition (type ``data``, subtype ``ota``) must be included in the :doc:`Partition Table </partition-tables>`
  16. of any project which uses the OTA functions.
  17. For factory boot settings, the OTA data partition should contain no data (all bytes erased to 0xFF). In this case the
  18. esp-idf software bootloader will boot the factory app if it is present in the the partition table. If no factory app is
  19. included in the partition table, the first available OTA slot (usually ``ota_0``) is booted.
  20. After the first OTA update, the OTA data partition is updated to specify which OTA app slot partition should be booted next.
  21. The OTA data partition is two flash sectors (0x2000 bytes) in size, to prevent problems if there is a power failure
  22. while it is being written. Sectors are independently erased and written with matching data, and if they disagree a
  23. counter field is used to determine which sector was written more recently.
  24. See also
  25. --------
  26. * :doc:`Partition Table documentation </partition-tables>`
  27. * :doc:`Lower-Level SPI Flash/Partition API </api/storage/spi_flash>`
  28. Application Example
  29. -------------------
  30. End-to-end example of OTA firmware update workflow: :example:`system/ota`.
  31. API Reference
  32. -------------
  33. Header Files
  34. ^^^^^^^^^^^^
  35. * :component_file:`app_update/include/esp_ota_ops.h`
  36. Macros
  37. ^^^^^^
  38. .. doxygendefine:: ESP_ERR_OTA_BASE
  39. .. doxygendefine:: ESP_ERR_OTA_PARTITION_CONFLICT
  40. .. doxygendefine:: ESP_ERR_OTA_SELECT_INFO_INVALID
  41. .. doxygendefine:: ESP_ERR_OTA_VALIDATE_FAILED
  42. .. doxygendefine:: OTA_SIZE_UNKNOWN
  43. Type Definitions
  44. ^^^^^^^^^^^^^^^^
  45. .. doxygentypedef:: esp_ota_handle_t
  46. Functions
  47. ^^^^^^^^^
  48. .. doxygenfunction:: esp_ota_begin
  49. .. doxygenfunction:: esp_ota_write
  50. .. doxygenfunction:: esp_ota_end
  51. .. doxygenfunction:: esp_ota_get_running_partition
  52. .. doxygenfunction:: esp_ota_set_boot_partition
  53. .. doxygenfunction:: esp_ota_get_boot_partition
  54. .. doxygenfunction:: esp_ota_get_next_update_partition