是否有方法从ESP-IDF应用程序代码内部访问编译时间?类似于如何使用IDF_VER
访问IDF版本?
它有IDF版本>=3.3
请参阅https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/app_image_format.html#application-描述
/**
* @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