diff --git a/rimage/elf.c b/rimage/elf.c index 6e9bd31a25e3..e2c6e8ff8257 100644 --- a/rimage/elf.c +++ b/rimage/elf.c @@ -87,11 +87,15 @@ static int elf_read_sections(struct image *image, struct module *module) fprintf(stdout, " BSS module metadata section at index %d\n", man_section_idx); - /* find log entries section */ - module->logs_index = elf_find_section(image, module, - ".static_log_entries"); + /* find log entries and fw ready sections */ + module->logs_index = elf_find_section(image, module, + ".static_log_entries"); fprintf(stdout, " static log entries section at index %d\n", module->logs_index); + module->fw_ready_index = elf_find_section(image, module, + ".fw_ready"); + fprintf(stdout, " fw ready section at index %d\n", + module->fw_ready_index); /* parse each section */ for (i = 0; i < hdr->e_shnum; i++) { @@ -352,7 +356,8 @@ static void elf_module_limits(struct image *image, struct module *module) section = &module->section[i]; /* module bss can sometimes be missed */ - if (i != module->bss_index && i != module->logs_index) { + if (i != module->bss_index && i != module->logs_index && + i != module->fw_ready_index) { /* only check valid sections */ if (!(section->sh_flags & valid)) diff --git a/rimage/file_format.h b/rimage/file_format.h index ddc07c27a9b2..935df3dc7923 100644 --- a/rimage/file_format.h +++ b/rimage/file_format.h @@ -63,6 +63,10 @@ #ifndef __INCLUDE_UAPI_SOF_FW_H__ #define __INCLUDE_UAPI_SOF_FW_H__ +/* Skip inclusion of which causes errors */ +#define __INCLUDE_IO__ +#include + #define SND_SOF_FW_SIG_SIZE 4 #define SND_SOF_FW_ABI 1 #define SND_SOF_FW_SIG "Reef" @@ -125,5 +129,6 @@ struct snd_sof_logs_header { uint32_t base_address; /* address of log entries section */ uint32_t data_length; /* amount of bytes following this header */ uint32_t data_offset; /* offset to first entry in this file */ + struct sof_ipc_fw_version version; }; #endif diff --git a/rimage/file_simple.c b/rimage/file_simple.c index 13f517a495c6..c88676c4e5cf 100644 --- a/rimage/file_simple.c +++ b/rimage/file_simple.c @@ -357,6 +357,37 @@ int write_logs_dictionary(struct image *image) for (i = 0; i < image->num_modules; i++) { struct module *module = &image->module[i]; + /* extract fw_version from fw_ready message located + * in .fw_ready section + */ + if (module->fw_ready_index > 0) { + Elf32_Shdr *section = + &module->section[module->fw_ready_index]; + + buffer = calloc(1, sizeof(struct sof_ipc_fw_ready)); + if (!buffer) + return -ENOMEM; + + fseek(module->fd, section->sh_offset, SEEK_SET); + size_t count = fread(buffer, 1, + sizeof(struct sof_ipc_fw_ready), module->fd); + + if (count != sizeof(struct sof_ipc_fw_ready)) { + fprintf(stderr, + "error: can't read ready section %d\n", + -errno); + ret = -errno; + goto out; + } + + memcpy(&header.version, + &((struct sof_ipc_fw_ready *)buffer)->version, + sizeof(header.version)); + + free(buffer); + buffer = NULL; + } + if (module->logs_index > 0) { Elf32_Shdr *section = &module->section[module->logs_index]; @@ -374,7 +405,8 @@ int write_logs_dictionary(struct image *image) size_t count = fread(buffer, 1, section->sh_size, module->fd); if (count != section->sh_size) { - fprintf(stderr, "error: can't read section %d\n", + fprintf(stderr, + "error: can't read logs section %d\n", -errno); ret = -errno; goto out; @@ -388,8 +420,10 @@ int write_logs_dictionary(struct image *image) goto out; } - fprintf(stdout, "logs dictionary: size %d\n\n", + fprintf(stdout, "logs dictionary: size %u\n", header.data_length + header.data_offset); + fprintf(stdout, "including fw version of size: %lu\n\n", + sizeof(header.version)); } } out: diff --git a/rimage/rimage.h b/rimage/rimage.h index b3ca3bbe73d5..6752005a0e1c 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -70,6 +70,7 @@ struct module { int fw_size; int bss_index; int logs_index; + int fw_ready_index; /* sizes do not include any gaps */ int bss_size; diff --git a/src/platform/apollolake/apollolake.x.in b/src/platform/apollolake/apollolake.x.in index a405b0a112a0..fd6976505fbc 100644 --- a/src/platform/apollolake/apollolake.x.in +++ b/src/platform/apollolake/apollolake.x.in @@ -567,4 +567,8 @@ SECTIONS *(*.static_log*) } > static_log_entries_seg :static_log_entries_phdr + .fw_ready : ALIGN(4) + { + KEEP (*(.fw_ready)) + } >sof_data :sof_data_phdr } diff --git a/src/platform/baytrail/baytrail.x.in b/src/platform/baytrail/baytrail.x.in index c5b6f80ba0bd..e71d824fef76 100755 --- a/src/platform/baytrail/baytrail.x.in +++ b/src/platform/baytrail/baytrail.x.in @@ -513,5 +513,9 @@ SECTIONS { *(*.static_log*) } > static_log_entries_seg :static_log_entries_phdr -} + .fw_ready : ALIGN(4) + { + KEEP (*(.fw_ready)) + } >sof_data :sof_data_phdr +} diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 1f8093c69766..66b542d432ac 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -57,7 +57,8 @@ #include #include -static const struct sof_ipc_fw_ready ready = { +static const struct sof_ipc_fw_ready ready + __attribute__((section(".fw_ready"))) = { .hdr = { .cmd = SOF_IPC_FW_READY, .size = sizeof(struct sof_ipc_fw_ready), diff --git a/src/platform/cannonlake/cannonlake.x.in b/src/platform/cannonlake/cannonlake.x.in index 00af66646d30..2b45572eb926 100644 --- a/src/platform/cannonlake/cannonlake.x.in +++ b/src/platform/cannonlake/cannonlake.x.in @@ -556,4 +556,9 @@ SECTIONS { *(*.static_log*) } > static_log_entries_seg :static_log_entries_phdr + + .fw_ready : ALIGN(4) + { + KEEP (*(.fw_ready)) + } >sof_data :sof_data_phdr } diff --git a/src/platform/haswell/broadwell.x.in b/src/platform/haswell/broadwell.x.in index 9704112b47ee..bf88006909eb 100755 --- a/src/platform/haswell/broadwell.x.in +++ b/src/platform/haswell/broadwell.x.in @@ -513,5 +513,9 @@ SECTIONS { *(*.static_log*) } > static_log_entries_seg :static_log_entries_phdr -} + .fw_ready : ALIGN(4) + { + KEEP (*(.fw_ready)) + } >sof_data :sof_data_phdr +} diff --git a/src/platform/haswell/haswell.x.in b/src/platform/haswell/haswell.x.in index db39f3af4e20..33b358c10a23 100755 --- a/src/platform/haswell/haswell.x.in +++ b/src/platform/haswell/haswell.x.in @@ -513,5 +513,9 @@ SECTIONS { *(*.static_log*) } > static_log_entries_seg :static_log_entries_phdr -} + .fw_ready : ALIGN(4) + { + KEEP (*(.fw_ready)) + } >sof_data :sof_data_phdr +} diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c index 91042cd03abd..f4c029192fca 100644 --- a/src/platform/haswell/platform.c +++ b/src/platform/haswell/platform.c @@ -56,7 +56,8 @@ #include #include -static const struct sof_ipc_fw_ready ready = { +static const struct sof_ipc_fw_ready ready + __attribute__((section(".fw_ready"))) = { .hdr = { .cmd = SOF_IPC_FW_READY, .size = sizeof(struct sof_ipc_fw_ready), diff --git a/src/platform/icelake/icelake.x.in b/src/platform/icelake/icelake.x.in index c6ea4fe9f70c..122d625873c3 100644 --- a/src/platform/icelake/icelake.x.in +++ b/src/platform/icelake/icelake.x.in @@ -556,4 +556,9 @@ SECTIONS { *(*.static_log*) } > static_log_entries_seg :static_log_entries_phdr + + .fw_ready : ALIGN(4) + { + KEEP (*(.fw_ready)) + } >sof_data :sof_data_phdr } diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index bfc39e2f1c87..5cec87ca133b 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -58,7 +58,8 @@ #include #include -static const struct sof_ipc_fw_ready ready = { +static const struct sof_ipc_fw_ready ready + __attribute__((section(".fw_ready"))) = { .hdr = { .cmd = SOF_IPC_FW_READY, .size = sizeof(struct sof_ipc_fw_ready), diff --git a/src/platform/suecreek/suecreek.x.in b/src/platform/suecreek/suecreek.x.in index 373515faa0e6..235185ce7027 100644 --- a/src/platform/suecreek/suecreek.x.in +++ b/src/platform/suecreek/suecreek.x.in @@ -555,4 +555,9 @@ SECTIONS { *(*.static_log*) } > static_log_entries_seg :static_log_entries_phdr + + .fw_ready : ALIGN(4) + { + KEEP (*(.fw_ready)) + } >sof_data :sof_data_phdr }