【问题标题】:How to access compilation time inside ESP-IDF application code?如何访问 ESP-IDF 应用程序代码中的编译时间?
【发布时间】:2020-05-29 15:39:11
【问题描述】:

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

【问题讨论】:

    标签: c esp-idf


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-17
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 2012-02-13
      相关资源
      最近更新 更多