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

Fix: Missing RISC-V debug guard #1684

Merged
merged 3 commits into from
Nov 17, 2023
Merged

Fix: Missing RISC-V debug guard #1684

merged 3 commits into from
Nov 17, 2023

Conversation

dragonmux
Copy link
Member

Detailed description

This PR addresses an oversight of #1683 resulting in a build error when ENABLE_DEBUG is not true.

Your checklist for this pull request

  • I've read the Code of Conduct
  • I've read the guidelines for contributing to this repository
  • It builds for hardware native (make PROBE_HOST=native)
  • It builds as BMDA (make PROBE_HOST=hosted)
  • I've tested it to the best of my ability
  • My commit messages provide a useful short description of what the commits do

Closing issues

@dragonmux dragonmux requested a review from esden November 15, 2023 16:20
@dragonmux dragonmux added the Bug Confirmed bug label Nov 15, 2023
@dragonmux dragonmux added this to the v2.0 release milestone Nov 15, 2023
@ALTracer
Copy link
Contributor

Explanation:

  • Hosted and release firmware builds work (and are checked by CI anyways).
  • I checked with a script that all ENABLE_DEBUG=1 devlog firmware variants build as of main v1.10.0-226-g529c4a46 (where flash size allows).
  • Requesting a release firmware with riscv target driver feature via ENABLE_RISCV=1 throws a single warning on
target/riscv32.c: In function 'riscv32_mem_write':
target/riscv32.c:580:30: error: unused variable 'data' [-Werror=unused-variable]
  580 |         const uint8_t *const data = (const uint8_t *)src;
      |                              ^~~~

which this PR fixes by gating the code block with mentioned variable and DEBUG_PROTO on #ifdef ENABLE_DEBUG.

  • Requesting a devlog firmware with riscv target driver feature via ENABLE_DEBUG=1 ENABLE_RISCV=1 throws both warnings:
target/riscv32.c: In function 'riscv32_mem_read':
target/riscv32.c:565:30: error: unused variable 'data' [-Werror=unused-variable]
  565 |         const uint8_t *const data = (const uint8_t *)dest;
      |                              ^~~~
target/riscv32.c: In function 'riscv32_mem_write':
target/riscv32.c:580:30: error: unused variable 'data' [-Werror=unused-variable]
  580 |         const uint8_t *const data = (const uint8_t *)src;
      |                              ^~~~

because DEBUG_PROTO is a no-op on adapters. This no longer allows emitting up to DEBUG_INFO verbosity messages from adapters for diagnosing issues specific to BMF and not BMDA.

Putting a #if PC_HOSTED == 1 guard in these two makes the builds succeed.

Note that all prior use of DEBUG_PROTO was contained in src/platforms/hosted/platform.c and not exposed to BMF/adapters. ADIv5 read/write proto logs AFAICS are handled purely in hosted -- this looks very much like adiv5_mem_read(), and I wonder if target_mem_read() should wrap this instead. There are inline wrappers in adiv5.h which omit the DEBUG_PROTO logging for BMF.

@dragonmux
Copy link
Member Author

Yes, guarding on PC_HOSTED would make things build for in-tree platforms, but is not really the right fix.

What we're going to do now we understand the nature of those second two build failures is to create new macros that define if their respective DEBUG_* macro is defined to be a no-op or not, and guard the assignments using those. (It was not made clear on Discord that you meant you'd done a firmware build with those two enables, so we didn't twig that the guard this provides is insufficient due to how DEBUG_PROTO() is defined for the firmware.)

@dragonmux
Copy link
Member Author

That case should now be handled with the new DEBUG_*_IS_NOOP macros and further guarding the conversion/assignment lines

Copy link
Member

@esden esden left a comment

Choose a reason for hiding this comment

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

LGTM

@esden esden merged commit 98f11d4 into main Nov 17, 2023
6 checks passed
@dragonmux dragonmux deleted the fix/missing-riscv-debug-guard branch November 17, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants