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

[sw] Port rstmgr_cpu_info_test to devicetables #26270

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

AlexJones0
Copy link
Contributor

@AlexJones0 AlexJones0 commented Feb 12, 2025

This PR is marked as a draft because it introduces temporary changes to opentitanlib to better support multitop, to get around some errors that occurred when compiling a sim_dv test for Darjeeling. This breaks other things in CI at the moment also.

Specifically, when changing the rstmgr DIF by introducing conditional compilation to make the necessary register bitfield changes to allow this test to function in Darjeeling environments, I began to get errors with opentitanlib when running the following command:

bazel build --build_tests_only //sw/device/tests:rstmgr_cpu_info_test_sim_dv --//hw/top=darjeeling

This is because opentitanlib is being compiled, and bindgen is not yet multitop and cannot deal with the missing bindings for these rstmgr symbols. The current PR adds support for this, so to reproduce this issue you need to drop all commits preceding e7d0770. It is not yet clear to me why opentitantool is being built for this command.

After this PR, rstmgr_cpu_info_test will pass on Earlgrey (on fpga_cw310_rom_with_fake_keys) and will successfully compile on Darjeeling.

The docs for this function use non-existent top `english_breakfast` as
an example (`englishbreakfast` is the actual name). They also give an
example of using an array as a dictionary key, but arrays are
non-hashable and so a tuple must be used instead to make a collection
as a key.

Signed-off-by: Alex Jones <[email protected]>
Starts the work for multitop bindgen support by adding the list of
Darjeeling dependencies, and selecting the exist of dependencies to use
for a given top based on `opentitan_select_top`. This can then be used
to replace the existing `_TOPLEVEL` hack that was used by
`prepare_sw.py` to reduce the number of dependencies used (and add
and extra clang flag to the dif).

Signed-off-by: Alex Jones <[email protected]>
Allows the bazel definitions of the rust bindgen libraries to differe
depending on top-level, such that the types exposed and used in bindgen
will not be generated from the `top_earlgrey.h` file but instead from
the files relevant to whatever top level is being used.

Signed-off-by: Alex Jones <[email protected]>
Replace existing englishbreakfast conditional with a rust configuration
feature per top, which can be used in rust code throughout
opentitanlib.

Also replaces the included autogenerated C header file with the
top-specific equivalent, rather than always using earlgrey's.

Note: opentitanlib still looks to be very top-dependent (e.g. the list
of included difs, to start). This just does some initial work.

Signed-off-by: Alex Jones <[email protected]>
This should be squashed with the previous commit that changes the C
difs, but is kept separate to allow easier testing of problems with
opentitanlib building when building a Darjeeling sim_dv test.

Signed-off-by: Alex Jones <[email protected]>
Adds conditional compilation for Darjeeling to match the changed
register definitions, including a change in the number of wakeup reasons
for the rstmgr.

Ideally this can be better modularised through some devicetable
extension API in the future for these blocks, but for now we introduce
`ifdef`s to the DIFs to enable this functionality.

Signed-off-by: Alex Jones <[email protected]>
@AlexJones0
Copy link
Contributor Author

AlexJones0 commented Feb 12, 2025

Quite confused. When I keep only the last 3 commits, I get this output.

 > bazel query "allpaths(//sw/device/tests:rstmgr_cpu_info_test_sim_dv, //sw/host/opentitanlib:opentitanlib)" --//hw/top=darjeeling
INFO: Empty results
 > bazel query "allpaths(//sw/device/tests:rstmgr_cpu_info_test, //sw/host/opentitanlib:opentitanlib)" --//hw/top=darjeeling
//hw/top_earlgrey:silicon_owner_sival_rom_ext
//signing:test_keys
//signing:token
//signing/tokens:local
//sw/device/tests:rstmgr_cpu_info_test
//sw/device/tests:rstmgr_cpu_info_test_silicon_owner_sival_rom_ext
//sw/host/opentitanlib:opentitanlib
//sw/host/opentitantool:opentitantool
 > bazel build //sw/device/tests:rstmgr_cpu_info_test --//hw/top=darjeeling
INFO: Invocation ID: b092b69c-bdb0-4306-9744-4939062944b3
INFO: Analyzed 7 targets (0 packages loaded, 2 targets configured).
ERROR: /home/alexj/opentitan/sw/host/opentitanlib/BUILD:57:13: Compiling Rust rlib opentitanlib (191 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from target //sw/host/opentitanlib:opentitanlib) bazel-out/k8-opt-exec-ST-fdd1730c120c/bin/external/rules_rust+/util/process_wrapper/process_wrapper --arg-file ... (remaining 293 arguments skipped)

not sure if I'm missing something obvious here / not understanding how Bazel works.

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.

1 participant