Skip to content

Commit 7d0a655

Browse files
committed
rimage: Add support to ignore detached sections
There are some non-critical data and code sections that are kept in DRAM to be accessed and executed from there without being copyind to SRAM. Such sections are marked as detached and linked into a separate "cold.mod" module. SOF marks sections between: SOF_MODULE_DRAM_LINK_START (0x00000000) to SOF_MODULE_DRAM_LINK_END (0x080000000) but this overalps with ITCM memory on M7 core of i.MX8MP. Add an option to ignore marking section as detached. Ideally in the future the dram start/end should be configured per platform. By default the behavior is unmodified, to enable this option one would need to pass `-d` to rimage. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
1 parent 87d2e63 commit 7d0a655

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

tools/rimage/src/include/rimage/module.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ void module_close(struct module *module);
127127
* @param module module structure
128128
* @param mem_cfg memory configration structure
129129
* @param verbose verbose logging selection
130+
* @param ignore_detached do not mark detached sections
130131
* @return error code
131132
*/
132133
void module_parse_sections(struct module *module, const struct memory_config *mem_cfg,
133-
bool verbose);
134+
bool verbose, bool ignore_detached);
134135

135136
/**
136137
* Read module section to memory buffer

tools/rimage/src/include/rimage/rimage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ struct image {
6565

6666
/* Output image is a loadable module */
6767
bool loadable_module;
68+
69+
/* Do not mark detached sections */
70+
bool ignore_detached;
6871
};
6972

7073
struct memory_zone {

tools/rimage/src/module.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ static enum module_section_type get_section_type(const struct elf_section_header
310310
}
311311
}
312312

313-
void module_parse_sections(struct module *module, const struct memory_config *mem_cfg, bool verbose)
313+
void module_parse_sections(struct module *module, const struct memory_config *mem_cfg, bool verbose,
314+
bool ignore_detached)
314315
{
315316
const uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR);
316317
uint16_t i;
@@ -344,7 +345,7 @@ void module_parse_sections(struct module *module, const struct memory_config *me
344345
out_section->size = sect->data.size;
345346
out_section->type = get_section_type(sect);
346347
out_section->rom = section_is_rom(mem_cfg, sect);
347-
out_section->detached = section_is_detached(mem_cfg, sect);
348+
out_section->detached = !ignore_detached && section_is_detached(mem_cfg, sect);
348349
out_section->address = sect->data.vaddr;
349350
out_section->load_address = find_physical_address(&module->elf, sect->data.vaddr);
350351

tools/rimage/src/rimage.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ static void usage(char *name)
3434
fprintf(stdout, "\t -y verify signed file\n");
3535
fprintf(stdout, "\t -q resign binary\n");
3636
fprintf(stdout, "\t -p set PV bit\n");
37+
fprintf(stdout, "\t -d ignore detached sections\n");
3738
}
3839

3940
int main(int argc, char *argv[])
@@ -50,7 +51,7 @@ int main(int argc, char *argv[])
5051

5152
image.imr_type = MAN_DEFAULT_IMR_TYPE;
5253

53-
while ((opt = getopt(argc, argv, "ho:va:s:k:ri:f:b:ec:y:q:pl")) != -1) {
54+
while ((opt = getopt(argc, argv, "ho:va:s:k:ri:f:b:ec:y:q:pld")) != -1) {
5455
switch (opt) {
5556
case 'o':
5657
image.out_file = optarg;
@@ -101,6 +102,10 @@ int main(int argc, char *argv[])
101102
case 'l':
102103
image.loadable_module = true;
103104
break;
105+
case 'd':
106+
/* ignore detached sections */
107+
image.ignore_detached = true;
108+
break;
104109
default:
105110
/* getopt's default error message is good enough */
106111
return 1;
@@ -225,7 +230,8 @@ int main(int argc, char *argv[])
225230
if (ret < 0)
226231
goto out;
227232

228-
module_parse_sections(&image.module[i].file, &image.adsp->mem, image.verbose);
233+
module_parse_sections(&image.module[i].file, &image.adsp->mem, image.verbose,
234+
image.ignore_detached);
229235

230236
/* When there is more than one module, then first one is bootloader.
231237
* Does not apply to building a image of a loadable module. */

0 commit comments

Comments
 (0)