Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llext: add support for signing additional binaries #66573

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions scripts/west_commands/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def preprocess_toml(self, config_dir, toml_basename, subdir):
compiler_path = self.cmake_cache.get("CMAKE_C_COMPILER")
preproc_cmd = [compiler_path, '-P', '-E', str(config_dir / (toml_basename + '.h'))]
preproc_cmd += ['-I', str(self.sof_src_dir / 'src')]
preproc_cmd += ['-I', str(self.sof_src_dir)]
preproc_cmd += ['-imacros',
str(pathlib.Path('zephyr') / 'include' / 'generated' / 'autoconf.h')]
preproc_cmd += ['-o', str(subdir / toml_basename)]
Expand Down Expand Up @@ -467,7 +468,14 @@ def sign(self, command, build_dir, build_conf, formats):
else:
log.die(msg)

kernel_name = build_conf.get('CONFIG_KERNEL_BIN_NAME', 'zephyr')
sign_config_extra_args = config_get_words(command.config, 'rimage.extra-args', [])

is_llext = '-r' in sign_config_extra_args + args.tool_args

if is_llext:
kernel_name = 'llext'
else:
kernel_name = build_conf.get('CONFIG_KERNEL_BIN_NAME', 'zephyr')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the bootloader code below still apply to this new llext thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb no, that's why it also checks for '-r' there and skips the bootloader for ELF / llext

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed that. Then this would be clearer and better (assuming peeking at -r is a good idea in the first place:

is_llext = '-r' in sign_config_extra_args + args.tool_args

kernel_name = 'llext' if is_llext else ...

...

if is_llext:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW CONFIG_KERNEL_BIN_NAME used to be hardcoded to zephyr.elf in this script. In #59721 such hardcoding was deemed a bad idea removing. Hardcoding something again to llext seems equally bad (but hard to tell for sure without a complete use case).


# TODO: make this a new sign.py --bootloader option.
if target in ('imx8', 'imx8m', 'imx8ulp'):
Expand Down Expand Up @@ -552,10 +560,11 @@ def sign(self, command, build_dir, build_conf, formats):
if not args.quiet and args.verbose:
sign_base += ['-v'] * args.verbose

components = [ ] if bootloader is None else [ bootloader ]
components += [ kernel ]

sign_config_extra_args = config_get_words(command.config, 'rimage.extra-args', [])
components = [ ]
if not is_llext:
if bootloader is not None:
components += [ bootloader ]
components += [ kernel ]

if '-k' not in sign_config_extra_args + args.tool_args:
# rimage requires a key argument even when it does not sign
Expand All @@ -567,7 +576,10 @@ def sign(self, command, build_dir, build_conf, formats):

if '-c' not in sign_config_extra_args + args.tool_args:
conf_dir = self.rimage_config_dir()
toml_basename = target + '.toml'
if is_llext:
toml_basename = 'llext.toml'
else:
toml_basename = target + '.toml'
if ((conf_dir / toml_basename).exists() and
(conf_dir / (toml_basename + '.h')).exists()):
command.die(f"Cannot have both {toml_basename + '.h'} and {toml_basename} in {conf_dir}")
Expand Down
Loading