Skip to content

fix(ORBITH743v2): register ICM40609D under its own hardware type and slot - #11845

Open
sensei-hacker wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix/orbith743v2-icm40609d-hwtype
Open

fix(ORBITH743v2): register ICM40609D under its own hardware type and slot#11845
sensei-hacker wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix/orbith743v2-icm40609d-hwtype

Conversation

@sensei-hacker

Copy link
Copy Markdown
Member

Summary

Fixes ORBITH743v2's second IMU (ICM40609D) being registered under the wrong hardware-type tag, so it could never be detected.

Before (src/main/target/ORBITH743v2/target.c):

BUSDEV_REGISTER_SPI_TAG(busdev_icm40609, DEVHW_ICM42605, ICM40609_SPI_BUS, ICM40609_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM40609_ALIGN);

After:

BUSDEV_REGISTER_SPI_TAG(busdev_icm40609, DEVHW_ICM40609D, ICM40609_SPI_BUS, ICM40609_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU_ICM40609_ALIGN);

And target.h gains #define USE_IMU_ICM40609D (it was never defined, so the whole accgyro_icm40609d.c driver was compiled out).

Why two changes on the one registration line

  1. Hardware type: the descriptor claimed DEVHW_ICM42605, but the ICM40609D driver's busDeviceInit/busDeviceOpen look up DEVHW_ICM40609D, and the ICM42605 driver's WHO_AM_I check (0x42/0x47) rejects the ICM40609D's 0x3B — so the chip could never match either driver.
  2. Tag: the descriptor used tag 0, colliding with the first gyro (busdev_icm42688_1, also tag 0). In this target's dual-gyro setup gyro_to_use maps directly to the descriptor tag (0 = first, 1 = second) — every other true dual-gyro target (FRSKYPILOT, FLYWOOF7DUAL, SKYSTARSH743HD, IFLIGHTF7_TWING) tags the second IMU as 1. With tag 0 on both, gyro_to_use=1 finds no descriptor at all (GYRO_NONE).

Verification

  • ORBITH743v2 builds clean (CI recipe, -DWARNINGS_AS_ERRORS=ON): FLASH1 751267 B / 1792 KB (40.94%).
  • Confirmed the driver is actually compiled in: nm on accgyro_icm40609d.c.obj shows icm40609dAccDetect / icm40609dGyroDetect defined (both are inside #if defined(USE_IMU_ICM40609D)).
  • No hardware available for physical verification; detection path traced: gyro_to_use=1 → ICM42605 driver finds no tag-1 DEVHW_ICM42605 descriptor → falls through → ICM40609D driver matches tag-1 DEVHW_ICM40609D descriptor → WHO_AM_I 0x3B check → detected.

Note on scope (vs original assignment)

The assignment said land on release/9.1 first, then forward-merge to maintenance-10.x. That is not implementable: the ICM40609D driver (accgyro_icm40609d.c), DEVHW_ICM40609D, ICM40609D_WHO_AM_I_CONST, and USE_IMU_ICM40609D all exist only on maintenance-10.x (commit 21bf312d2b, "Add ICM40609D IMU driver") — none are present on release/9.1, so this fix cannot compile there. Per user direction this PR targets maintenance-10.x only.

…slot

The second IMU was registered with DEVHW_ICM42605 and descriptor tag 0,
so icm40609dGyroDetect/AccDetect could never match it: the ICM42605
driver rejects the ICM40609D WHO_AM_I (0x3B vs 0x42/0x47), and tag 0
collides with the first gyro while gyro_to_use=1 requests tag 1. Register
it as DEVHW_ICM40609D with tag 1 and enable USE_IMU_ICM40609D so the
dual-gyro selection can actually find the second IMU.
@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

Copy link
Copy Markdown

PR Summary by Qodo

Fix ORBITH743v2 secondary ICM40609D detection

🐞 Bug fix ⚙️ Configuration changes 🕐 Less than 10 minutes

Grey Divider

AI Description

• Registers the secondary ICM40609D with its correct hardware type and dual-gyro slot.
• Enables the ICM40609D driver so firmware can detect the configured sensor.
Diagram

sequenceDiagram
    participant Config as Target Config
    participant Registry as Bus Registry
    participant Selection as Gyro Selection
    participant Driver as ICM40609D Driver
    participant IMU as Second IMU
    Config->>Driver: Compile driver
    Config->>Registry: Register type and slot 1
    Selection->>Driver: Detect slot 1
    Driver->>Registry: Match ICM40609D descriptor
    Registry-->>Driver: Return SPI device
    Driver->>IMU: Verify WHO_AM_I 0x3B
    IMU-->>Driver: Detection succeeds
Loading
High-Level Assessment

The PR uses the correct minimal approach: align the target descriptor with the dedicated driver's hardware-type lookup, assign the established second-gyro tag, and enable that driver for the target. Reusing the ICM42605 identity or changing driver lookup behavior would misrepresent the hardware and broaden the fix unnecessarily.

Files changed (2) +2 / -1

Bug fix (1) +1 / -1
target.cRegister ICM40609D under the correct type and secondary slot +1/-1

Register ICM40609D under the correct type and secondary slot

• Changes the second IMU descriptor from DEVHW_ICM42605 to DEVHW_ICM40609D and assigns tag 1. This lets dual-gyro selection find the device through the dedicated ICM40609D detection path.

src/main/target/ORBITH743v2/target.c

Other (1) +1 / -0
target.hEnable the ICM40609D driver for ORBITH743v2 +1/-0

Enable the ICM40609D driver for ORBITH743v2

• Defines USE_IMU_ICM40609D so the target build includes the sensor's accelerometer and gyroscope detection implementation.

src/main/target/ORBITH743v2/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

Test firmware build ready — commit 7f48c0a

Download firmware for PR #11845

1 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.

@github-actions

Copy link
Copy Markdown

RAM / Flash usage vs. base commit 2e8857e — commit 7f48c0a

None of the representative targets (MATEKF405, MATEKF722, MATEKF765, MATEKH743) were built by this PR — no size comparison to show.

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

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