2

有没有办法从 ESP-IDF 应用程序代码中访问编译时间?与您如何访问 IDF 版本类似IDF_VER

4

1 回答 1

1

它在 IDF 版本 >= 3.3 中可用

请参阅https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/app_image_format.html#application-description

/**
 * @brief Description about application.
 */
typedef struct {
    uint32_t magic_word;        /*!< Magic word ESP_APP_DESC_MAGIC_WORD */
    uint32_t secure_version;    /*!< Secure version */
    uint32_t reserv1[2];        /*!< --- */
    char version[32];           /*!< Application version */
    char project_name[32];      /*!< Project name */
    char time[16];              /*!< Compile time */
    char date[16];              /*!< Compile date*/
    char idf_ver[32];           /*!< Version IDF */
    uint8_t app_elf_sha256[32]; /*!< sha256 of elf file */
    uint32_t reserv2[20];       /*!< --- */
} esp_app_desc_t;

像这样访问它:

// Note esp_ota_get_partition_description() was introduced in ESP-IDF 3.3.
#ifdef ESP_APP_DESC_MAGIC_WORD // enable functionality only if present in IDF by testing for macro.
esp_app_desc_t app_info;
if (esp_ota_get_partition_description(it_partition, &app_info) == ESP_OK)
{
    ESP_LOGI(TAG, "compilation_time:%s", app_info.time);
}
#endif
于 2020-09-10T01:06:32.213 回答