mirror of https://github.com/thesofproject/sof.git
rimage: debugability: include fw_version in .ldc file
Extract fw_version from fw_ready section of elf and include it in header of .ldc file to allow verification by sof-logger. Signed-off-by: ArturX Kloniecki <arturx.kloniecki@linux.intel.com>
This commit is contained in:
parent
f59e7061d3
commit
0f3f9c0807
13
rimage/elf.c
13
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))
|
||||
|
|
|
@ -63,6 +63,10 @@
|
|||
#ifndef __INCLUDE_UAPI_SOF_FW_H__
|
||||
#define __INCLUDE_UAPI_SOF_FW_H__
|
||||
|
||||
/* Skip inclusion of <sof/io.h> which causes errors */
|
||||
#define __INCLUDE_IO__
|
||||
#include <uapi/ipc.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue