esp_flash_partitions.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_FLASH_PARTITIONS_H
  14. #define __ESP_FLASH_PARTITIONS_H
  15. #include "esp_err.h"
  16. #include "esp_flash_data_types.h"
  17. #include <stdbool.h>
  18. #include "sdkconfig.h"
  19. /* Pre-partition table fixed flash offsets */
  20. #define ESP_BOOTLOADER_DIGEST_OFFSET 0x0
  21. #define ESP_BOOTLOADER_OFFSET 0x1000 /* Offset of bootloader image. Has matching value in bootloader KConfig.projbuild file. */
  22. #define ESP_PARTITION_TABLE_OFFSET CONFIG_PARTITION_TABLE_OFFSET /* Offset of partition table. Backwards-compatible name.*/
  23. #define ESP_PARTITION_TABLE_MAX_LEN 0xC00 /* Maximum length of partition table data */
  24. #define ESP_PARTITION_TABLE_MAX_ENTRIES (ESP_PARTITION_TABLE_MAX_LEN / sizeof(esp_partition_info_t)) /* Maximum length of partition table data, including terminating entry */
  25. /* @brief Verify the partition table
  26. *
  27. * @param partition_table Pointer to at least ESP_PARTITION_TABLE_MAX_ENTRIES of potential partition table data. (ESP_PARTITION_TABLE_MAX_LEN bytes.)
  28. * @param log_errors Log errors if the partition table is invalid.
  29. * @param num_partitions If result is ESP_OK, num_partitions is updated with total number of partitions (not including terminating entry).
  30. *
  31. * @return ESP_OK on success, ESP_ERR_INVALID_STATE if partition table is not valid.
  32. */
  33. esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
  34. /* This function is included for compatibility with the ESP-IDF v3.x API */
  35. inline static __attribute__((deprecated)) esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
  36. {
  37. return esp_partition_table_verify(partition_table, log_errors, num_partitions);
  38. }
  39. #endif