esp_partition.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef __ESP_PARTITION_H__
  7. #define __ESP_PARTITION_H__
  8. #include <stdint.h>
  9. #include <stdbool.h>
  10. #include <stddef.h>
  11. #include "esp_err.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /**
  16. * @file esp_partition.h
  17. * @brief Partition APIs
  18. */
  19. /** @cond */
  20. typedef struct esp_flash_t esp_flash_t;
  21. /** @endcond */
  22. /**
  23. * @brief Enumeration which specifies memory space requested in an mmap call
  24. */
  25. typedef enum {
  26. ESP_PARTITION_MMAP_DATA, /**< map to data memory (Vaddr0), allows byte-aligned access, 4 MB total */
  27. ESP_PARTITION_MMAP_INST, /**< map to instruction memory (Vaddr1-3), allows only 4-byte-aligned access, 11 MB total */
  28. } esp_partition_mmap_memory_t;
  29. /**
  30. * @brief Opaque handle for memory region obtained from esp_partition_mmap.
  31. */
  32. typedef uint32_t esp_partition_mmap_handle_t;
  33. /**
  34. * @brief Partition type
  35. *
  36. * @note Partition types with integer value 0x00-0x3F are reserved for partition types defined by ESP-IDF.
  37. * Any other integer value 0x40-0xFE can be used by individual applications, without restriction.
  38. *
  39. * @internal Keep this enum in sync with PartitionDefinition class gen_esp32part.py @endinternal
  40. *
  41. */
  42. typedef enum {
  43. ESP_PARTITION_TYPE_APP = 0x00, //!< Application partition type
  44. ESP_PARTITION_TYPE_DATA = 0x01, //!< Data partition type
  45. ESP_PARTITION_TYPE_ANY = 0xff, //!< Used to search for partitions with any type
  46. } esp_partition_type_t;
  47. /**
  48. * @brief Partition subtype
  49. *
  50. * @note These ESP-IDF-defined partition subtypes apply to partitions of type ESP_PARTITION_TYPE_APP
  51. * and ESP_PARTITION_TYPE_DATA.
  52. *
  53. * Application-defined partition types (0x40-0xFE) can set any numeric subtype value.
  54. *
  55. * @internal Keep this enum in sync with PartitionDefinition class gen_esp32part.py @endinternal
  56. */
  57. typedef enum {
  58. ESP_PARTITION_SUBTYPE_APP_FACTORY = 0x00, //!< Factory application partition
  59. ESP_PARTITION_SUBTYPE_APP_OTA_MIN = 0x10, //!< Base for OTA partition subtypes
  60. ESP_PARTITION_SUBTYPE_APP_OTA_0 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 0, //!< OTA partition 0
  61. ESP_PARTITION_SUBTYPE_APP_OTA_1 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 1, //!< OTA partition 1
  62. ESP_PARTITION_SUBTYPE_APP_OTA_2 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 2, //!< OTA partition 2
  63. ESP_PARTITION_SUBTYPE_APP_OTA_3 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 3, //!< OTA partition 3
  64. ESP_PARTITION_SUBTYPE_APP_OTA_4 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 4, //!< OTA partition 4
  65. ESP_PARTITION_SUBTYPE_APP_OTA_5 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 5, //!< OTA partition 5
  66. ESP_PARTITION_SUBTYPE_APP_OTA_6 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 6, //!< OTA partition 6
  67. ESP_PARTITION_SUBTYPE_APP_OTA_7 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 7, //!< OTA partition 7
  68. ESP_PARTITION_SUBTYPE_APP_OTA_8 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 8, //!< OTA partition 8
  69. ESP_PARTITION_SUBTYPE_APP_OTA_9 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 9, //!< OTA partition 9
  70. ESP_PARTITION_SUBTYPE_APP_OTA_10 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 10,//!< OTA partition 10
  71. ESP_PARTITION_SUBTYPE_APP_OTA_11 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 11,//!< OTA partition 11
  72. ESP_PARTITION_SUBTYPE_APP_OTA_12 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 12,//!< OTA partition 12
  73. ESP_PARTITION_SUBTYPE_APP_OTA_13 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 13,//!< OTA partition 13
  74. ESP_PARTITION_SUBTYPE_APP_OTA_14 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 14,//!< OTA partition 14
  75. ESP_PARTITION_SUBTYPE_APP_OTA_15 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 15,//!< OTA partition 15
  76. ESP_PARTITION_SUBTYPE_APP_OTA_MAX = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 16,//!< Max subtype of OTA partition
  77. ESP_PARTITION_SUBTYPE_APP_TEST = 0x20, //!< Test application partition
  78. ESP_PARTITION_SUBTYPE_DATA_OTA = 0x00, //!< OTA selection partition
  79. ESP_PARTITION_SUBTYPE_DATA_PHY = 0x01, //!< PHY init data partition
  80. ESP_PARTITION_SUBTYPE_DATA_NVS = 0x02, //!< NVS partition
  81. ESP_PARTITION_SUBTYPE_DATA_COREDUMP = 0x03, //!< COREDUMP partition
  82. ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS = 0x04, //!< Partition for NVS keys
  83. ESP_PARTITION_SUBTYPE_DATA_EFUSE_EM = 0x05, //!< Partition for emulate eFuse bits
  84. ESP_PARTITION_SUBTYPE_DATA_UNDEFINED = 0x06, //!< Undefined (or unspecified) data partition
  85. ESP_PARTITION_SUBTYPE_DATA_ESPHTTPD = 0x80, //!< ESPHTTPD partition
  86. ESP_PARTITION_SUBTYPE_DATA_FAT = 0x81, //!< FAT partition
  87. ESP_PARTITION_SUBTYPE_DATA_SPIFFS = 0x82, //!< SPIFFS partition
  88. ESP_PARTITION_SUBTYPE_DATA_LITTLEFS = 0x83, //!< LITTLEFS partition
  89. #if __has_include("extra_partition_subtypes.inc")
  90. #include "extra_partition_subtypes.inc"
  91. #endif
  92. ESP_PARTITION_SUBTYPE_ANY = 0xff, //!< Used to search for partitions with any subtype
  93. } esp_partition_subtype_t;
  94. /**
  95. * @brief Convenience macro to get esp_partition_subtype_t value for the i-th OTA partition
  96. */
  97. #define ESP_PARTITION_SUBTYPE_OTA(i) ((esp_partition_subtype_t)(ESP_PARTITION_SUBTYPE_APP_OTA_MIN + ((i) & 0xf)))
  98. /**
  99. * @brief Opaque partition iterator type
  100. */
  101. typedef struct esp_partition_iterator_opaque_* esp_partition_iterator_t;
  102. /**
  103. * @brief partition information structure
  104. *
  105. * This is not the format in flash, that format is esp_partition_info_t.
  106. *
  107. * However, this is the format used by this API.
  108. */
  109. typedef struct {
  110. esp_flash_t* flash_chip; /*!< SPI flash chip on which the partition resides */
  111. esp_partition_type_t type; /*!< partition type (app/data) */
  112. esp_partition_subtype_t subtype; /*!< partition subtype */
  113. uint32_t address; /*!< starting address of the partition in flash */
  114. uint32_t size; /*!< size of the partition, in bytes */
  115. uint32_t erase_size; /*!< size the erase operation should be aligned to */
  116. char label[17]; /*!< partition label, zero-terminated ASCII string */
  117. bool encrypted; /*!< flag is set to true if partition is encrypted */
  118. bool readonly; /*!< flag is set to true if partition is read-only */
  119. } esp_partition_t;
  120. /**
  121. * @brief Find partition based on one or more parameters
  122. *
  123. * @param type Partition type, one of esp_partition_type_t values or an 8-bit unsigned integer.
  124. * To find all partitions, no matter the type, use ESP_PARTITION_TYPE_ANY, and set
  125. * subtype argument to ESP_PARTITION_SUBTYPE_ANY.
  126. * @param subtype Partition subtype, one of esp_partition_subtype_t values or an 8-bit unsigned integer.
  127. * To find all partitions of given type, use ESP_PARTITION_SUBTYPE_ANY.
  128. * @param label (optional) Partition label. Set this value if looking
  129. * for partition with a specific name. Pass NULL otherwise.
  130. *
  131. * @return iterator which can be used to enumerate all the partitions found,
  132. * or NULL if no partitions were found.
  133. * Iterator obtained through this function has to be released
  134. * using esp_partition_iterator_release when not used any more.
  135. */
  136. esp_partition_iterator_t esp_partition_find(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);
  137. /**
  138. * @brief Find first partition based on one or more parameters
  139. *
  140. * @param type Partition type, one of esp_partition_type_t values or an 8-bit unsigned integer.
  141. * To find all partitions, no matter the type, use ESP_PARTITION_TYPE_ANY, and set
  142. * subtype argument to ESP_PARTITION_SUBTYPE_ANY.
  143. * @param subtype Partition subtype, one of esp_partition_subtype_t values or an 8-bit unsigned integer
  144. * To find all partitions of given type, use ESP_PARTITION_SUBTYPE_ANY.
  145. * @param label (optional) Partition label. Set this value if looking
  146. * for partition with a specific name. Pass NULL otherwise.
  147. *
  148. * @return pointer to esp_partition_t structure, or NULL if no partition is found.
  149. * This pointer is valid for the lifetime of the application.
  150. */
  151. const esp_partition_t* esp_partition_find_first(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);
  152. /**
  153. * @brief Get esp_partition_t structure for given partition
  154. *
  155. * @param iterator Iterator obtained using esp_partition_find. Must be non-NULL.
  156. *
  157. * @return pointer to esp_partition_t structure. This pointer is valid for the lifetime
  158. * of the application.
  159. */
  160. const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);
  161. /**
  162. * @brief Move partition iterator to the next partition found
  163. *
  164. * Any copies of the iterator will be invalid after this call.
  165. *
  166. * @param iterator Iterator obtained using esp_partition_find. Must be non-NULL.
  167. *
  168. * @return NULL if no partition was found, valid esp_partition_iterator_t otherwise.
  169. */
  170. esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t iterator);
  171. /**
  172. * @brief Release partition iterator
  173. *
  174. * @param iterator Iterator obtained using esp_partition_find.
  175. * The iterator is allowed to be NULL, so it is not necessary to check its value
  176. * before calling this function.
  177. *
  178. */
  179. void esp_partition_iterator_release(esp_partition_iterator_t iterator);
  180. /**
  181. * @brief Verify partition data
  182. *
  183. * Given a pointer to partition data, verify this partition exists in the partition table (all fields match.)
  184. *
  185. * This function is also useful to take partition data which may be in a RAM buffer and convert it to a pointer to the
  186. * permanent partition data stored in flash.
  187. *
  188. * Pointers returned from this function can be compared directly to the address of any pointer returned from
  189. * esp_partition_get(), as a test for equality.
  190. *
  191. * @param partition Pointer to partition data to verify. Must be non-NULL. All fields of this structure must match the
  192. * partition table entry in flash for this function to return a successful match.
  193. *
  194. * @return
  195. * - If partition not found, returns NULL.
  196. * - If found, returns a pointer to the esp_partition_t structure in flash. This pointer is always valid for the lifetime of the application.
  197. */
  198. const esp_partition_t* esp_partition_verify(const esp_partition_t* partition);
  199. /**
  200. * @brief Read data from the partition
  201. *
  202. * Partitions marked with an encryption flag will automatically be
  203. * be read and decrypted via a cache mapping.
  204. *
  205. * @param partition Pointer to partition structure obtained using
  206. * esp_partition_find_first or esp_partition_get.
  207. * Must be non-NULL.
  208. * @param dst Pointer to the buffer where data should be stored.
  209. * Pointer must be non-NULL and buffer must be at least 'size' bytes long.
  210. * @param src_offset Address of the data to be read, relative to the
  211. * beginning of the partition.
  212. * @param size Size of data to be read, in bytes.
  213. *
  214. * @return ESP_OK, if data was read successfully;
  215. * ESP_ERR_INVALID_ARG, if src_offset exceeds partition size;
  216. * ESP_ERR_INVALID_SIZE, if read would go out of bounds of the partition;
  217. * or one of error codes from lower-level flash driver.
  218. */
  219. esp_err_t esp_partition_read(const esp_partition_t* partition,
  220. size_t src_offset, void* dst, size_t size);
  221. /**
  222. * @brief Write data to the partition
  223. *
  224. * Before writing data to flash, corresponding region of flash needs to be erased.
  225. * This can be done using esp_partition_erase_range function.
  226. *
  227. * Partitions marked with an encryption flag will automatically be
  228. * written via the esp_flash_write_encrypted() function. If writing to
  229. * an encrypted partition, all write offsets and lengths must be
  230. * multiples of 16 bytes. See the esp_flash_write_encrypted() function
  231. * for more details. Unencrypted partitions do not have this
  232. * restriction.
  233. *
  234. * @param partition Pointer to partition structure obtained using
  235. * esp_partition_find_first or esp_partition_get.
  236. * Must be non-NULL.
  237. * @param dst_offset Address where the data should be written, relative to the
  238. * beginning of the partition.
  239. * @param src Pointer to the source buffer. Pointer must be non-NULL and
  240. * buffer must be at least 'size' bytes long.
  241. * @param size Size of data to be written, in bytes.
  242. *
  243. * @note Prior to writing to flash memory, make sure it has been erased with
  244. * esp_partition_erase_range call.
  245. *
  246. * @return ESP_OK, if data was written successfully;
  247. * ESP_ERR_INVALID_ARG, if dst_offset exceeds partition size;
  248. * ESP_ERR_INVALID_SIZE, if write would go out of bounds of the partition;
  249. * ESP_ERR_NOT_ALLOWED, if partition is read-only;
  250. * or one of error codes from lower-level flash driver.
  251. */
  252. esp_err_t esp_partition_write(const esp_partition_t* partition,
  253. size_t dst_offset, const void* src, size_t size);
  254. /**
  255. * @brief Read data from the partition without any transformation/decryption.
  256. *
  257. * @note This function is essentially the same as \c esp_partition_read() above.
  258. * It just never decrypts data but returns it as is.
  259. *
  260. * @param partition Pointer to partition structure obtained using
  261. * esp_partition_find_first or esp_partition_get.
  262. * Must be non-NULL.
  263. * @param dst Pointer to the buffer where data should be stored.
  264. * Pointer must be non-NULL and buffer must be at least 'size' bytes long.
  265. * @param src_offset Address of the data to be read, relative to the
  266. * beginning of the partition.
  267. * @param size Size of data to be read, in bytes.
  268. *
  269. * @return ESP_OK, if data was read successfully;
  270. * ESP_ERR_INVALID_ARG, if src_offset exceeds partition size;
  271. * ESP_ERR_INVALID_SIZE, if read would go out of bounds of the partition;
  272. * or one of error codes from lower-level flash driver.
  273. */
  274. esp_err_t esp_partition_read_raw(const esp_partition_t* partition,
  275. size_t src_offset, void* dst, size_t size);
  276. /**
  277. * @brief Write data to the partition without any transformation/encryption.
  278. *
  279. * @note This function is essentially the same as \c esp_partition_write() above.
  280. * It just never encrypts data but writes it as is.
  281. *
  282. * Before writing data to flash, corresponding region of flash needs to be erased.
  283. * This can be done using esp_partition_erase_range function.
  284. *
  285. * @param partition Pointer to partition structure obtained using
  286. * esp_partition_find_first or esp_partition_get.
  287. * Must be non-NULL.
  288. * @param dst_offset Address where the data should be written, relative to the
  289. * beginning of the partition.
  290. * @param src Pointer to the source buffer. Pointer must be non-NULL and
  291. * buffer must be at least 'size' bytes long.
  292. * @param size Size of data to be written, in bytes.
  293. *
  294. * @note Prior to writing to flash memory, make sure it has been erased with
  295. * esp_partition_erase_range call.
  296. *
  297. * @return ESP_OK, if data was written successfully;
  298. * ESP_ERR_INVALID_ARG, if dst_offset exceeds partition size;
  299. * ESP_ERR_INVALID_SIZE, if write would go out of bounds of the partition;
  300. * ESP_ERR_NOT_ALLOWED, if partition is read-only;
  301. * or one of the error codes from lower-level flash driver.
  302. */
  303. esp_err_t esp_partition_write_raw(const esp_partition_t* partition,
  304. size_t dst_offset, const void* src, size_t size);
  305. /**
  306. * @brief Erase part of the partition
  307. *
  308. * @param partition Pointer to partition structure obtained using
  309. * esp_partition_find_first or esp_partition_get.
  310. * Must be non-NULL.
  311. * @param offset Offset from the beginning of partition where erase operation
  312. * should start. Must be aligned to partition->erase_size.
  313. * @param size Size of the range which should be erased, in bytes.
  314. * Must be divisible by partition->erase_size.
  315. *
  316. * @return ESP_OK, if the range was erased successfully;
  317. * ESP_ERR_INVALID_ARG, if iterator or dst are NULL;
  318. * ESP_ERR_INVALID_SIZE, if erase would go out of bounds of the partition;
  319. * ESP_ERR_NOT_ALLOWED, if partition is read-only;
  320. * or one of error codes from lower-level flash driver.
  321. */
  322. esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
  323. size_t offset, size_t size);
  324. /**
  325. * @brief Configure MMU to map partition into data memory
  326. *
  327. * Unlike spi_flash_mmap function, which requires a 64kB aligned base address,
  328. * this function doesn't impose such a requirement.
  329. * If offset results in a flash address which is not aligned to 64kB boundary,
  330. * address will be rounded to the lower 64kB boundary, so that mapped region
  331. * includes requested range.
  332. * Pointer returned via out_ptr argument will be adjusted to point to the
  333. * requested offset (not necessarily to the beginning of mmap-ed region).
  334. *
  335. * To release mapped memory, pass handle returned via out_handle argument to
  336. * esp_partition_munmap function.
  337. *
  338. * @param partition Pointer to partition structure obtained using
  339. * esp_partition_find_first or esp_partition_get.
  340. * Must be non-NULL.
  341. * @param offset Offset from the beginning of partition where mapping should start.
  342. * @param size Size of the area to be mapped.
  343. * @param memory Memory space where the region should be mapped
  344. * @param out_ptr Output, pointer to the mapped memory region
  345. * @param out_handle Output, handle which should be used for esp_partition_munmap call
  346. *
  347. * @return ESP_OK, if successful
  348. */
  349. esp_err_t esp_partition_mmap(const esp_partition_t* partition, size_t offset, size_t size,
  350. esp_partition_mmap_memory_t memory,
  351. const void** out_ptr, esp_partition_mmap_handle_t* out_handle);
  352. /**
  353. * @brief Release region previously obtained using esp_partition_mmap
  354. *
  355. * @note Calling this function will not necessarily unmap memory region.
  356. * Region will only be unmapped when there are no other handles which
  357. * reference this region. In case of partially overlapping regions
  358. * it is possible that memory will be unmapped partially.
  359. *
  360. * @param handle Handle obtained from spi_flash_mmap
  361. */
  362. void esp_partition_munmap(esp_partition_mmap_handle_t handle);
  363. /**
  364. * @brief Get SHA-256 digest for required partition.
  365. *
  366. * For apps with SHA-256 appended to the app image, the result is the appended SHA-256 value for the app image content.
  367. * The hash is verified before returning, if app content is invalid then the function returns ESP_ERR_IMAGE_INVALID.
  368. * For apps without SHA-256 appended to the image, the result is the SHA-256 of all bytes in the app image.
  369. * For other partition types, the result is the SHA-256 of the entire partition.
  370. *
  371. * @param[in] partition Pointer to info for partition containing app or data. (fields: address, size and type, are required to be filled).
  372. * @param[out] sha_256 Returned SHA-256 digest for a given partition.
  373. *
  374. * @return
  375. * - ESP_OK: In case of successful operation.
  376. * - ESP_ERR_INVALID_ARG: The size was 0 or the sha_256 was NULL.
  377. * - ESP_ERR_NO_MEM: Cannot allocate memory for sha256 operation.
  378. * - ESP_ERR_IMAGE_INVALID: App partition doesn't contain a valid app image.
  379. * - ESP_FAIL: An allocation error occurred.
  380. */
  381. esp_err_t esp_partition_get_sha256(const esp_partition_t* partition, uint8_t* sha_256);
  382. /**
  383. * @brief Check for the identity of two partitions by SHA-256 digest.
  384. *
  385. * @param[in] partition_1 Pointer to info for partition 1 containing app or data. (fields: address, size and type, are required to be filled).
  386. * @param[in] partition_2 Pointer to info for partition 2 containing app or data. (fields: address, size and type, are required to be filled).
  387. *
  388. * @return
  389. * - True: In case of the two firmware is equal.
  390. * - False: Otherwise
  391. */
  392. bool esp_partition_check_identity(const esp_partition_t* partition_1, const esp_partition_t* partition_2);
  393. /**
  394. * @brief Register a partition on an external flash chip
  395. *
  396. * This API allows designating certain areas of external flash chips (identified by the esp_flash_t structure)
  397. * as partitions. This allows using them with components which access SPI flash through the esp_partition API.
  398. *
  399. * @param flash_chip Pointer to the structure identifying the flash chip
  400. * @param offset Address in bytes, where the partition starts
  401. * @param size Size of the partition in bytes
  402. * @param label Partition name
  403. * @param type One of the partition types (ESP_PARTITION_TYPE_*), or an integer. Note that applications can not be booted from external flash
  404. * chips, so using ESP_PARTITION_TYPE_APP is not supported.
  405. * @param subtype One of the partition subtypes (ESP_PARTITION_SUBTYPE_*), or an integer.
  406. * @param[out] out_partition Output, if non-NULL, receives the pointer to the resulting esp_partition_t structure
  407. * @return
  408. * - ESP_OK on success
  409. * - ESP_ERR_NO_MEM if memory allocation has failed
  410. * - ESP_ERR_INVALID_ARG if the new partition overlaps another partition on the same flash chip
  411. * - ESP_ERR_INVALID_SIZE if the partition doesn't fit into the flash chip size
  412. */
  413. esp_err_t esp_partition_register_external(esp_flash_t* flash_chip, size_t offset, size_t size,
  414. const char* label, esp_partition_type_t type, esp_partition_subtype_t subtype,
  415. const esp_partition_t** out_partition);
  416. /**
  417. * @brief Deregister the partition previously registered using esp_partition_register_external
  418. * @param partition pointer to the partition structure obtained from esp_partition_register_external,
  419. * @return
  420. * - ESP_OK on success
  421. * - ESP_ERR_NOT_FOUND if the partition pointer is not found
  422. * - ESP_ERR_INVALID_ARG if the partition comes from the partition table
  423. * - ESP_ERR_INVALID_ARG if the partition was not registered using
  424. * esp_partition_register_external function.
  425. */
  426. esp_err_t esp_partition_deregister_external(const esp_partition_t* partition);
  427. #ifdef __cplusplus
  428. }
  429. #endif
  430. #endif /* __ESP_PARTITION_H__ */