Optimize PG struct field ordering to eliminate alignment padding#11401
Optimize PG struct field ordering to eliminate alignment padding#11401sensei-hacker wants to merge 16 commits intoiNavFlight:maintenance-10.xfrom
Conversation
Updated contact method for hardware feature requests.
SDMODEL SDH7 V2 flight controller with MPU6000 on SPI4 (CW270), MAX7456 OSD on SPI2, SD card blackbox on SPI1, BMP280/MS5611 baro and IST8310 mag on I2C1, 8 motor outputs across TIM2/3/5/8, VCP + 6 UARTs (UART7 RX-only for ESC sensor).
…RT2 for onboard Bluetooth MSP Remove the camera control timer output on PE9. Add config.c to wire PINIO1/PINIO2 to USER1/USER2 mode boxes and preset UART2 for MSP at 115200 baud since it is connected to an onboard Bluetooth module.
…h7v2 New target: SDMODELH7V2 (STM32H743)
…ch-6 NEW_HARDWARE_POLICY.md: Use Discord rather than email
Removed HD_3016 resolution type from the enum.
…ero-special-case Remove legacy hdzero special case
Add a workflow_run-triggered job that uploads each PR's firmware as individually named release assets on iNavFlight/pr-test-builds, then posts (or updates) a PR comment with a direct download link. This avoids two limitations of GitHub Actions artifacts: the opaque single-zip bundle, and the requirement for a GitHub login to download. Requires a PR_BUILDS_TOKEN secret with Contents:write access to iNavFlight/pr-test-builds.
- Add issues: write permission (required for github.rest.issues.* endpoints) - Include fork repo name in concurrency key to prevent cross-fork cancellation - Pin release tag to head_sha via --target flag - Add parseInt radix and NaN validation for PR number
…t-builds CI: publish PR test builds to iNavFlight/pr-test-builds
Maintenance 9.x to master
Multi-line shell string in the NOTES variable had unindented continuation
lines (**..., >...) that were less indented than the YAML block scalar
body, causing a parse error on every run.
Replace with printf + --notes-file to avoid multi-line strings in the
YAML block scalar entirely. Also moves ${{ }} expressions into env vars
rather than inline in the shell script.
Reorder fields in four PG structs from largest-to-smallest type to eliminate internal padding holes created by misaligned fields. Each modified PG version is incremented to force EEPROM reset on firmware upgrade (required when struct layout changes). Results on MATEKF722 (F722, flash-constrained target): .pg_resetdata: 1303 → 1275 bytes (-28 bytes) text total: 470511 → 470491 bytes (-20 bytes) Structs optimized: pidProfile_s: 292 → 272 bytes (21 holes → 0), PG version 11→12 blackboxConfig_s: 16 → 12 bytes ( 2 holes → 0), PG version 4→5 statsConfig_s: 20 → 16 bytes ( 2 holes → 0), PG version 2→3 geozone_config_s: 20 → 16 bytes ( 2 holes → 0), PG version 0→1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan Review Summary by QodoOptimize struct alignment, add SDMODELH7V2 target, and improve CI/build distribution
WalkthroughsDescription• Reorder struct fields largest-to-smallest to eliminate alignment padding - pidProfile_s: 292→272 bytes (21 bytes saved) - blackboxConfig_s: 16→12 bytes (2 bytes saved) - statsConfig_s: 20→16 bytes (2 bytes saved) - geozone_config_s: 20→16 bytes (2 bytes saved) • Add SDMODELH7V2 target (STM32H743 flight controller) - MPU6000 IMU on SPI4, MAX7456 OSD on SPI2, SD card on SPI1 - BMP280/MS5611 baro and IST8310 mag on I2C1 - 8 motor outputs, VCP + 6 UARTs with ESC sensor support • Remove legacy HDZero special case and HD_3016 resolution mode • Add CI workflow to publish PR test builds to external repository Diagramflowchart LR
A["Struct Field Reordering"] -->|Eliminates padding| B["Flash savings: 20 bytes"]
C["New SDMODELH7V2 Target"] -->|STM32H743| D["8 motors, 7 UARTs, OSD"]
E["Remove HDZero Legacy Code"] -->|Simplification| F["Cleaner codebase"]
G["PR Test Build Workflow"] -->|Automated distribution| H["iNavFlight/pr-test-builds"]
File Changes1. src/main/flight/pid.h
|
Code Review by Qodo
1. resolutionType_e values renumbered
|
Summary
Reorder fields in four PG structs from largest-to-smallest type to eliminate internal alignment padding holes. No logic changes — field access by name is unaffected throughout the codebase (verified: MSP, settings, CMS all use named field access).
Changes
pidProfile_s: 292 → 272 bytes, 10 holes / 21 bytes eliminated, PG version 11→12blackboxConfig_s: 16 → 12 bytes, 1 hole / 2 bytes eliminated, PG version 4→5statsConfig_s: 20 → 16 bytes, 1 hole / 2 bytes eliminated, PG version 2→3geozone_config_s: 20 → 16 bytes, 1 hole / 2 bytes eliminated, PG version 0→1Result on MATEKF722:
.pg_resetdata1303→1275 bytes, text 470511→470491 bytes (-20 bytes flash).Note:
statsConfigversion bump applies universally including targets withoutUSE_ADCwhere the layout is unchanged. Those targets will lose saved stats on upgrade.Testing
paholeconfirms zero internal holes in all modified structs after change