Skip to content

Commit 536b2aa

Browse files
committed
west: sign/rimage: use rimage config to find SOF directory
After removal of SOF from manifest, if rimage is in path, the build would fail because the gen-uuid-reg.py cannot be found anymore. To fix this, use the rimage config path to find the SOF directory since the rimage config path is a directory under SOF. This would allow rimage to again sign images to run on hardware. Signed-off-by: Daniel Leung <[email protected]>
1 parent d14a547 commit 536b2aa

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

scripts/west_commands/sign.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from elftools.elf.elffile import ELFFile
1616

17-
from west import manifest
1817
from west.commands import Verbosity
1918
from west.util import quote_sh_list
2019

@@ -438,7 +437,11 @@ def rimage_config_dir(self):
438437
def generate_uuid_registry(self):
439438
'Runs the uuid-registry.h generator script'
440439

441-
generate_cmd = [sys.executable, str(self.sof_src_dir / 'scripts' / 'gen-uuid-reg.py'),
440+
uuid_script_path = self.sof_src_dir / 'scripts' / 'gen-uuid-reg.py'
441+
if not uuid_script_path.exists():
442+
self.command.die(f"{uuid_script_path} does not exists.")
443+
444+
generate_cmd = [sys.executable, str(uuid_script_path),
442445
str(self.sof_src_dir / 'uuid-registry.txt'),
443446
str(pathlib.Path('zephyr') / 'include' / 'generated' / 'uuid-registry.h')
444447
]
@@ -554,13 +557,20 @@ def sign(self, command, build_dir, build_conf, formats):
554557
if not args.quiet:
555558
command.inf('Signing with tool {}'.format(tool_path))
556559

560+
sof_src_dir = None
557561
try:
558562
sof_proj = command.manifest.get_projects(['sof'], allow_paths=False)
559563
sof_src_dir = pathlib.Path(sof_proj[0].abspath)
560564
except ValueError: # sof is the manifest
561-
sof_src_dir = pathlib.Path(manifest.manifest_path()).parent
565+
conf_dir = self.cmake_cache.get('RIMAGE_CONFIG_PATH')
566+
if conf_dir:
567+
# Config path is <sof top>/tools/rimage/config/
568+
# So need to go up 3 levels to get SOF directory.
569+
sof_src_dir = pathlib.Path(conf_dir).parent.parent.parent
562570

563571
self.sof_src_dir = sof_src_dir
572+
if not self.sof_src_dir:
573+
command.die("Cannot find SOF directory.")
564574

565575

566576
command.inf('Signing for SOC target ' + target)

0 commit comments

Comments
 (0)