esp_app_desc.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. #include <stddef.h>
  10. #include "esp_err.h"
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. #define ESP_APP_DESC_MAGIC_WORD (0xABCD5432) /*!< The magic word for the esp_app_desc structure that is in DROM. */
  16. /**
  17. * @brief Description about application.
  18. */
  19. typedef struct {
  20. uint32_t magic_word; /*!< Magic word ESP_APP_DESC_MAGIC_WORD */
  21. uint32_t secure_version; /*!< Secure version */
  22. uint32_t reserv1[2]; /*!< reserv1 */
  23. char version[32]; /*!< Application version */
  24. char project_name[32]; /*!< Project name */
  25. char time[16]; /*!< Compile time */
  26. char date[16]; /*!< Compile date*/
  27. char idf_ver[32]; /*!< Version IDF */
  28. uint8_t app_elf_sha256[32]; /*!< sha256 of elf file */
  29. uint32_t reserv2[20]; /*!< reserv2 */
  30. } esp_app_desc_t;
  31. /** @cond */
  32. _Static_assert(sizeof(esp_app_desc_t) == 256, "esp_app_desc_t should be 256 bytes");
  33. /** @endcond */
  34. /**
  35. * @brief Return esp_app_desc structure. This structure includes app version.
  36. *
  37. * Return description for running app.
  38. * @return Pointer to esp_app_desc structure.
  39. */
  40. const esp_app_desc_t *esp_app_get_description(void);
  41. /**
  42. * @brief Fill the provided buffer with SHA256 of the ELF file, formatted as hexadecimal, null-terminated.
  43. * If the buffer size is not sufficient to fit the entire SHA256 in hex plus a null terminator,
  44. * the largest possible number of bytes will be written followed by a null.
  45. * @param dst Destination buffer
  46. * @param size Size of the buffer
  47. * @return Number of bytes written to dst (including null terminator)
  48. */
  49. int esp_app_get_elf_sha256(char* dst, size_t size);
  50. #ifdef __cplusplus
  51. }
  52. #endif