@@ -16,6 +16,8 @@
static void print_mdata(struct fwu_mdata *mdata)
{
int i, j;
+ uint8_t num_banks;
+ uint16_t num_images;
struct fwu_image_entry *img_entry;
struct fwu_image_bank_info *img_info;
@@ -25,15 +27,22 @@ static void print_mdata(struct fwu_mdata *mdata)
printf("active_index: %#x\n", mdata->active_index);
printf("previous_active_index: %#x\n", mdata->previous_active_index);
+ num_banks = fwu_get_fw_desc(mdata)->num_banks;
+ num_images = fwu_get_fw_desc(mdata)->num_images;
+
+ for (i = 0; i < 4; i++)
+ printf("bank_state[%d]: %#x\n", i, mdata->bank_state[i]);
+
printf("\tImage Info\n");
- for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) {
- img_entry = &mdata->img_entry[i];
+
+ for (i = 0; i < num_images; i++) {
+ img_entry = fwu_img_entry_offset(mdata, i);
printf("\nImage Type Guid: %pUL\n",
- &img_entry->image_type_uuid);
- printf("Location Guid: %pUL\n", &img_entry->location_uuid);
- for (j = 0; j < CONFIG_FWU_NUM_BANKS; j++) {
- img_info = &img_entry->img_bank_info[j];
- printf("Image Guid: %pUL\n", &img_info->image_uuid);
+ &img_entry->image_type_guid);
+ printf("Location Guid: %pUL\n", &img_entry->location_guid);
+ for (j = 0; j < num_banks; j++) {
+ img_info = fwu_img_bank_info_offset(mdata, i, j);
+ printf("Image Guid: %pUL\n", &img_info->image_guid);
printf("Image Acceptance: %s\n",
img_info->accepted == 0x1 ? "yes" : "no");
}
@@ -43,19 +52,35 @@ static void print_mdata(struct fwu_mdata *mdata)
int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag,
int argc, char * const argv[])
{
+ uint32_t mdata_size;
+ struct fwu_mdata *mdata = NULL;
int ret = CMD_RET_SUCCESS, res;
- struct fwu_mdata mdata;
- res = fwu_get_mdata(&mdata);
+ res = fwu_get_mdata_size(&mdata_size);
+ if (res) {
+ log_err("Unable to get FWU metadata size\n");
+ ret = CMD_RET_FAILURE;
+ goto out;
+ }
+
+ mdata = malloc(mdata_size);
+ if (!mdata) {
+ log_err("Unable to allocate memory for FWU metadata\n");
+ ret = CMD_RET_FAILURE;
+ goto out;
+ }
+
+ res = fwu_get_mdata(mdata);
if (res < 0) {
log_err("Unable to get valid FWU metadata\n");
ret = CMD_RET_FAILURE;
goto out;
}
- print_mdata(&mdata);
+ print_mdata(mdata);
out:
+ free(mdata);
return ret;
}
Make changes to the fwu_mdata_read command to have it align with the metadata version 2. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> --- Changes since V1: * Use the helper functions from the previous patch to access the image information in the metadata. cmd/fwu_mdata.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-)