]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
feat(stm32mp1): add support for reading the metadata partition
authorSughosh Ganu <sughosh.ganu@linaro.org>
Wed, 1 Dec 2021 11:16:34 +0000 (16:46 +0530)
committerSughosh Ganu <sughosh.ganu@linaro.org>
Thu, 27 Jan 2022 12:39:02 +0000 (18:09 +0530)
Add support for reading the FWU metadata partition. The metadata
partition stores information on the current active bank along with
information on all the FWU updatable images on the platform. This
information is then used to identify the image to be booted.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Change-Id: I66bc5ac718c21a49c504e698b5b1f5c4daed2d08

plat/st/common/bl2_io_storage.c
plat/st/common/stm32mp_fconf_io.c
plat/st/stm32mp1/include/platform_def.h

index 96921e051c89ee27c0e3a62f4f18ab2b02783ae2..e129dfdb121357f5ef277b22a58f78dea62803e3 100644 (file)
@@ -548,4 +548,51 @@ void plat_fwu_set_images_source(const struct fwu_metadata *metadata)
                image_spec->length = entry->length;
        }
 }
+
+static int plat_set_image_source(unsigned int image_id,
+                                uintptr_t *handle,
+                                uintptr_t *image_spec,
+                                const char *part_name)
+{
+       struct plat_io_policy *policy;
+       io_block_spec_t *spec;
+       const partition_entry_t *entry = get_partition_entry(part_name);
+
+       if (entry == NULL) {
+               ERROR("Unable to find the %s partition\n", part_name);
+               return -ENOENT;
+       }
+
+       policy = &policies[image_id];
+
+       spec = (io_block_spec_t *)policy->image_spec;
+       spec->offset = entry->start;
+       spec->length = entry->length;
+
+       *image_spec = policy->image_spec;
+       *handle = *policy->dev_handle;
+
+       return 0;
+}
+
+int plat_fwu_set_metadata_image_source(unsigned int image_id,
+                                      uintptr_t *handle,
+                                      uintptr_t *image_spec)
+{
+       char *part_name;
+
+       assert((image_id == FWU_METADATA_IMAGE_ID) ||
+              (image_id == BKUP_FWU_METADATA_IMAGE_ID));
+
+       partition_init(GPT_IMAGE_ID);
+
+       if (image_id == FWU_METADATA_IMAGE_ID) {
+               part_name = METADATA_PART_1;
+       } else {
+               part_name = METADATA_PART_2;
+       }
+
+       return plat_set_image_source(image_id, handle, image_spec,
+                                    part_name);
+}
 #endif /* (STM32MP_SDMMC || STM32MP_EMMC) && PSA_FWU_SUPPORT */
index 7ab3b737a0a1c268ddeb5af0dc92f7a680a4101e..ca7195854ac5bc54127c096925780f3253d7478b 100644 (file)
@@ -27,6 +27,13 @@ static io_block_spec_t gpt_block_spec = {
 };
 #endif
 
+#if (STM32MP_SDMMC || STM32MP_EMMC) && PSA_FWU_SUPPORT
+io_block_spec_t metadata_block_spec = {
+       .offset = 0,    /* To be filled at runtime */
+       .length = 0,    /* To be filled at runtime */
+};
+#endif /* (STM32MP_SDMMC || STM32MP_EMMC) && PSA_FWU_SUPPORT */
+
 /* By default, STM32 platforms load images from the FIP */
 struct plat_io_policy policies[MAX_NUMBER_IDS] = {
        [FIP_IMAGE_ID] = {
@@ -43,6 +50,20 @@ struct plat_io_policy policies[MAX_NUMBER_IDS] = {
                .check = open_storage
        },
 #endif
+#if (STM32MP_SDMMC || STM32MP_EMMC) && PSA_FWU_SUPPORT
+       [FWU_METADATA_IMAGE_ID] = {
+               .dev_handle = &storage_dev_handle,
+               .image_spec = (uintptr_t)&metadata_block_spec,
+               .img_type_guid = NULL_GUID,
+               .check = open_storage
+       },
+       [BKUP_FWU_METADATA_IMAGE_ID] = {
+               .dev_handle = &storage_dev_handle,
+               .image_spec = (uintptr_t)&metadata_block_spec,
+               .img_type_guid = NULL_GUID,
+               .check = open_storage
+       },
+#endif /* (STM32MP_SDMMC || STM32MP_EMMC) && PSA_FWU_SUPPORT */
 };
 
 #define FCONF_ST_IO_UUID_NUMBER        U(8)
index 511a0e25c33f40b514d172d9607aaadceb4bad13..8ecb4c3e434f5bc0db99fc0bf4e59d08dc8d2f3b 100644 (file)
@@ -40,6 +40,9 @@
 #define BL33_BINARY_TYPE               U(0x0)
 #else /* STM32MP_USE_STM32IMAGE */
 #define FIP_IMAGE_NAME                 "fip"
+#define METADATA_PART_1                        "metadata1"
+#define METADATA_PART_2                        "metadata2"
+
 #endif /* STM32MP_USE_STM32IMAGE */
 
 #define STM32MP_PRIMARY_CPU            U(0x0)