From 01dd989f3e42b595d3ce1fd607945d4df27e58fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lefort?= Date: Tue, 2 Sep 2025 16:42:05 +0200 Subject: [PATCH 1/2] [ot] scripts/opentitan: cfggen.py: fix error reporting for otp_ctrl_part_pkg.sv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tool would display "No such file 'None'" when none of the default location match. Also includes some changes to stay under 80 columns and avoid duplicating the OTP file name. Signed-off-by: Loïc Lefort --- scripts/opentitan/cfggen.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/opentitan/cfggen.py b/scripts/opentitan/cfggen.py index bb5a27b11dfbd..5970712f8d39f 100755 --- a/scripts/opentitan/cfggen.py +++ b/scripts/opentitan/cfggen.py @@ -553,6 +553,8 @@ def main(): ot_dir = abspath(ot_dir) log.info("OT directory: '%s'", ot_dir) log.info("Variant: '%s'", topvar) + top_dir = joinpath(ot_dir, 'hw', top) + if not args.lifecycle: lcpath = joinpath(ot_dir, 'hw/ip/lc_ctrl/rtl/lc_ctrl_state_pkg.sv') else: @@ -560,22 +562,22 @@ def main(): if not isfile(lcpath): argparser.error(f"No such file '{lcpath}'") - if not args.otpconst: + ocfilename = 'otp_ctrl_part_pkg.sv' + ocpath = args.otpconst + if not ocpath: otp_constant_locations = [ - joinpath( - ot_dir, "hw", top, "ip_autogen/otp_ctrl/rtl/otp_ctrl_part_pkg.sv" - ), - joinpath(ot_dir, 'hw/ip/otp_ctrl/rtl/otp_ctrl_part_pkg.sv'), + joinpath(top_dir, f'ip_autogen/otp_ctrl/rtl/{ocfilename}'), + joinpath(ot_dir, f'hw/ip/otp_ctrl/rtl/{ocfilename}'), ] - ocpath = None for maybe_ocpath in otp_constant_locations: if isfile(maybe_ocpath): ocpath = maybe_ocpath break - else: - ocpath = args.otpconst - if ocpath is None or not isfile(lcpath): + if not ocpath: + argparser.error(f"Unknown location for '{ocfilename}'") + if not isfile(ocpath): argparser.error(f"No such file '{ocpath}'") + log.debug(f"'{ocfilename}' location: '%s'", ocpath) cfg.load_lifecycle(lcpath) cfg.load_otp_constants(ocpath) From 3f41f337a59c584502f885748719de33ff23f0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lefort?= Date: Tue, 2 Sep 2025 16:43:22 +0200 Subject: [PATCH 2/2] [ot] scripts/opentitan: cfggen.py: support multiple LC_CTRL constant locations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Look in multiple locations for 'lc_ctrl_state_pkg.sv' in order to support both the stable 'earlgrey_1.0.0' branch of OpenTitan and the 'master' branch. Signed-off-by: Loïc Lefort --- scripts/opentitan/cfggen.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/opentitan/cfggen.py b/scripts/opentitan/cfggen.py index 5970712f8d39f..a9fe42f9df30c 100755 --- a/scripts/opentitan/cfggen.py +++ b/scripts/opentitan/cfggen.py @@ -555,12 +555,23 @@ def main(): log.info("Variant: '%s'", topvar) top_dir = joinpath(ot_dir, 'hw', top) - if not args.lifecycle: - lcpath = joinpath(ot_dir, 'hw/ip/lc_ctrl/rtl/lc_ctrl_state_pkg.sv') - else: - lcpath = args.lifecycle + lcfilename = 'lc_ctrl_state_pkg.sv' + lcpath = args.lifecycle + if not lcpath: + lc_constant_locations = [ + joinpath(top_dir, f'rtl/autogen/dev/{lcfilename}'), + joinpath(top_dir, f'rtl/autogen/{lcfilename}'), + joinpath(ot_dir, f'hw/ip/lc_ctrl/rtl/{lcfilename}'), + ] + for maybe_lcpath in lc_constant_locations: + if isfile(maybe_lcpath): + lcpath = maybe_lcpath + break + if not lcpath: + argparser.error(f"Unknown location for '{lcfilename}'") if not isfile(lcpath): argparser.error(f"No such file '{lcpath}'") + log.debug(f"'{lcfilename}' location: '%s'", lcpath) ocfilename = 'otp_ctrl_part_pkg.sv' ocpath = args.otpconst