Skip to content

Commit

Permalink
Write firmware file micro version to manifest for cAVS platforms
Browse files Browse the repository at this point in the history
SOF CMake can extract FW file version from latest git tag and defines
SOF_MAJOR, SOF_MINOR and SOF_MICRO for 3 version fields. But rimage only
gets major and minor version from SOF CMake and writes them into the
standard firmware manifest header of cAVS platforms.

This patch make rimage also get the micro version from SOF CMake, and
write it to the unused hotfix_version field of manifest header.

This update will enable sof_ri_info.py to dump entire file version from
a FW binary for cAVS platforms. So we can check if a FW release candidate
is built from the correct git tag.

Signed-off-by: mengdonglin <[email protected]>

update
  • Loading branch information
mengdonglin authored and lgirdwood committed May 9, 2022
1 parent 05be213 commit 9d45332
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/include/rimage/rimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct image {
char* fw_ver_build_string;
uint16_t fw_ver_major;
uint16_t fw_ver_minor;
uint16_t fw_ver_micro;
uint16_t fw_ver_build;
};

Expand Down
7 changes: 7 additions & 0 deletions src/manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ int man_write_fw_v1_5(struct image *image)
/* firmware and build version */
m->desc.header.major_version = image->fw_ver_major;
m->desc.header.minor_version = image->fw_ver_minor;
m->desc.header.hotfix_version = image->fw_ver_micro;
m->desc.header.build_version = image->fw_ver_build;

/* create each module */
Expand Down Expand Up @@ -845,6 +846,7 @@ int man_write_fw_v1_5_sue(struct image *image)
/* firmware and build version */
m->desc.header.major_version = image->fw_ver_major;
m->desc.header.minor_version = image->fw_ver_minor;
m->desc.header.hotfix_version = image->fw_ver_micro;
m->desc.header.build_version = image->fw_ver_build;

/* create each module - subtract the boot loader exec header */
Expand Down Expand Up @@ -916,6 +918,7 @@ int man_write_fw_v1_8(struct image *image)
m->css.version.build_version = image->fw_ver_build;
m->desc.header.major_version = image->fw_ver_major;
m->desc.header.minor_version = image->fw_ver_minor;
m->desc.header.hotfix_version = image->fw_ver_micro;
m->desc.header.build_version = image->fw_ver_build;

/* create each module */
Expand Down Expand Up @@ -1022,6 +1025,7 @@ int man_write_fw_meu_v1_5(struct image *image)
/* firmware and build version */
desc->header.major_version = image->fw_ver_major;
desc->header.minor_version = image->fw_ver_minor;
desc->header.hotfix_version = image->fw_ver_micro;
desc->header.build_version = image->fw_ver_build;

/* create each module */
Expand Down Expand Up @@ -1102,6 +1106,7 @@ int man_write_fw_meu_v1_8(struct image *image)
/* firmware and build version */
desc->header.major_version = image->fw_ver_major;
desc->header.minor_version = image->fw_ver_minor;
desc->header.hotfix_version = image->fw_ver_micro;
desc->header.build_version = image->fw_ver_build;

/* create each module */
Expand Down Expand Up @@ -1182,6 +1187,7 @@ int man_write_fw_meu_v2_5(struct image *image)
/* firmware and build version */
desc->header.major_version = image->fw_ver_major;
desc->header.minor_version = image->fw_ver_minor;
desc->header.hotfix_version = image->fw_ver_micro;
desc->header.build_version = image->fw_ver_build;

/* create each module */
Expand Down Expand Up @@ -1266,6 +1272,7 @@ int man_write_fw_v2_5(struct image *image)
m->css.version.build_version = image->fw_ver_build;
m->desc.header.major_version = image->fw_ver_major;
m->desc.header.minor_version = image->fw_ver_minor;
m->desc.header.hotfix_version = image->fw_ver_micro;
m->desc.header.build_version = image->fw_ver_build;

/* create each module */
Expand Down
14 changes: 8 additions & 6 deletions src/rimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void usage(char *name)
fprintf(stdout, "\t -r enable relocatable ELF files\n");
fprintf(stdout, "\t -s MEU signing offset, disables rimage signing\n");
fprintf(stdout, "\t -i set IMR type\n");
fprintf(stdout, "\t -f firmware version = x.y\n");
fprintf(stdout, "\t -f firmware version = major.minor.micro\n");
fprintf(stdout, "\t -b build version\n");
fprintf(stdout, "\t -e build extended manifest\n");
fprintf(stdout, "\t -y verify signed file\n");
Expand Down Expand Up @@ -115,19 +115,21 @@ int main(int argc, char *argv[])
return -EINVAL;
}

/* firmware version and build id */
/* firmware version: major.minor.micro */
if (image.fw_ver_string) {
ret = sscanf(image.fw_ver_string, "%hu.%hu",
ret = sscanf(image.fw_ver_string, "%hu.%hu.%hu",
&image.fw_ver_major,
&image.fw_ver_minor);
&image.fw_ver_minor,
&image.fw_ver_micro);

if (ret != 2) {
if (ret != 3) {
fprintf(stderr,
"error: cannot parse firmware version\n");
"error: cannot parse firmware version major.minor.micro\n");
return -EINVAL;
}
}

/* firmware build id */
if (image.fw_ver_build_string) {
ret = sscanf(image.fw_ver_build_string, "%hu",
&image.fw_ver_build);
Expand Down

0 comments on commit 9d45332

Please sign in to comment.