i2c: fix slave clock-stretch gate and master STOP-settle race

The slave_read drain re-armed the receive path unconditionally on every
call, with no concept of whether the consumer had actually taken the
previous frame -- a frame arriving before the client drained the prior
one just overwrote it in the server's one-frame latch. Gate the re-arm
on a per-frame credit the consumer grants by draining, so the controller
clock-stretches a slow client instead of losing data.

write_buffer_mode returned as soon as PKT_DONE was observed, but the
packet state machine (I2CM14[31:28]) was still reading STOP at that
moment -- the controller was still physically driving the stop
condition. The next write's command register landed on a busy
controller and was silently dropped. Add a settle loop that waits for
the state machine to return to idle before returning.

Reading back what DMA wrote requires invalidating the CM4F's
write-through cache first, which touches the SCU directly. Map scu_regs
into every i2c_server consumer of this driver, not just the one that
exercised the path when this was written -- a config that lacked the
mapping would MemoryManagement fault the moment a slave frame actually
arrived.
17 files changed
tree: a8d9e0178d02f7b0f3efb183936168935d9489bc
  1. .github/
  2. docs/
  3. drivers/
  4. hal/
  5. openprot/
  6. platform/
  7. presubmit/
  8. services/
  9. target/
  10. third_party/
  11. tools/
  12. util/
  13. .bazelignore
  14. .bazelrc
  15. .bazelversion
  16. .clang-format
  17. .gitignore
  18. .semgrepignore
  19. BUILD.bazel
  20. CONTRIBUTING.md
  21. LICENSE
  22. MODULE.bazel
  23. MODULE.bazel.lock
  24. pw
  25. README.md
  26. rust-toolchain.toml
  27. workflows.json
README.md

OpenPRoT

Technical Charter

The OpenPRoT Technical Charter can be found at https://github.com/OpenPRoT/.github/blob/main/GOVERNANCE.md

Getting Started

NOTE: We are converting our build system to bazel. We recommend installing bazelisk to automatically manage bazel versions.

Available Tasks

You can run tasks using the Pigweed workflow launcher pw or bazel.

  • ./pw presubmit - Run presubmit checks: formatting, license checks, C/C++ header checks and clippy.
  • ./pw format - Run the code formatters.
  • bazel test //... - Run all tests.
  • bazel build //docs - Build documentation.

Development

The project is structured as a bazel module.

Requirements

  • Bazel. We recommend installing bazelisk to automatically manage bazel versions.

No additional tools are required - all dependencies are managed by bazel.