Chapter 2. API Reference
image content. The hash is verified before returning, if app content is invalid then the function returns
ESP_ERR_IMAGE_INVALID. For apps without SHA-256 appended to the image, the result is the SHA-
256 of all bytes in the app image. For other partition types, the result is the SHA-256 of the entire partition.
Return
• ESP_OK: In case of successful operation.
• ESP_ERR_INVALID_ARG: The size was 0 or the sha_256 was NULL.
• ESP_ERR_NO_MEM: Cannot allocate memory for sha256 operation.
• ESP_ERR_IMAGE_INVALID: App partition doesn’t contain a valid app image.
• ESP_FAIL: An allocation error occurred.
Parameters
• [in] partition: Pointer to info for partition containing app or data. (fields: address, size and
type, are required to be filled).
• [out] sha_256: Returned SHA-256 digest for a given partition.
bool esp_partition_check_identity(const esp_partition_t *partition_1, const esp_partition_t
*partition_2)
Check for the identity of two partitions by SHA-256 digest.
Return
• True: In case of the two firmware is equal.
• False: Otherwise
Parameters
• [in] partition_1: Pointer to info for partition 1 containing app or data. (fields: address, size
and type, are required to be filled).
• [in] partition_2: Pointer to info for partition 2 containing app or data. (fields: address, size
and type, are required to be filled).
esp_err_t esp_partition_register_external(esp_flash_t *flash_chip, size_t offset, size_t
size, const char *label, esp_partition_type_t
type, esp_partition_subtype_t subtype, const
esp_partition_t **out_partition)
Register a partition on an external flash chip.
This API allows designating certain areas of external flash chips (identified by the esp_flash_t structure) as
partitions. This allows using them with components which access SPI flash through the esp_partition API.
Return
• ESP_OK on success
• ESP_ERR_NOT_SUPPORTED if CONFIG_CONFIG_SPI_FLASH_USE_LEGACY_IMPL is
enabled
• ESP_ERR_NO_MEM if memory allocation has failed
• ESP_ERR_INVALID_ARG if the new partition overlaps another partition on the same flash chip
• ESP_ERR_INVALID_SIZE if the partition doesn
’
t fit into the flash chip size
Parameters
• flash_chip: Pointer to the structure identifying the flash chip
• offset: Address in bytes, where the partition starts
• size: Size of the partition in bytes
• label: Partition name
• type: One of the partition types (ESP_PARTITION_TYPE_*), or an integer. Note that applica-
tions can not be booted from external flash chips, so using ESP_PARTITION_TYPE_APP is not
supported.
• subtype: One of the partition subtypes (ESP_PARTITION_SUBTYPE_*), or an integer.
• [out] out_partition: Output, if non-NULL, receives the pointer to the resulting
esp_partition_t structure
esp_err_t esp_partition_deregister_external(const esp_partition_t *partition)
Deregister the partition previously registered using esp_partition_register_external.
Return
• ESP_OK on success
• ESP_ERR_NOT_FOUND if the partition pointer is not found
Espressif Systems 760
Submit Document Feedback
Release v4.4