Skip to content

blackbox: declare up to 12 motors in the log header - #12127

Open
MrScothh wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
MrScothh:fix/blackbox-twelve-motors
Open

MrScothh wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
MrScothh:fix/blackbox-twelve-motors

Conversation

@MrScothh

@MrScothh MrScothh commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The log header declares motor[0..7], but the I and P frames write getMotorCount() motors, up to MAX_SUPPORTED_MOTORS (12). With 9 to 12 motors and motor logging on, every frame carries more values than the header describes, and nothing in the log decodes: on SITL with a 12-motor mixer, blackbox_decode read none of 681 frames.

This declares motor[8..11] behind four more conditions, AT_LEAST_MOTORS_9 to 12, with the same predictors and encodings as motors 1 to 7. The condition cache was a uint64_t that the dual-gyro targets already fill to the last bit, so it becomes an array of 32-bit words sized from FLIGHT_LOG_FIELD_CONDITION_LAST, and a static assert ties MAX_SUPPORTED_MOTORS to the 12 motors the header can now declare.

With 8 motors or fewer the header is the same as before. The MSP enum reference (inav_enums.json, inav_enums_ref.md) gets the new condition values; I regenerated only this enum's section, since a full regeneration also rewrites unrelated enums that were already out of date.

Testing

SITL, blackbox to a file, decoded with the current blackbox_decode:

mixer header frames decoded rows
12 motors, maintenance-10.x motor[0..7] 0 (681 failed) 0
12 motors, this PR motor[0..11] 41 I + 606 P 647
8 motors, both the same field lines 684 and 685

Unit tests pass. Built for MATEKF405SE, MATEKF722SE, KAKUTEF7, KAKUTEF7HDV, MATEKH743 and TBS_LUCID_H7_WING: flash -32 to -176 B (testing a bit in a 32-bit word takes less code than in a 64-bit one), RAM +0 to +8 B, ITCM unchanged on KAKUTEF7 and KAKUTEF7HDV.

Not tested on a real craft with more than 8 motors: if you fly one with the blackbox on, I'd like to know whether your logs decode with this.

blackbox-log-viewer reads these logs, but its motor lists stop at 8: it labels motor[7] "motor[8]" next to the real motor[8], shows motors 9 to 12 as raw values instead of percent, and leaves them out of the per-motor current and the activity bar.

Related: #12126, another case where P frames didn't match what decoders read from the header.

The header declared motor[0..7], while the I and P frames write
getMotorCount() values, up to MAX_SUPPORTED_MOTORS (12). With 9 to 12 motors
and motor logging on, every frame carried more values than the header
described, and no frame of the log decoded.

The header now declares motor[8..11] behind four more conditions. The
condition cache was a uint64_t already full on dual-gyro targets, so it
becomes an array of 32-bit words sized for every condition. The MSP enum
reference gets the new values (that enum's section only).
@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

Blackbox: declare up to 12 motors in log headers

🐞 Bug fix 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Declare motor fields through motor[11] so headers match I and P frames on 9–12-motor mixers.
• Expand the condition cache to accommodate the new fields and guard against unsupported motor
 counts.
• Update the MSP enum references to reflect the added conditions and shifted values.
Diagram

graph TD
    M["Mixer motor count"] --> T{"Count and flag?"} --> C["Condition cache"] --> D["Motor field definitions"] --> H["Log header"] --> L["Blackbox decoder"]
    M --> F["I/P frames"] --> L
    C --> F
Loading
High-Level Assessment

Extend the existing conditional field definitions rather than generate motor header fields dynamically: this preserves the established predictors and encodings while fixing the header/frame mismatch. Sizing the cache from the last condition avoids another fixed-width limit.

Files changed (4) +138 / -118

Bug fix (2) +19 / -12
blackbox.cMatch blackbox motor headers to frame payloads +15/-12

Match blackbox motor headers to frame payloads

• Defines conditional header fields for motor[8] through motor[11] using the existing motor predictors and encodings. Replaces the fixed 64-bit condition cache with a size-derived array of 32-bit words and asserts that the supported motor count does not exceed the declared fields.

src/main/blackbox/blackbox.c

blackbox_fielddefs.hAdd conditions for 9–12 active motors +4/-0

Add conditions for 9–12 active motors

• Extends the contiguous motor-count condition enum so the new header fields can be selected by active motor count.

src/main/blackbox/blackbox_fielddefs.h

Documentation (2) +119 / -106
inav_enums.jsonUpdate machine-readable flight-log condition values +61/-53

Update machine-readable flight-log condition values

• Adds conditions for motors 9–12 and shifts subsequent enum values. Also records the conditional dual-gyro enumerator in this enum section.

docs/development/msp/inav_enums.json

inav_enums_ref.mdUpdate the flight-log condition reference table +58/-53

Update the flight-log condition reference table

• Documents the four new motor thresholds and renumbered conditions, including the conditional dual-gyro entry.

docs/development/msp/inav_enums_ref.md

@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 keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

RAM / Flash usage vs. base commit e87050f — commit dbde203

Using the nearest available size baseline — the PR's exact base commit has no stored baseline yet.

Target Flash Δ RAM Δ
MATEKF405 -144 B (-0.02%) CCM: ±0 B (±0.00%)
RAM: +8 B (+0.01%)
MATEKF722 +40 B (+0.01%) ITCM_RAM: ±0 B (±0.00%)
RAM: +8 B (+0.01%)
TCM: ±0 B (±0.00%)
MATEKF765 -56 B (-0.01%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: +8 B (+0.01%)
MATEKH743 -112 B (-0.01%) D2_RAM: ±0 B (±0.00%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)

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

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Test firmware build ready — commit dbde203

Download firmware for PR #12127

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