Skip to content

Conversation

@engdoreis
Copy link
Contributor

This PR is a manual Backport of #28259.

The conflict was caused by commit 4790641, which also modified sim.mk. I have resolved the conflict in an additional commit within this PR, which can be squashed after the review if preferred.

@engdoreis engdoreis requested a review from a team as a code owner January 19, 2026 16:58
@engdoreis engdoreis force-pushed the backport-28259-to-master branch from 4a1ec76 to 128ee8c Compare January 19, 2026 17:28
Copy link
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

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

Just some comments from an initial read through.

@engdoreis engdoreis force-pushed the backport-28259-to-master branch from 128ee8c to 444fe63 Compare January 20, 2026 18:08
@marnovandermaas
Copy link
Contributor

Any idea why CI is complaining about?
ERROR: Skipping '//hw/ip/otp_ctrl/data:img_seed': no such package 'hw/ip/otp_ctrl/data': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.

@engdoreis engdoreis force-pushed the backport-28259-to-master branch 5 times, most recently from 2150a5a to 99e9194 Compare January 21, 2026 18:04
hcallahan-lowrisc and others added 4 commits January 22, 2026 14:25
Replace some heavily-nested Makefile target code with a dedicated python script
that invokes Bazel to build the needed software collateral for a simulation.
This script does not fundamentally change any of logic for building software,
but repackages it in a form that allows proper documentation and modularity.

Signed-off-by: Harry Callahan <[email protected]>
(cherry picked from commit 9989803)
Signed-off-by: Harry Callahan <[email protected]>
(cherry picked from commit 6437f96)
This creates a new run_mode 'sw_test_mode_base', which currently only provides
the following run opts: +sw_build_device and +sw_images

Signed-off-by: Harry Callahan <[email protected]>
(cherry picked from commit 85b1517)
This commit replicate the changes made to the sim.mk file
in the commit 4790641

Signed-off-by: Douglas Reis <[email protected]>
@engdoreis engdoreis force-pushed the backport-28259-to-master branch 2 times, most recently from 2ef8be7 to eea84dd Compare January 22, 2026 14:35
@engdoreis
Copy link
Contributor Author

There were some problems with darjeeling that @hcallahan-lowrisc helped me to investigate and fix.
I should pass CI now.

Copy link
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

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

Ideally, @hcallahan-lowrisc would review this code.

Comment on lines 305 to 313
# If build_seed is provided, feed this value into bazel when building the OTP pre-load images.
# This overrides the default seed value and is needed for reproducibility to match the
# synthesized hardware from the 'build' stage. (sw build happens in the 'run' stage)
if args.build_seed != "None":
bazel_runner.build_opts += [
f"--//hw/ip/otp_ctrl/data:lc_seed={args.build_seed}",
f"--//hw/ip/otp_ctrl/data:otp_seed={args.build_seed}",
]

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you removing the build seed here? The commit message says you're making changes to sim.mk but this is a different file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original PR extracted the shell script inside the sim.mk to a python script build_sw_collateral_for_sim.py. So in order to backport this PR to master, all the changes made to sim.mk after the earlgrey_1.0.0 forked must be replicated in build_sw_collateral_for_sim.py.

@jwnrt
Copy link
Contributor

jwnrt commented Feb 3, 2026

As a backport it looks okay, but I don't know enough about this flow to give a good review

Copy link
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

Thanks for the backport, this is definitely a big improvement over the original Makefile logic. I've primarily focused on reviewing the new Python script, but have briefly looked over other changes. The majority of the comments are about the original PR, not this backport specifically. As this is a backport (and a big improvement), I'm okay for it to go in without most the comments being addressed and we can defer these to an issue / separate PR.

Generally most of the comments should be quick fixes or suggestions, but there are a couple that ideally I would like to be resolved before approving this PR - specifically, the comments about the docs on the sw_type enum and about the de-duplication in the last commit that passes the sw build opt to cquery.

// SPDX-License-Identifier: Apache-2.0
{
sw_build_cmd: "bazel"
sw_build_cmd: [
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: maybe this should be called sw_build.hjson, or even bazel_sw.hjson instead? At the moment it's slightly confusing to just have it named bazel.hjson when its purpose is actually just to build the sw collateral (via Bazel) - "Bazel" should not be synonymous with "SW collateral". I think the naming issue here just becomes more pronounced with the change to a python script that uses Bazel.

Comment on lines +514 to +515
type=_space_sep_str,
default=[],
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit (repeated for --sw-build-opts): the idiomatic way would be to have nargs="*" with no specified type and then just have your shell and argparse handle splitting on whitespace for you, and then give the args like e.g.

./util/py/scripts/build_sw_collateral_for_sim.py --sw-images img_one img_two img_three

etc., but that might require some small changes to the HJSON to support. At the moment this works well for the makefile flow but won't play particularly nice with manual invocations.

Comment on lines +388 to +392
dev = args.sw_build_device

def _f_endswith_dev(f: Path) -> bool:
f_stem = str(f).split(".")[0]
return f_stem.endswith(dev)
Copy link
Contributor

@AlexJones0 AlexJones0 Feb 5, 2026

Choose a reason for hiding this comment

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

It looks like this --sw-build-device argument should be marked as required=True in the argparse parser? Or this code should handle the None case.

The same is true with args.run_dir later on in the copy_files_to_run_dir call, which doesn't handle the None case for its run_dir arg.

Comment on lines +414 to +417
if logger.level <= logging.INFO:
location_query = bazel_runner.query(iq.label, ["--output=location"])
location = location_query[0].split(" ")[0]
logger.info(f"bazel target location: {location}")
Copy link
Contributor

@AlexJones0 AlexJones0 Feb 5, 2026

Choose a reason for hiding this comment

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

I wonder if this script should default to logging.WARNING and take a -v/--verbose option? As right now _main always configures to logging.INFO which means that we are making these additional expensive Bazel queries per image for any SW collateral build we do (despite good logging practice here!) This could add up over lots of SW images.

This is needed on master branch only because of darjeeling, otherwise
cquery would not find darjeeling artefacts.

Signed-off-by: Douglas Reis <[email protected]>
@engdoreis engdoreis force-pushed the backport-28259-to-master branch 2 times, most recently from 6776896 to 800d7f1 Compare February 6, 2026 14:31
@engdoreis engdoreis force-pushed the backport-28259-to-master branch from 800d7f1 to 1ca7e87 Compare February 6, 2026 14:39
Copy link
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

Looks OK to me modulo a couple of quick comments on your fixes 😅

As already mentioned, I'm happy to defer my remaining comments to an issue or future PR in the interest of making the backporting easier. If you haven't already, it would probably be a good idea to check the DV flow with the latest changes before merging.

@engdoreis engdoreis force-pushed the backport-28259-to-master branch from 1ca7e87 to 13ff019 Compare February 9, 2026 10:11
Copy link
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! As before, I am happy for the rest of the comments to be deferred so we can get this backported.

@engdoreis engdoreis added this pull request to the merge queue Feb 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 9, 2026
@engdoreis engdoreis added this pull request to the merge queue Feb 9, 2026
Merged via the queue into lowRISC:master with commit 75229e1 Feb 9, 2026
77 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants