Skip to content

Conversation

sasdf
Copy link
Contributor

@sasdf sasdf commented Oct 14, 2025

This PR enhances our coverage framework by integrating the ROM_EXT immutable section. It enables the collection of coverage data for this section from end-to-end tests run in rom_ext exec_env.

The changes include supporting runfiles propagation and adding essential coverage API calls to the immutable section's code.

The native cc_import rule lacks runfile propagation. Therefore, we've reimplemented _cc_import using objcopy and ar to address this.

Tested with:

$ ./bazelisk.sh coverage --config=ot_coverage \
  //sw/device/tests:uart_smoketest_fpga_cw340_rom_ext

$ genhtml -o /tmp/$USER/coverage --ignore-errors inconsistent,unsupported \
  bazel-out/_coverage/_coverage_report.dat \
| grep imm_section -A 1

Processing file sw/device/silicon_creator/rom_ext/imm_section/imm_section.c
  lines=26 hit=26 functions=2 hit=2
--
Processing file sw/device/silicon_creator/rom_ext/imm_section/imm_section_epmp.c
  lines=32 hit=28 functions=2 hit=2

@sasdf sasdf marked this pull request as ready for review October 14, 2025 11:15
@sasdf sasdf requested a review from a team as a code owner October 14, 2025 11:15
sasdf added 6 commits October 16, 2025 12:02
Propagating runfiles from `opentitan_binary` dependencies
makes the immutable section ELF file accessible for coverage
report generation.

Change-Id: I72acb0b43e3ac53dee260a0517ae8a38a6dcab20
Signed-off-by: Yi-Hsuan Deng <[email protected]>
The exec_env implementation of `update_file_attr` should propagate
the runfiles if `attr` contains it.

This ensures that runfiles from attributes like `rom_ext` are
correctly propagated after the change.

Change-Id: I4d5fc442758bce3aee640872319f9397f7338076
Signed-off-by: Yi-Hsuan Deng <[email protected]>
This change enables the imm_section rules to propagate the generated elf
in `runfiles`.

Since the native `cc_import` does not support runfiles propagation,
a custom `_cc_import` implementation was added to ensure proper propagation.

Change-Id: Ia466cd4eabbf78fb9b9cc6fae0038cc40a40718c
Signed-off-by: Yi-Hsuan Deng <[email protected]>
This change moves `imm_section_start.S` to a separate `cc_library` target,
`imm_section_start`, and adds it as a dependency to `main_lib`. This change
is necessary to allow `imm_section_start.S` to have coverage
instrumentation.

Change-Id: I57fc7d3899719032920d32181962ce6a3ba78421
Signed-off-by: Yi-Hsuan Deng <[email protected]>
This change adds the coverage sections to the `imm_section` linker script,
which allows the `imm_section` to support code coverage.

Change-Id: I2db35a4ee55390da41c91cadf7a9896166295649
Signed-off-by: Yi-Hsuan Deng <[email protected]>
This change adds the `coverage_report()` and `coverage_invalidate()` calls
in `imm_section_main` func to report and invalidate coverage data before
returning to ROM / Mutable ROM_EXT. It also initializes the coverage
framework in `_imm_section_start_boot` for ASM.

Change-Id: I4fbe76bba0748ca212ccdfb87f398370df3e884e
Signed-off-by: Yi-Hsuan Deng <[email protected]>
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