esp_https_ota.rst 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ESP HTTPS OTA
  2. =============
  3. Overview
  4. --------
  5. ``esp_https_ota`` provides simplified APIs to perform firmware upgrades over HTTPS.
  6. It's an abstraction layer over existing OTA APIs.
  7. Application Example
  8. -------------------
  9. .. highlight:: c
  10. ::
  11. esp_err_t do_firmware_upgrade()
  12. {
  13. esp_http_client_config_t config = {
  14. .url = CONFIG_FIRMWARE_UPGRADE_URL,
  15. .cert_pem = (char *)server_cert_pem_start,
  16. };
  17. esp_https_ota_config_t ota_config = {
  18. .http_config = &config,
  19. };
  20. esp_err_t ret = esp_https_ota(&ota_config);
  21. if (ret == ESP_OK) {
  22. esp_restart();
  23. } else {
  24. return ESP_FAIL;
  25. }
  26. return ESP_OK;
  27. }
  28. Partial Image Download over HTTPS
  29. ---------------------------------
  30. To use partial image download feature, enable ``partial_http_download`` configuration in ``esp_https_ota_config_t``.
  31. When this configuration is enabled, firmware image will be downloaded in multiple HTTP requests of specified size.
  32. Maximum content length of each request can be specified by setting ``max_http_request_size`` to required value.
  33. This option is useful while fetching image from a service like AWS S3, where mbedTLS Rx buffer size (:ref:`CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN`)
  34. can be set to lower value which is not possible without enabling this configuration.
  35. Default value of mbedTLS Rx buffer size is set to 16K. By using partial_http_download with max_http_request_size of 4K,
  36. size of mbedTLS Rx buffer can be reduced to 4K. With this configuration, memory saving of around 12K is expected.
  37. Signature Verification
  38. ----------------------
  39. For additional security, signature of OTA firmware images can be verified. For that, refer :ref:`secure-ota-updates`
  40. Advanced APIs
  41. -------------
  42. ``esp_https_ota`` also provides advanced APIs which can be used if more information and control is needed during the OTA process.
  43. Example that uses advanced ESP_HTTPS_OTA APIs: :example:`system/ota/advanced_https_ota`.
  44. OTA Upgrades with Pre-Encrypted Firmware
  45. ----------------------------------------
  46. To perform OTA upgrades with Pre-Encrypted Firmware, please enable :ref:`CONFIG_ESP_HTTPS_OTA_DECRYPT_CB` in component menuconfig.
  47. Example that performs OTA upgrade with Pre-Encrypted Firmware: :example:`system/ota/pre_encrypted_ota`.
  48. API Reference
  49. -------------
  50. .. include-build-file:: inc/esp_https_ota.inc