mirror of https://github.com/thesofproject/sof.git
Take firmware version and build ID as command line arguments
Since rimage is no longer built with the SOF code, the firmware version (SOF_MAJOR and SOF_MINOR) and build ID (SOF_BUILD) are no longer defined during build. So these needs to be passed as command line arguments. Signed-off-by: Daniel Leung <danielcp@gmail.com>
This commit is contained in:
parent
606b4f0442
commit
41cba2f663
|
@ -125,6 +125,13 @@ struct image {
|
|||
char out_rom_file[256];
|
||||
char out_man_file[256];
|
||||
char out_unsigned_file[256];
|
||||
|
||||
/* fw version and build id */
|
||||
char* fw_ver_string;
|
||||
char* fw_ver_build_string;
|
||||
uint16_t fw_ver_major;
|
||||
uint16_t fw_ver_minor;
|
||||
uint16_t fw_ver_build;
|
||||
};
|
||||
|
||||
struct mem_zone {
|
||||
|
|
|
@ -49,10 +49,10 @@ struct fw_image_manifest_v1_8 apl_manifest = {
|
|||
.header_id = MAN_CSS_HDR_ID,
|
||||
.padding = 0,
|
||||
.version = {
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
},
|
||||
.modulus_size = MAN_CSS_MOD_SIZE,
|
||||
.exponent_size = MAN_CSS_EXP_SIZE,
|
||||
|
@ -116,10 +116,10 @@ struct fw_image_manifest_v1_8 apl_manifest = {
|
|||
.preload_page_count = 0, /* size in pages from $CPD */
|
||||
.fw_image_flags = SOF_MAN_FW_HDR_FLAGS,
|
||||
.feature_mask = SOF_MAN_FW_HDR_FEATURES,
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
.load_offset = MAN_DESC_OFFSET_V1_8,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -48,10 +48,10 @@ struct fw_image_manifest_v1_8 cnl_manifest = {
|
|||
.header_id = MAN_CSS_HDR_ID,
|
||||
.padding = 0,
|
||||
.version = {
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
},
|
||||
.modulus_size = MAN_CSS_MOD_SIZE,
|
||||
.exponent_size = MAN_CSS_EXP_SIZE,
|
||||
|
@ -115,10 +115,10 @@ struct fw_image_manifest_v1_8 cnl_manifest = {
|
|||
.preload_page_count = 0, /* size in pages from $CPD */
|
||||
.fw_image_flags = SOF_MAN_FW_HDR_FLAGS,
|
||||
.feature_mask = SOF_MAN_FW_HDR_FEATURES,
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
.load_offset = 0x30000,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -37,10 +37,10 @@ struct fw_image_manifest_v1_5 kbl_manifest = {
|
|||
.preload_page_count = 0,
|
||||
.fw_image_flags = SOF_MAN_FW_HDR_FLAGS,
|
||||
.feature_mask = SOF_MAN_FW_HDR_FEATURES,
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
.load_offset = 0,
|
||||
.hw_buf_base_addr = KBL_HARDWARE_BUFFER_BASE,
|
||||
.hw_buf_length = KBL_HARDWARE_BUFFER_LEN
|
||||
|
|
|
@ -17,10 +17,10 @@ struct fw_image_manifest_v1_5_sue sue_manifest = {
|
|||
.preload_page_count = 0, /* size in pages from $CPD */
|
||||
.fw_image_flags = SOF_MAN_FW_HDR_FLAGS,
|
||||
.feature_mask = SOF_MAN_FW_HDR_FEATURES,
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
.load_offset = 0x2000,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -48,10 +48,10 @@ struct fw_image_manifest_v2_5 tgl_manifest = {
|
|||
.header_id = MAN_CSS_HDR_ID,
|
||||
.padding = 0,
|
||||
.version = {
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
},
|
||||
.modulus_size = MAN_CSS_MOD_SIZE,
|
||||
.exponent_size = MAN_CSS_EXP_SIZE,
|
||||
|
@ -115,10 +115,10 @@ struct fw_image_manifest_v2_5 tgl_manifest = {
|
|||
.preload_page_count = 0, /* size in pages from $CPD */
|
||||
.fw_image_flags = SOF_MAN_FW_HDR_FLAGS,
|
||||
.feature_mask = SOF_MAN_FW_HDR_FEATURES,
|
||||
.major_version = SOF_MAJOR,
|
||||
.minor_version = SOF_MINOR,
|
||||
.major_version = 0,
|
||||
.minor_version = 0,
|
||||
.hotfix_version = 0,
|
||||
.build_version = SOF_BUILD,
|
||||
.build_version = 0,
|
||||
.load_offset = 0x30000,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -727,6 +727,11 @@ static int man_write_fw_v1_5(struct image *image)
|
|||
m = image->fw_image;
|
||||
desc = image->fw_image + MAN_DESC_OFFSET_V1_5;
|
||||
|
||||
/* 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.build_version = image->fw_ver_build;
|
||||
|
||||
/* create each module */
|
||||
m->desc.header.num_module_entries = image->num_modules;
|
||||
man_create_modules(image, desc, FILE_TEXT_OFFSET_V1_5);
|
||||
|
@ -791,6 +796,11 @@ static int man_write_fw_v1_5_sue(struct image *image)
|
|||
/* create the module */
|
||||
m = image->fw_image + MAN_DESC_OFFSET_V1_5_SUE;
|
||||
|
||||
/* 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.build_version = image->fw_ver_build;
|
||||
|
||||
/* create each module - subtract the boot loader exec header */
|
||||
m->desc.header.num_module_entries = image->num_modules - 1;
|
||||
man_create_modules(image, &m->desc, FILE_TEXT_OFFSET_V1_5_SUE);
|
||||
|
@ -854,6 +864,14 @@ static int man_write_fw_v1_8(struct image *image)
|
|||
m = image->fw_image;
|
||||
desc = image->fw_image + MAN_DESC_OFFSET_V1_8;
|
||||
|
||||
/* firmware and build version */
|
||||
m->css.version.major_version = image->fw_ver_major;
|
||||
m->css.version.minor_version = image->fw_ver_minor;
|
||||
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.build_version = image->fw_ver_build;
|
||||
|
||||
/* create each module */
|
||||
m->desc.header.num_module_entries = image->num_modules;
|
||||
man_create_modules(image, desc, FILE_TEXT_OFFSET_V1_8);
|
||||
|
|
34
src/rimage.c
34
src/rimage.c
|
@ -40,6 +40,8 @@ static void usage(char *name)
|
|||
#endif /* HAS_FILE_FORMAT_H */
|
||||
fprintf(stdout, "\t -i set IMR type\n");
|
||||
fprintf(stdout, "\t -x set xcc module offset\n");
|
||||
fprintf(stdout, "\t -f firmware version = x.y\n");
|
||||
fprintf(stdout, "\t -b build version\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -54,7 +56,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
image.xcc_mod_offset = DEFAULT_XCC_MOD_OFFSET;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ho:p:m:vba:s:k:l:ri:x:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "ho:p:m:va:s:k:l:ri:x:f:b:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
image.out_file = optarg;
|
||||
|
@ -92,6 +94,12 @@ int main(int argc, char *argv[])
|
|||
case 'x':
|
||||
image.xcc_mod_offset = atoi(optarg);
|
||||
break;
|
||||
case 'f':
|
||||
image.fw_ver_string = optarg;
|
||||
break;
|
||||
case 'b':
|
||||
image.fw_ver_build_string = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
break;
|
||||
|
@ -117,6 +125,30 @@ int main(int argc, char *argv[])
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* firmware version and build id */
|
||||
if (image.fw_ver_string) {
|
||||
ret = sscanf(image.fw_ver_string, "%hu.%hu",
|
||||
&image.fw_ver_major,
|
||||
&image.fw_ver_minor);
|
||||
|
||||
if (ret != 2) {
|
||||
fprintf(stderr,
|
||||
"error: cannot parse firmware version\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (image.fw_ver_build_string) {
|
||||
ret = sscanf(image.fw_ver_build_string, "%hu",
|
||||
&image.fw_ver_build);
|
||||
|
||||
if (ret != 1) {
|
||||
fprintf(stderr,
|
||||
"error: cannot parse build version\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* find machine */
|
||||
for (i = 0; i < ARRAY_SIZE(machine); i++) {
|
||||
if (!strcmp(mach, machine[i]->name)) {
|
||||
|
|
Loading…
Reference in New Issue