简体   繁体   English

如何访问 ESP-IDF 应用程序代码中的编译时间?

[英]How to access compilation time inside ESP-IDF application code?

Is there a way to access compilation time from inside the ESP-IDF application code?有没有办法从 ESP-IDF 应用程序代码中访问编译时间? Similarly to how you can access IDF version with IDF_VER ?类似于如何使用IDF_VER访问 IDF 版本?

It is available in IDF version >= 3.3它在 IDF 版本 >= 3.3 中可用

See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/app_image_format.html#application-description请参阅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;

Access it like this:像这样访问它:

// 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM