Skip to content

Disable SIM telemetry for F722 targets due to lack of FLASH memory#11399

Open
DzikuVx wants to merge 2 commits intomaintenance-10.xfrom
dzikuvx-disable-sim-telemetry-f722
Open

Disable SIM telemetry for F722 targets due to lack of FLASH memory#11399
DzikuVx wants to merge 2 commits intomaintenance-10.xfrom
dzikuvx-disable-sim-telemetry-f722

Conversation

@DzikuVx
Copy link
Member

@DzikuVx DzikuVx commented Mar 5, 2026

No description provided.

@DzikuVx DzikuVx added this to the 10.0 milestone Mar 5, 2026
@qodo-code-review
Copy link
Contributor

Review Summary by Qodo

Disable SIM telemetry for F722 targets to save FLASH memory

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Disable SIM telemetry for F722 targets due to FLASH memory constraints
• Move USE_TELEMETRY_SIM definition behind MCU_FLASH_SIZE check
• Preserve SIM telemetry for higher-capacity MCUs (>512KB FLASH)
Diagram
flowchart LR
  A["SIM Telemetry Definition"] -->|Moved from common| B["MCU_FLASH_SIZE > 512 Check"]
  B -->|Enabled for| C["F7/H7 with >512KB FLASH"]
  B -->|Disabled for| D["F722/F411 with ≤512KB FLASH"]
Loading

Grey Divider

File Changes

1. src/main/target/common.h ⚙️ Configuration changes +1/-1

Conditionally enable SIM telemetry based on FLASH size

• Removed USE_TELEMETRY_SIM from unconditional definitions
• Added USE_TELEMETRY_SIM inside conditional block for MCUs with FLASH_SIZE > 512KB
• Ensures SIM telemetry is only enabled on targets with sufficient FLASH memory

src/main/target/common.h


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Mar 5, 2026

Code Review by Qodo

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

Grey Divider


Action required

1. EEPROM telemetry config corruption🐞 Bug ✓ Correctness
Description
Disabling USE_TELEMETRY_SIM on <=512KiB builds changes the serialized layout of telemetryConfig_t
(SIM fields are removed from the middle), but the parameter-group version remains the same. On
upgrade, pgLoad will memcpy bytes from the old stored record into the new struct (version still
matches), shifting/corrupting mavlink and other telemetry settings silently.
Code

src/main/target/common.h[R203-204]

#if (MCU_FLASH_SIZE > 512)
+#define USE_TELEMETRY_SIM
Evidence
This PR makes USE_TELEMETRY_SIM conditional on MCU_FLASH_SIZE > 512, so F722xE/F411xE (512KiB) will
compile without USE_TELEMETRY_SIM. telemetryConfig_t conditionally includes SIM fields *before* the
mavlink sub-struct, so removing SIM fields shifts subsequent fields. However, telemetryConfig is
still registered at version 8; pgLoad will accept version==8 and memcpy the first
MIN(storedSize,newSize) bytes, causing the old SIM bytes to be interpreted as the new mavlink
config. The EEPROM loader passes the stored record’s size and version into pgLoad, so this mismatch
happens in real upgrades. For affected targets, MCU_FLASH_SIZE is indeed 512KiB (e.g., STM32F411
uses MCU_FLASH_SIZE=512; STM32F7 “E” size maps to 512KiB).

src/main/target/common.h[202-205]
src/main/telemetry/telemetry.h[56-92]
src/main/telemetry/telemetry.c[59-88]
src/main/config/parameter_group.c[86-94]
src/main/config/config_eeprom.c[220-237]
cmake/stm32.cmake[142-175]
cmake/stm32f4.cmake[126-130]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`USE_TELEMETRY_SIM` is now disabled on &amp;lt;=512KiB targets, which removes the SIM fields from `telemetryConfig_t` and shifts the `mavlink` sub-struct. However, `telemetryConfig` is still registered at PG version `8`, so upgrades on affected targets will load old EEPROM records (also version 8) via `pgLoad()` and memcpy the wrong bytes into the new struct, corrupting mavlink/telemetry config.
## Issue Context
- EEPROM loading uses the stored record’s `size` and `version` and calls `pgLoad()`.
- `pgLoad()` will memcpy bytes when versions match, and it does not understand field-level migrations.
## Fix Focus Areas
- src/main/telemetry/telemetry.c[59-60]
## Implementation notes
- Option A (recommended): make the PG version conditional:
- If `USE_TELEMETRY_SIM` is defined, keep version `8`.
- Else, use version `9` (or any new version) so EEPROM records written with SIM-enabled layout won’t be loaded into the SIM-disabled layout.
- Option B: bump to `9` unconditionally (will reset telemetry config for all targets, but avoids corruption everywhere).
- After bumping version, confirm that `pgLoad()` will skip memcpy on version mismatch, leaving reset defaults intact.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

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