EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #838 background imageLoading...
Page #838 background image
Chapter 2. API Reference
esp_err_t do_firmware_upgrade()
{
esp_http_client_config_t config = {
.url = CONFIG_FIRMWARE_UPGRADE_URL,
.cert_pem = (char *)server_cert_pem_start,
};
esp_err_t ret = esp_https_ota(&config);
if (ret == ESP_OK) {
esp_restart();
} else {
return ESP_FAIL;
}
return ESP_OK;
}
Partial Image Download over HTTPS
To use partial image download feature, enable partial_http_download configuration in
esp_https_ota_config_t. When this configuration is enabled, firmware image will be downloaded in
multiple HTTP requests of specified size. Maximum content length of each request can be specified by setting
max_http_request_size to required value.
This option is useful while fetching image from a service like AWS S3, where mbedTLS Rx buffer size (CON-
FIG_MBEDTLS_SSL_IN_CONTENT_LEN) can be set to lower value which is not possible without enabling this
configuration.
Default value of mbedTLS Rx buffer size is set to 16K. By using partial_http_download with max_http_request_size
of 4K, size of mbedTLS Rx buffer can be reduced to 4K. With this confiuration, memory saving of around 12K is
expected.
Signature Verification
For additional security, signature of OTA firmware images can be veried. For that, refer Secure OTA Updates Without
Secure boot
API Reference
Header File
components/esp_https_ota/include/esp_https_ota.h
Functions
esp_err_t esp_https_ota(const esp_http_client_config_t *config)
HTTPS OTA Firmware upgrade.
This function allocates HTTPS OTA Firmware upgrade context, establishes HTTPS connection, reads image
data from HTTP stream and writes it to OTA partition and finishes HTTPS OTA Firmware upgrade operation.
This API supports URL redirection, but if CA cert of URLs differ then it should be appended to cert_pem
member of config.
Note This API handles the entire OTA operation, so if this API is being used then no other APIs from
esp_https_ota component should be called. If more information and control is needed during the
HTTPS OTA process, then one can use esp_https_ota_begin and subsequent APIs. If this API
returns successfully, esp_restart() must be called to boot from the new firmware image.
Return
ESP_OK: OTA data updated, next reboot will use specified partition.
ESP_FAIL: For generic failure.
ESP_ERR_INVALID_ARG: Invalid argument
Espressif Systems 827
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish