From 25804e7dc8ee37f3cb87b0a96b58300478cd3cff Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Fri, 31 Mar 2023 12:50:25 +0200 Subject: [PATCH] manifest: Use module manifest from toml as a template for elf modules The manifest for elf modules is read from their .module section. The modules configuration parsed from a toml file was completely ignored. After this change, the parsed configuration is treated as a template for the module manifest. Signed-off-by: Adrian Warecki --- src/manifest.c | 10 ++++++++-- src/rimage.c | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/manifest.c b/src/manifest.c index 76754a542..3e8f2fc7e 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -662,6 +662,10 @@ static int man_create_modules(struct image *image, struct sof_man_fw_desc *desc, for (; i < image->num_modules; i++) { man_module = (void *)desc + SOF_MAN_MODULE_OFFSET(i - offset); + /* Use manifest created using toml files as template */ + assert(i < image->adsp->modules->mod_man_count); + memcpy(man_module, &image->adsp->modules->mod_man[i], sizeof(*man_module)); + module = &image->module[i]; if (i == 0) @@ -693,12 +697,14 @@ static void man_create_modules_in_config(struct image *image, struct sof_man_fw_ if (!modules) return; - /*skip bringup and base module */ - for (i = 2; i < modules->mod_man_count; i++) { + /* skip modules passed as parameters. Their manifests have already been copied by the + * man_create_modules function. */ + for (i = image->num_modules; i < modules->mod_man_count; i++) { man_module = (void *)desc + SOF_MAN_MODULE_OFFSET(i); memcpy(man_module, &modules->mod_man[i], sizeof(*man_module)); } + /* We need to copy the configurations for all modules. */ cfg_start = (void *)desc + SOF_MAN_MODULE_OFFSET(i); memcpy(cfg_start, modules->mod_cfg, modules->mod_cfg_count * sizeof(struct sof_man_mod_config)); diff --git a/src/rimage.c b/src/rimage.c index 556e05890..d181a3da5 100644 --- a/src/rimage.c +++ b/src/rimage.c @@ -206,6 +206,12 @@ int main(int argc, char *argv[]) goto out; } + if (image.num_modules > image.adsp->modules->mod_man_count) { + fprintf(stderr, "error: Each ELF input module requires entry in toml file.\n"); + ret = -EINVAL; + goto out; + } + /* getopt reorders argv[] */ for (i = first_non_opt; i < argc; i++) { /* When there is more than one module, then first one is bootloader.