Hi @leschge,
custom application versioning is not currently deployed in the IDF, though there is a support for generating .rodata_custom_desc section in the target binary.
Thus, if you need to add the custom versions to your application you ought to implement roughly the following (excerpts of my POC code):
Preferred runtime readout:
1. create custom application-version holder:
Code: Select all
const __attribute__((weak)) __attribute__((section(".rodata_custom_desc"))) esp_app_desc_t esp_app_desc_custom = {
.magic_word = ESP_APP_DESC_MAGIC_WORD,
.version = "app_version 1.2.3.4",
.project_name = PROJECT_NAME,
.time = "time",
.date = "date",
.idf_ver = IDF_VER
};
2. implement its getter API
Code: Select all
const esp_app_desc_t *esp_app_get_custom_description(void)
{
return &esp_app_desc_custom;
}
Direct readout from required partition (app/factory in my case):
1. implement reading the partition data from a proper offset
Code: Select all
esp_err_t esp_ota_get_partition_custom_description(const esp_partition_t *partition, esp_app_desc_t *app_desc)
{
if (partition == NULL || app_desc == NULL) {
return ESP_ERR_INVALID_ARG;
}
if(partition->type != ESP_PARTITION_TYPE_APP) {
return ESP_ERR_NOT_SUPPORTED;
}
esp_err_t err = esp_partition_read(partition, sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t), app_desc, sizeof(esp_app_desc_t));
if (err != ESP_OK) {
return err;
}
if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) {
return ESP_ERR_NOT_FOUND;
}
return ESP_OK;
}
note the offset in esp_err_t err = esp_partition_read(partition, sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t), app_desc, sizeof(esp_app_desc_t));
I assume you would like to maintain both standard app-version and the custom one in parallel. If you just like to replace one section with another, you can freely exchange .rodata_desc with .rodata_custom_desc and nothing changes for the versioning APIs, the offsets remain the same.
Regarding the bootloader usage - not sure, need to check the details first. However, the SSBL code uses own implementation for accessing the application's bin data.
Hope this helps