Skip to content

Commit

Permalink
llext: add support for signing additional binaries
Browse files Browse the repository at this point in the history
This allows the use of "west sign" command for signing of additional
binaries with rimage, specifically this is used to sign llext
extensions for SOF.
Example:

west sign -d build-mtl -t rimage -p build-rimage/rimage -- \
-k key.pem -c modules/audio/sof/src/samples/audio/smart_amp_test.toml \
-r build-mtl/zephyr/smart_amp_llext/libsmart_amp_test_out.so

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
  • Loading branch information
lyakh committed Jan 9, 2024
1 parent b83b9be commit 63024ba
Showing 1 changed file with 18 additions and 6 deletions.
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')

# 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

0 comments on commit 63024ba

Please sign in to comment.