Skip to content

fix: activate SPI DMA for STM32H7 targets - #1367

Draft
nerdCopter wants to merge 1 commit into
emuflight:masterfrom
nerdCopter:fix/h7-spi-dma-activation
Draft

fix: activate SPI DMA for STM32H7 targets#1367
nerdCopter wants to merge 1 commit into
emuflight:masterfrom
nerdCopter:fix/h7-spi-dma-activation

Conversation

@nerdCopter

@nerdCopter nerdCopter commented Aug 7, 2026

Copy link
Copy Markdown
Member

AI Generated [pull-request]

Summary

Closes #1353.

spiInitBusDMA() (src/main/drivers/bus_spi.c) already guards
#if (defined(STM32F4) || defined(STM32F7) || defined(STM32H7)) && defined(USE_SPI) — H7
support exists in the function itself. PR #1348 only defined USE_SPI_DMA_ENABLE_LATE for
STM32F4/STM32F7 in common_fc_pre.h; H7 targets never reached the fc_init.c call
site (gated #if defined(USE_SPI) && defined(USE_SPI_DMA_ENABLE_LATE)), so spiInitBusDMA()
was dead code on every H7 target.

This PR adds the same define to the STM32H7 block, mirroring the existing F4/F7 pattern.
One line, one file.

No USE_GYRO_IMUF9001 target is STM32H7-based (HELIOSPRING/STRIXF10/MODE2FLUX are all
F4/F7), so this doesn't interact with the SPI1-exclusion guard PR #1359 added.

Tier classification

Tier 2 — behavioral change (DMA path activation), per this project's production-
readiness gates.

  • Gyro verified on: pending — no STM32H7 hardware access this session
  • Motor test: pending

Verification done

  • make clean && CCACHE_DISABLE=1 make test: 42/42 unit test binaries pass, 0 fail.
  • CCACHE_DISABLE=1 make STELLARH7DEV MATEKH743 KAKUTEH7: clean compile, zero warnings.
  • Link-map cross-reference on STELLARH7DEV: spiInitBusDMA is placed at a real address
    and cross-referenced from the LTRANS object — genuinely linked in under
    -Wl,-gc-sections, not just present-but-eliminated.
  • CodeRabbit GitHub review: raised a finding requesting H7 hardware validation before
    default-on, then withdrew it after re-tracing bus_spi.c/bus_spi_ll.c/
    dma_stm32h7xx.c/the H7 linker scripts — confirmed H7's DTCM/cache DMA constraints are
    already handled generically, same fallback-to-polling model as the accepted F4/F7
    precedent. Full exchange: PR review thread starting at
    fix: activate SPI DMA for STM32H7 targets #1367 (comment).

Not yet done — blocking merge

Real-hardware verification on STM32H7 (STELLARH7DEV): gyro functional test, motor arming
test, and 3x flash+reboot power cycles. No H7 hardware access this session. This PR stays
DRAFT until that verification is done.

Test plan

  • make test — 42/42 pass
  • Compile gate — STELLARH7DEV, MATEKH743, KAKUTEH7, zero warnings
  • Link-map confirms spiInitBusDMA genuinely activated on STELLARH7DEV
  • CodeRabbit GitHub review — code-level finding raised then withdrawn, no open findings
  • Gyro functional test on STELLARH7DEV
  • Motor arming test on STELLARH7DEV
  • Flash + reboot x3 on STELLARH7DEV

spiInitBusDMA() (bus_spi.c) already guards STM32H7 alongside F4/F7, but
USE_SPI_DMA_ENABLE_LATE was only defined for STM32F4/STM32F7 in
common_fc_pre.h (PR emuflight#1348), so H7 targets never reached the fc_init.c
call site. Adds the same define for the STM32H7 block, matching the
existing F4/F7 pattern.

No STM32H7 USE_GYRO_IMUF9001 target exists, so this doesn't interact
with the SPI1-exclusion guard added by PR emuflight#1359.

Closes emuflight#1353
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The STM32H7 target configuration now enables USE_SPI_DMA_ENABLE_LATE alongside the existing H7 feature definitions.

Changes

STM32H7 SPI DMA configuration

Layer / File(s) Summary
Enable late SPI DMA feature
src/main/target/common_fc_pre.h
STM32H7 builds now define USE_SPI_DMA_ENABLE_LATE.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested labels: help wanted

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code change satisfies issue #1353 by enabling USE_SPI_DMA_ENABLE_LATE for STM32H7 targets.
Out of Scope Changes check ✅ Passed The pull request changes one relevant configuration line and contains no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely identifies the main change: enabling SPI DMA for STM32H7 targets.
Description check ✅ Passed The description explains the change, linked issue, verification results, and clearly identifies the remaining hardware tests and draft status.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nerdCopter

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added the help wanted Extra attention is needed label Aug 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/target/common_fc_pre.h`:
- Line 100: Keep USE_SPI_DMA_ENABLE_LATE disabled by default or make it
explicitly opt-in until STELLARH7DEV validation is complete; record successful
gyro, motor, flash, and reboot hardware tests before enabling it for all USE_SPI
builds.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2c4f02e-10ed-4d45-99df-a5b2360d6b2a

📥 Commits

Reviewing files that changed from the base of the PR and between 035fff1 and 461bee6.

📒 Files selected for processing (1)
  • src/main/target/common_fc_pre.h
📜 Review details
⏰ Context from checks skipped due to timeout. (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build (targets-group-8)
  • GitHub Check: build (targets-group-10)
  • GitHub Check: build (targets-group-7)
  • GitHub Check: build (targets-group-4)
  • GitHub Check: build (targets-group-3)
  • GitHub Check: build (targets-group-6)
  • GitHub Check: build (targets-group-5)
  • GitHub Check: build (targets-group-11)
  • GitHub Check: build (targets-group-1)
  • GitHub Check: build (targets-group-9)
  • GitHub Check: build (targets-group-2)

Comment thread src/main/target/common_fc_pre.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPI DMA activation: H7 targets not yet hardware-verified

1 participant