Просмотр исходного кода

app_update: Add EXCLUDE option

Added two options for PROJECT_NAME and PROJECT_VER variables to exclude them from the firmware image.

Closes: https://github.com/espressif/esp-idf/issues/2803
Konstantin Kondrashov 7 лет назад
Родитель
Сommit
51133083f6
3 измененных файлов с 31 добавлено и 0 удалено
  1. 14 0
      components/app_update/Kconfig.projbuild
  2. 13 0
      components/app_update/esp_app_desc.c
  3. 4 0
      components/esp32/cpu_start.c

+ 14 - 0
components/app_update/Kconfig.projbuild

@@ -9,4 +9,18 @@ config APP_COMPILE_TIME_DATE
         This can be useful for getting the same binary image files made from the same source, 
         This can be useful for getting the same binary image files made from the same source, 
         but at different times.
         but at different times.
 
 
+config APP_EXCLUDE_PROJECT_VER_VAR
+    bool "Exclude PROJECT_VER from firmware image"
+    default n
+	help
+        The PROJECT_VER variable from the build system will not affect the firmware image.
+        This value will not be contained in the esp_app_desc structure.
+
+config APP_EXCLUDE_PROJECT_NAME_VAR
+    bool "Exclude PROJECT_NAME from firmware image"
+    default n
+	help
+        The PROJECT_NAME variable from the build system will not affect the firmware image.
+        This value will not be contained in the esp_app_desc structure.
+
 endmenu # "Application manager"
 endmenu # "Application manager"

+ 13 - 0
components/app_update/esp_app_desc.c

@@ -19,8 +19,17 @@
 // Application version info
 // Application version info
 const __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = {
 const __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = {
     .magic_word = ESP_APP_DESC_MAGIC_WORD,
     .magic_word = ESP_APP_DESC_MAGIC_WORD,
+#ifdef CONFIG_APP_EXCLUDE_PROJECT_VER_VAR
+    .version = "",
+#else
     .version = PROJECT_VER,
     .version = PROJECT_VER,
+#endif
+
+#ifdef CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR
+    .project_name = "",
+#else
     .project_name = PROJECT_NAME,
     .project_name = PROJECT_NAME,
+#endif
     .idf_ver = IDF_VER,
     .idf_ver = IDF_VER,
 
 
 #ifdef CONFIG_APP_SECURE_VERSION
 #ifdef CONFIG_APP_SECURE_VERSION
@@ -39,9 +48,13 @@ const __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = {
 };
 };
 
 
 
 
+#ifndef CONFIG_APP_EXCLUDE_PROJECT_VER_VAR
 _Static_assert(sizeof(PROJECT_VER) <= sizeof(esp_app_desc.version), "PROJECT_VER is longer than version field in structure");
 _Static_assert(sizeof(PROJECT_VER) <= sizeof(esp_app_desc.version), "PROJECT_VER is longer than version field in structure");
+#endif
 _Static_assert(sizeof(IDF_VER) <= sizeof(esp_app_desc.idf_ver), "IDF_VER is longer than idf_ver field in structure");
 _Static_assert(sizeof(IDF_VER) <= sizeof(esp_app_desc.idf_ver), "IDF_VER is longer than idf_ver field in structure");
+#ifndef CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR
 _Static_assert(sizeof(PROJECT_NAME) <= sizeof(esp_app_desc.project_name), "PROJECT_NAME is longer than project_name field in structure");
 _Static_assert(sizeof(PROJECT_NAME) <= sizeof(esp_app_desc.project_name), "PROJECT_NAME is longer than project_name field in structure");
+#endif
 
 
 const esp_app_desc_t *esp_ota_get_app_description(void)
 const esp_app_desc_t *esp_ota_get_app_description(void)
 {
 {

+ 4 - 0
components/esp32/cpu_start.c

@@ -179,8 +179,12 @@ void IRAM_ATTR call_start_cpu0()
     if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) {
     if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) {
         const esp_app_desc_t *app_desc = esp_ota_get_app_description();
         const esp_app_desc_t *app_desc = esp_ota_get_app_description();
         ESP_EARLY_LOGI(TAG, "Application information:");
         ESP_EARLY_LOGI(TAG, "Application information:");
+#ifndef CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR
         ESP_EARLY_LOGI(TAG, "Project name:     %s", app_desc->project_name);
         ESP_EARLY_LOGI(TAG, "Project name:     %s", app_desc->project_name);
+#endif
+#ifndef CONFIG_APP_EXCLUDE_PROJECT_VER_VAR
         ESP_EARLY_LOGI(TAG, "App version:      %s", app_desc->version);
         ESP_EARLY_LOGI(TAG, "App version:      %s", app_desc->version);
+#endif
 #ifdef CONFIG_APP_SECURE_VERSION
 #ifdef CONFIG_APP_SECURE_VERSION
         ESP_EARLY_LOGI(TAG, "Secure version:   %x", app_desc->secure_version);
         ESP_EARLY_LOGI(TAG, "Secure version:   %x", app_desc->secure_version);
 #endif
 #endif