Skip to content

DAKEFPV - fix target, fix inicialization of second IMU - #12243

Open
error414 wants to merge 1 commit into
iNavFlight:next-10.1from
error414:error414/fix/dakefpv-imu
Open

error414 wants to merge 1 commit into
iNavFlight:next-10.1from
error414:error414/fix/dakefpv-imu

Conversation

@error414

@error414 error414 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR is for issue #12240

There was two issues

  1. wrong SPI for second IMU in DAKEFPV target
  2. wrong incialization of second imu, if second imu was not found then SPI kept in slowest speed

I was able to reproduce issue on OMNIBUSF7NXT (it uses two IMU MPU6000 and MPU6500)

@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Fix DAKEFPVH743 secondary IMU bus and dual-gyro initialization order

🐞 Bug fix ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Map the DAKEFPVH743 secondary IMU to SPI4 so its hardware descriptors use the correct bus.
• Probe and start the optional secondary gyro before the primary to preserve the primary's SPI
 clock.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 3 capabilities

  • 3 affected capabilities span independent functional scopes: DAKEFPVH743 inertial sensing and gyro diagnostics, inertial sensing and gyro diagnostics.
  • The changed initialization order directly controls the primary gyro that supplies the end-to-end flight-sensing path.
  • The secondary is an implementation hop in the same dual-IMU integration; it is not an independent flight capability.
  • This is the target-specific flight-sensing behavior affected by removal of the dual-gyro compile-time contract.
  • It is distinct from optional secondary logging because it changes which physical sensor supplies the flight-control input.
  • This is a separate user-visible diagnostic operation from selecting the flight gyro, but remains within the same target-specific inertial-sensing and logging integration.
  • Its downstream contract is the conditional gyroRaw2 Blackbox field.
Behavioral complexity 🟡 Medium 🧩 Coordinated invariants, Compatibility cases

  • Before: the primary was detected and started before the optional secondary path.
  • After: the secondary is detected and started first, then the primary is detected, while the code must preserve bus configuration, per-driver detected-variant state, primary availability, and the invariant that the secondary is never used for flight control.
  • New correctness condition: secondary probing and startup must leave shared bus and driver state valid for primary detection, and primary failure must invalidate the secondary path.
  • This is a newly ordered interaction, not merely reuse of existing detection helpers.
Potential damage 🟡 Medium 🩹 Temporary loss

  • A primary initialization failure removes the flight gyro and therefore the normal attitude/control sensing capability.
  • Reverting the firmware or correcting the target/driver initialization can restore operation; the source shows no persistent state corruption or external side effect.
  • Recoverable by firmware rollback or a corrected initialization sequence, assuming the IMU and bus hardware are otherwise functional.
  • A power cycle alone is not established as sufficient.
Assessed commit 343f030
Diagram

graph TD
    Bus["SPI4 mapping"] --> Probe2["Secondary probe"]
    Init["gyroInit"] --> Probe2 --> Start2["Secondary start"] --> Probe1["Primary probe"] --> Start1["Primary start"]
    Init -. "secondary disabled" .-> Probe1
    Probe2 -. "not found" .-> Probe1
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Restore SPI clock after secondary probing
  • ➕ Could retain the previous primary-first initialization order.
  • ➖ Requires coordinated bus or driver changes and must still preserve each driver's detected variant until initialization.

Recommendation: Keep the proposed secondary-first sequence: it lets each device initialize immediately after detection and leaves the primary's SPI clock set after the final probe, without changing shared driver behavior.

Files changed (2) +32 / -28

Bug fix (1) +31 / -23
gyro.cInitialize optional secondary gyro before the primary +31/-23

Initialize optional secondary gyro before the primary

• Moves secondary tag probing and initialization ahead of primary detection so later probes cannot leave a shared SPI bus at a slow clock after the primary starts. Clears secondaryInitialized if primary detection fails, since the secondary is not used without a primary.

src/main/sensors/gyro.c

Other (1) +1 / -5
target.hCorrect the secondary IMU SPI bus +1/-5

Correct the secondary IMU SPI bus

• Changes the secondary IMU bus from SPI1 to SPI4, which is used by the target's secondary device descriptors. Removes a duplicate USE_DUAL_GYRO definition while retaining the earlier definition.

src/main/target/DAKEFPVH743/target.h

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions

Copy link
Copy Markdown

RAM / Flash usage vs. base commit 01a7aa3 — commit 343f030

Using the nearest available size baseline: this build contains base commit 6cbfc64, which has no stored baseline yet, so the deltas also include what was merged to the base since 01a7aa3.

Target Flash Δ RAM Δ
MATEKF405 ⚠️ +3856 B (+0.53%) CCM: -4 B (-0.01%)
RAM: +1660 B (+1.59%)
MATEKF722 +1224 B (+0.25%) ITCM_RAM: -928 B (-7.40%)
RAM: +56 B (+0.06%)
TCM: ±0 B (±0.00%)
MATEKF765 +1368 B (+0.18%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: +64 B (+0.05%)
MATEKH743 ⚠️ +7188 B (+0.90%) D2_RAM: +256 B (+7.84%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: -888 B (-5.41%)
RAM: +1940 B (+1.36%)

See RAM/flash optimization guide for techniques to reduce usage.

@github-actions

Copy link
Copy Markdown

Test firmware build ready — commit 343f030

Download firmware for PR #12243

251 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

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