Skip to content

Commit 6d0c23b

Browse files
lyakhkartben
authored andcommitted
soc: intel_adsp: add support for .cold* sections
Add support for .cold and .coldrodata sections, used to implement a cold module. Assigning code and read-only data to those sections makes them suitable for use in a cold module, stored and executed in slow memory. Signed-off-by: Guennadi Liakhovetski <[email protected]>
1 parent 09cdc1f commit 6d0c23b

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

scripts/west_commands/sign.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import subprocess
1313
import sys
1414

15+
from elftools.elf.elffile import ELFFile
16+
1517
from west import manifest
1618
from west.commands import Verbosity
1719
from west.util import quote_sh_list
@@ -474,6 +476,7 @@ def sign(self, command, build_dir, build_conf, formats):
474476
kernel_name = build_conf.get('CONFIG_KERNEL_BIN_NAME', 'zephyr')
475477

476478
bootloader = None
479+
cold = None
477480
kernel = str(b / 'zephyr' / f'{kernel_name}.elf')
478481
out_bin = str(b / 'zephyr' / f'{kernel_name}.ri')
479482
out_xman = str(b / 'zephyr' / f'{kernel_name}.ri.xman')
@@ -484,6 +487,12 @@ def sign(self, command, build_dir, build_conf, formats):
484487
# zephyr.elf directly.
485488
if os.path.exists(str(b / 'zephyr' / 'boot.mod')):
486489
bootloader = str(b / 'zephyr' / 'boot.mod')
490+
if os.path.exists(str(b / 'zephyr' / 'cold.mod')):
491+
cold = str(b / 'zephyr' / 'cold.mod')
492+
with open(cold, 'rb') as f_cold:
493+
elf = ELFFile(f_cold)
494+
if elf.get_section_by_name('.cold') is None:
495+
cold = None
487496
if os.path.exists(str(b / 'zephyr' / 'main.mod')):
488497
kernel = str(b / 'zephyr' / 'main.mod')
489498

@@ -556,7 +565,10 @@ def sign(self, command, build_dir, build_conf, formats):
556565
if not args.quiet and args.verbose:
557566
sign_base += ['-v'] * args.verbose
558567

568+
# Order is important
559569
components = [ ] if bootloader is None else [ bootloader ]
570+
if cold is not None:
571+
components += [ cold ]
560572
components += [ kernel ]
561573

562574
sign_config_extra_args = command.config_get_words('rimage.extra-args', [])

soc/intel/intel_adsp/ace/ace-link.ld

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ SECTIONS {
171171
*/
172172
.imrdata : ALIGN(4096) {
173173
*(.imrdata .imrdata.*)
174+
} >imr
175+
176+
/* Cold code in IMR memory */
177+
.cold : ALIGN(4096) {
178+
*(.cold .cold.* )
179+
} >imr
180+
181+
/* Cold data. */
182+
.coldrodata : ALIGN(4096) {
183+
*(.coldrodata .coldrodata.*)
174184
_imr_end = .;
175185
} >imr
176186

@@ -553,6 +563,7 @@ SECTIONS {
553563

554564
/* rimage module manifest headers */
555565
.module.boot : { KEEP(*(.module.boot)) } >noload
566+
.module.cold : { KEEP(*(.module.cold)) } >noload
556567
.module.main : { KEEP(*(.module.main)) } >noload
557568

558569
.static_uuid_entries : {

soc/intel/intel_adsp/common/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,22 @@ add_custom_command(
8282
--rename-section .module.boot=.module
8383
${KERNEL_REMAPPED} ${CMAKE_BINARY_DIR}/zephyr/boot.mod 2>${NULL_FILE}
8484

85+
COMMAND ${CMAKE_OBJCOPY}
86+
--only-section .cold
87+
--only-section .coldrodata
88+
--only-section .module.cold
89+
--set-section-flags .module.cold=noload,readonly
90+
--rename-section .module.cold=.module
91+
${KERNEL_REMAPPED} ${CMAKE_BINARY_DIR}/zephyr/cold.mod 2>${NULL_FILE}
92+
8593
# Remove .fw_metadata here...
8694
COMMAND ${CMAKE_OBJCOPY}
8795
--remove-section .imr
8896
--remove-section .imrdata
97+
--remove-section .cold
98+
--remove-section .coldrodata
8999
--remove-section .module.boot
100+
--remove-section .module.cold
90101
--remove-section .fw_metadata
91102
--set-section-flags .module.main=noload,readonly
92103
--set-section-flags .static_uuid_entries=noload,readonly

0 commit comments

Comments
 (0)