mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-01 06:27:29 +00:00
spi_flash: support for partitions in external flash
This commit is contained in:
@@ -19,8 +19,10 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -98,6 +100,7 @@ typedef struct esp_partition_iterator_opaque_* esp_partition_iterator_t;
|
||||
* However, this is the format used by this API.
|
||||
*/
|
||||
typedef struct {
|
||||
esp_flash_t* flash_chip; /*!< SPI flash chip on which the partition resides */
|
||||
esp_partition_type_t type; /*!< partition type (app/data) */
|
||||
esp_partition_subtype_t subtype; /*!< partition subtype */
|
||||
uint32_t address; /*!< starting address of the partition in flash */
|
||||
@@ -320,6 +323,43 @@ esp_err_t esp_partition_get_sha256(const esp_partition_t *partition, uint8_t *sh
|
||||
*/
|
||||
bool esp_partition_check_identity(const esp_partition_t *partition_1, const esp_partition_t *partition_2);
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param flash_chip Pointer to the structure identifying the flash chip
|
||||
* @param offset Address in bytes, where the partition starts
|
||||
* @param size Size of the partition in bytes
|
||||
* @param label Partition name
|
||||
* @param type One of the partition types (ESP_PARTITION_TYPE_*). Note that applications can not be booted from external flash
|
||||
* chips, so using ESP_PARTITION_TYPE_APP is not supported.
|
||||
* @param subtype One of the partition subtypes (ESP_PARTITION_SUBTYPE_*)
|
||||
* @param[out] out_partition Output, if non-NULL, receives the pointer to the resulting esp_partition_t structure
|
||||
* @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
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Deregister the partition previously registered using esp_partition_register_external
|
||||
* @param partition pointer to the partition structure obtained from esp_partition_register_external,
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_FOUND if the partition pointer is not found
|
||||
* - ESP_ERR_INVALID_ARG if the partition comes from the partition table
|
||||
* - ESP_ERR_INVALID_ARG if the partition was not registered using
|
||||
* esp_partition_register_external function.
|
||||
*/
|
||||
esp_err_t esp_partition_deregister_external(const esp_partition_t* partition);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user