esp_app_desc.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * SPDX-FileCopyrightText: 2022-2023 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. #include "esp_assert.h"
  12. #include "esp_attr.h"
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17. #define ESP_APP_DESC_MAGIC_WORD (0xABCD5432) /*!< The magic word for the esp_app_desc structure that is in DROM. */
  18. /**
  19. * @brief Description about application.
  20. */
  21. typedef struct {
  22. uint32_t magic_word; /*!< Magic word ESP_APP_DESC_MAGIC_WORD */
  23. uint32_t secure_version; /*!< Secure version */
  24. uint32_t reserv1[2]; /*!< reserv1 */
  25. char version[32]; /*!< Application version */
  26. char project_name[32]; /*!< Project name */
  27. char time[16]; /*!< Compile time */
  28. char date[16]; /*!< Compile date*/
  29. char idf_ver[32]; /*!< Version IDF */
  30. uint8_t app_elf_sha256[32]; /*!< sha256 of elf file */
  31. uint32_t reserv2[20]; /*!< reserv2 */
  32. } esp_app_desc_t;
  33. /** @cond */
  34. ESP_STATIC_ASSERT(sizeof(esp_app_desc_t) == 256, "esp_app_desc_t should be 256 bytes");
  35. /** @endcond */
  36. /**
  37. * @brief Return esp_app_desc structure. This structure includes app version.
  38. *
  39. * Return description for running app.
  40. * @return Pointer to esp_app_desc structure.
  41. */
  42. const esp_app_desc_t *esp_app_get_description(void);
  43. /**
  44. * @brief Fill the provided buffer with SHA256 of the ELF file, formatted as hexadecimal, null-terminated.
  45. * If the buffer size is not sufficient to fit the entire SHA256 in hex plus a null terminator,
  46. * the largest possible number of bytes will be written followed by a null.
  47. * @param dst Destination buffer
  48. * @param size Size of the buffer
  49. * @return Number of bytes written to dst (including null terminator)
  50. */
  51. int esp_app_get_elf_sha256(char* dst, size_t size);
  52. /** @cond */
  53. extern char app_elf_sha256_str[];
  54. /** @endcond */
  55. /**
  56. * @brief Return SHA256 of the ELF file which is already formatted as hexadecimal, null-terminated included.
  57. * Can be used in panic handler or core dump during when cache is disabled.
  58. * The length is defined by CONFIG_APP_RETRIEVE_LEN_ELF_SHA option.
  59. * @return Hexadecimal SHA256 string
  60. */
  61. FORCE_INLINE_ATTR char *esp_app_get_elf_sha256_str(void)
  62. {
  63. return app_elf_sha256_str;
  64. }
  65. #ifdef __cplusplus
  66. }
  67. #endif