1 /*
2  * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
7  * The header file used normally for ESP-IDF has the same name but is located elsewhere.
8  */
9 #ifndef __ESP_PARTITION_H__
10 #define __ESP_PARTITION_H__
11 
12 #include <stdint.h>
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include "esp_err.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef enum {
22     ESP_PARTITION_TYPE_APP = 0x00,       //!< Application partition type
23     ESP_PARTITION_TYPE_DATA = 0x01,      //!< Data partition type
24 } esp_partition_type_t;
25 
26 typedef enum {
27     ESP_PARTITION_SUBTYPE_APP_FACTORY = 0x00,                                 //!< Factory application partition
28     ESP_PARTITION_SUBTYPE_APP_OTA_MIN = 0x10,                                 //!< Base for OTA partition subtypes
29     ESP_PARTITION_SUBTYPE_APP_OTA_0 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 0,  //!< OTA partition 0
30     ESP_PARTITION_SUBTYPE_APP_OTA_1 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 1,  //!< OTA partition 1
31     ESP_PARTITION_SUBTYPE_APP_OTA_2 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 2,  //!< OTA partition 2
32     ESP_PARTITION_SUBTYPE_APP_OTA_3 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 3,  //!< OTA partition 3
33     ESP_PARTITION_SUBTYPE_APP_OTA_4 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 4,  //!< OTA partition 4
34     ESP_PARTITION_SUBTYPE_APP_OTA_5 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 5,  //!< OTA partition 5
35     ESP_PARTITION_SUBTYPE_APP_OTA_6 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 6,  //!< OTA partition 6
36     ESP_PARTITION_SUBTYPE_APP_OTA_7 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 7,  //!< OTA partition 7
37     ESP_PARTITION_SUBTYPE_APP_OTA_8 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 8,  //!< OTA partition 8
38     ESP_PARTITION_SUBTYPE_APP_OTA_9 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 9,  //!< OTA partition 9
39     ESP_PARTITION_SUBTYPE_APP_OTA_10 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 10,//!< OTA partition 10
40     ESP_PARTITION_SUBTYPE_APP_OTA_11 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 11,//!< OTA partition 11
41     ESP_PARTITION_SUBTYPE_APP_OTA_12 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 12,//!< OTA partition 12
42     ESP_PARTITION_SUBTYPE_APP_OTA_13 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 13,//!< OTA partition 13
43     ESP_PARTITION_SUBTYPE_APP_OTA_14 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 14,//!< OTA partition 14
44     ESP_PARTITION_SUBTYPE_APP_OTA_15 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 15,//!< OTA partition 15
45     ESP_PARTITION_SUBTYPE_APP_OTA_MAX = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 16,//!< Max subtype of OTA partition
46     ESP_PARTITION_SUBTYPE_APP_TEST = 0x20,                                    //!< Test application partition
47 
48     ESP_PARTITION_SUBTYPE_DATA_OTA = 0x00,                                    //!< OTA selection partition
49     ESP_PARTITION_SUBTYPE_DATA_PHY = 0x01,                                    //!< PHY init data partition
50     ESP_PARTITION_SUBTYPE_DATA_NVS = 0x02,                                    //!< NVS partition
51     ESP_PARTITION_SUBTYPE_DATA_COREDUMP = 0x03,                               //!< COREDUMP partition
52     ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS = 0x04,                               //!< Partition for NVS keys
53     ESP_PARTITION_SUBTYPE_DATA_EFUSE_EM = 0x05,                               //!< Partition for emulate eFuse bits
54     ESP_PARTITION_SUBTYPE_DATA_UNDEFINED = 0x06,                              //!< Undefined (or unspecified) data partition
55 
56     ESP_PARTITION_SUBTYPE_DATA_ESPHTTPD = 0x80,                               //!< ESPHTTPD partition
57     ESP_PARTITION_SUBTYPE_DATA_FAT = 0x81,                                    //!< FAT partition
58     ESP_PARTITION_SUBTYPE_DATA_SPIFFS = 0x82,                                 //!< SPIFFS partition
59 
60     ESP_PARTITION_SUBTYPE_ANY = 0xff,                                         //!< Used to search for partitions with any subtype
61 } esp_partition_subtype_t;
62 
63 /**
64  * @brief Opaque partition iterator type
65  */
66 typedef struct esp_partition_iterator_opaque_* esp_partition_iterator_t;
67 
68 /**
69  * @brief partition information structure
70  *
71  * This is not the format in flash, that format is esp_partition_info_t.
72  *
73  * However, this is the format used by this API.
74  */
75 typedef struct {
76     void* flash_chip;            /*!< SPI flash chip on which the partition resides */
77     esp_partition_type_t type;          /*!< partition type (app/data) */
78     esp_partition_subtype_t subtype;    /*!< partition subtype */
79     uint32_t address;                   /*!< starting address of the partition in flash */
80     uint32_t size;                      /*!< size of the partition, in bytes */
81     char label[17];                     /*!< partition label, zero-terminated ASCII string */
82     bool encrypted;                     /*!< flag is set to true if partition is encrypted */
83 } esp_partition_t;
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 
90 #endif /* __ESP_PARTITION_H__ */
91