Skip to content

GPS: u-blox ZED-F9P and ZED-X20P as their own receiver models - #12083

Open
Raffi1202 wants to merge 8 commits into
iNavFlight:maintenance-10.xfrom
Raffi1202:feature/ublox-f9p-x20p
Open

Raffi1202 wants to merge 8 commits into
iNavFlight:maintenance-10.xfrom
Raffi1202:feature/ublox-f9p-x20p

Conversation

@Raffi1202

@Raffi1202 Raffi1202 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #12021 (X20 detection via PROTVER). Until that is merged this branch carries its commits; the change here is the last commit, 2c92c0f.

Background

  • The ZED-F9P reports the M9's hardware ID 00190000 and is configured like an M9. configureGNSS() enables Galileo with E1 only and GLONASS with L1 only (sigCfgMask = 0x01). The F9P accepts GPS, Galileo, GLONASS and QZSS only with both bands on or both off and answers anything else with ACK-NAK (ZED-F9P Integration Manual §3.1.4.3, Table 3). INAV then resets gps_ublox_use_galileo/beidou/glonass to their defaults while the receiver keeps its factory setup. u-blox F9 series GNSS support #10236 shows it: Galileo and GLONASS switched themselves off, BeiDou stayed on.
  • The ZED-X20P's default signal plan has no BeiDou B1I (ZED-X20P Integration Manual, Table 6), which configureGNSS10() enables whenever GLONASS is off.
  • The X20 answers UBX-MON-GNSS only in version 1, which INAV does not parse. It was still polled three times at startup and every 5 s after.

Changes

  • ubloxRefineHardwareVersion(): hardware 00190000 with a MON-VER extension MOD=...F9... becomes UBX_HW_VERSION_UBLOX_F9 = 0x89 (series 0b10, as reserved in the header). Without MOD= the swVersion decides: the F9 reports EXT CORE 1., the M9 EXT CORE 4.. MSP_GPSSTATISTICS reports 0x89, CLI status shows UBLOXF9.
  • The capability checks compare the generation bits, so the F9 keeps every M9 decision except the constellation setup.
  • F9 and X20 get one CFG-VALSET with only the constellation switches SBAS_ENA, GAL_ENA, BDS_ENA, QZSS_ENA, GLO_ENA. The per-signal keys stay at the receiver defaults, so the band rules cannot be broken. A constellation the receiver does not list in MON-VER/MON-GNSS is not sent (X20 HPG 2.00/2.02 have no GLONASS). ArduPilot's CFGv2 sends only these keys as well. M8, M9, M10 and unknown receivers keep their paths.
  • A MON-GNSS reply in a version other than 0 ends the startup poll and stops the periodic one.
  • gps_ublox_nav_hz description: F9P and X20P rate limits (data sheets).

No new settings, no PG version change.

Behaviour change: with the default gps_ublox_use_glonass = OFF an F9P now runs GPS, Galileo and BeiDou instead of its factory four constellations.

Testing

  • gps_ublox_unittest, table-driven: hardware refinement (real F9P/M9/X20 MON-VER strings; M8, M10, X20 and unknown hardware with F9 strings stay unchanged), capability matrix including F9 and X20, enable-key lists per constellation and supported mask. gps_null_port_unittest, gps_heartbeat_unittest and the full check target (601 tests) pass.
  • Hardware: ZED-F9P (HPG 1.51) and ZED-X20P (HPG 2.11) on an IFLIGHT_BLITZ_ATF435, results in the comment below. The F9P accepts every constellation choice and keeps both bands, the X20 keeps BeiDou B1C.

Flash / RAM

Against maintenance-10.x + #12021, built locally. The size bot compares against 7e82f68, the merge base with maintenance-11.x, so its table includes the maintenance-10.x changes since then; compared with its report on #12021 the difference is +264 B on MATEKF405 and +424 B on MATEKF722.

Target Flash RAM
MATEKF405 +208 B 0
MATEKF722 +424 B (FLASH1 97.69 %) -8 B
IFLIGHT_BLITZ_ATF435 +224 B 0

Open

Configurator presets for both receivers: iNavFlight/inav-configurator#2813.

gpsParseFrameUBLOX() only looked for PROTVER after the hardware string
was recognised. Receivers newer than M10 stayed at Proto 0.00 and were
configured over legacy CFG messages they do not answer, so auto-config
never completed. Parse the protocol version from every extension field,
read the two-digit major/minor as integers instead of through fastA2F(),
drop MON-VER payloads shorter than the header, and let a known protocol
version finish detection. Adds gps_ublox_protocol_unittest.
The ZED-X20P reports hwVersion 000B0000 in MON-VER. Without a table
entry it stays UBX_HW_VERSION_UNKNOWN and gpsConfigure() skips the
constellation setup, so gps_ublox_use_galileo/beidou/glonass never
reach the receiver.

Add UBX_HW_VERSION_UBLOX20 (0x54) in the u-blox series, so the existing
">= UBX_HW_VERSION_UBLOX10" checks cover it: GNSS setup over CFG-VALSET,
MON-GNSS poll at start-up and MON-RF polling.

The F9P is not added. It reports 00190000, the same ID as the M9, and is
already handled as UBLOX9.

The test uses a MON-VER captured from a ZED-X20P running HPG 2.10.
The X20 answers MON-GNSS with message version 1, which the parser
ignores, so the start-up capability poll waits its full 3 x 500 ms.
Nothing refreshes the GPS timeout in that loop and gps.c restarts the
driver after 1000 ms. Since aa0d822 made the X20 known hardware, it
entered that loop and never finished configuration.

Refresh the timeout on each poll; the receiver already answered MON-VER.
The test now answers MON-GNSS with a capture from a ZED-X20P and checks
the longest gap without a timeout refresh.
The F9P reports the M9 hardware ID, answers MON-GNSS version 0 and still
accepts legacy CFG messages. The test uses replies captured from a
ZED-F9P running HPG 1.51 and checks that it keeps the M9 path:
constellations over CFG-GNSS, the rest over CFG-VALSET, and no GPS
timeout during start-up.
…le-driven

The hardware and protocol version decoders become pure functions in
gps_ublox_utils.c, so gps_ublox_unittest.cc tests them directly with
tables of known IDs, valid formats, the old float truncation cases and
malformed fields. The protocol harness that drove the whole driver
through a fake serial port, its CMake target and the target.h change
are dropped. No behaviour change.
A receiver whose hardware ID is not in the table but that reports
PROTVER 15.00 or newer (the first M8 protocol with CFG-GNSS and
MON-GNSS) now gets the GNSS capability poll, the constellation
detection from the MON-VER extensions and the constellation setup.
Such a receiver uses the M10 signal keys from protocol 34.00 on: below
that, the documented firmware (M9, F9P, F9R) lacks BDS_B1C, and M9 and
F9P still accept CFG-GNSS. Known hardware keeps its current path.

The decisions become pure functions in gps_ublox_utils.c with table
tests. ubloxEffectiveNavHz() returns the rate configureRATE is asked
for, including the 20/40 Hz limit that configureRATE used to apply on
its own, so the satellite info divider in iNavFlight#12001 can use the same value.
gps.c counts its timeout from the last gpsSetProtocolTimeout() call, not
from received frames, so the MON-VER retries only got two of their three
polls when an answer was lost. The timeout is now refreshed on each
poll, as the MON-GNSS loop already does. If none of the three polls
brings a hardware or protocol version, the driver restarts as on a
communication loss instead of setting the receiver up on the legacy
path.

The capability bits were cleared after MON-VER had set GAL/BDS/GLO from
its extensions. M8 to M10 set them again from MON-GNSS, but the X20
answers MON-GNSS version 1, so gpsinfo showed no constellations for it.
They are now cleared before MON-VER; on M8 to M10 a lost MON-GNSS answer
now leaves the MON-VER bits in place instead of none.

Document 0x54 (X20, hwVersion 000B0000) in gps_ublox.h, and drop the
typeconversion.h include that is unused since fastA2F went.
The ZED-F9P reports the M9's hardware ID. It is now told apart by the
MOD= extension of MON-VER (fallback: the "EXT CORE 1." base version)
and reported as 0x89, series 0b10. The capability checks compare the
generation, so the F9 keeps every M9 decision except the constellation
setup.

F9 and X20 get their constellations through the CFG-SIGNAL enable keys
only and keep the receiver's signal defaults. The F9 rejects the
single-band masks INAV sent, which reset the constellation settings to
their defaults, and the X20's default signal plan has no BeiDou B1I.

A MON-GNSS reply in a version INAV does not parse (X20: version 1)
ends the startup poll and stops the periodic poll.
@github-actions

Copy link
Copy Markdown

RAM / Flash usage vs. base commit 7e82f68 — commit 2c92c0f

Target Flash Δ RAM Δ
MATEKF405 ⚠️ +19916 B (+2.83%) CCM: +4096 B (+14.39%)
RAM: -5088 B (-4.66%)
MATEKF722 ⚠️ +9124 B (+1.93%) ITCM_RAM: +104 B (+0.84%)
RAM: -1584 B (-1.79%)
TCM: ±0 B (±0.00%)
MATEKF765 ⚠️ +13232 B (+1.78%) DTCM_RAM: +136 B (+0.48%)
SRAM1: -1764 B (-1.39%)
MATEKH743 ⚠️ +20092 B (+2.58%) D2_RAM: +160 B (+5.15%)
DTCM_RAM: +116 B (+0.90%)
ITCM_RAM: +64 B (+0.39%)
RAM: -1124 B (-0.78%)

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

@github-actions

Copy link
Copy Markdown

Test firmware build ready — commit 2c92c0f

Download firmware for PR #12083

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.

@Raffi1202

Copy link
Copy Markdown
Contributor Author

Hardware test done with both receivers.

Setup: IFLIGHT_BLITZ_ATF435, receiver on a UART at 115200 baud, gps_auto_config = ON. ZED-F9P HPG 1.51 (PROTVER 27.50) and ZED-X20P HPG 2.11 (PROTVER 50.11). "base" is maintenance-10.x @ 3931fcd + #12021, "PR" is the same with this branch @ 2c92c0f. Every run starts from a freshly reset receiver (CFG-RST), the receiver's CFG-SIGNAL items are read back with CFG-VALGET afterwards. Settings are given as Galileo/BeiDou/GLONASS.

ZED-F9P

base PR
CLI status UBLOX9 Proto: 27.50 UBLOXF9 Proto: 27.50
ON/OFF/ON NAK. The three settings fall back to their defaults, the receiver keeps all four constellations acknowledged, settings stay. Receiver: Galileo E1+E5b, BeiDou off, GLONASS L1+L2
OFF/ON/OFF acknowledged, but BeiDou is left with B1 only (B2 off) acknowledged. BeiDou B1+B2, Galileo and GLONASS off
Setting changed and saved, receiver stays powered NAK. INAV shows Galileo ON while the receiver keeps Galileo off the receiver follows every change

No driver restarts in any run. This is the pattern of #10236, and it is gone with the PR.

ZED-X20P

base PR
CLI status UBLOX20 Proto: 50.11 UBLOX20 Proto: 50.11
ON/ON/OFF and OFF/ON/OFF acknowledged, BeiDou left without L1 (BDS_B1_ENA = 1, BDS_B1C_ENA = 0, no B1I in signal plan SP2) acknowledged, only the *_ENA items change, BeiDou keeps B1C
ON/OFF/ON acknowledged acknowledged
Receiver reset while the FC runs one timeout, configured again within 5 s the same

Over USB the X20 acknowledged all 64 transitions between the 8 combinations with the enable keys, each within 63 ms.

Configurator

iNavFlight/inav-configurator#2813 (CI build of 6675bb4) against this firmware: Auto-detect reports "u-blox ZED-F9P" and "u-blox ZED-X20P" and selects the matching preset.

Limitation: the X20 needs #12001 at 115200 baud

With NAV-SIG at the navigation rate the X20's UART is overbooked once reception is good (12 to 14 satellites): 98 to 102 % load, 45 kB backlog in the receiver, data about 4 s old while INAV shows GPS=OK, and after an FC reboot the driver restarts in a loop. With #12001 and #11921 merged on top the load is 36 to 37 % and none of this happens. The numbers are in #12021. This PR does not change the amount of data, it only inherits the problem; it should be merged together with #12001 or after it.

Not tested

  • F9P with full reception on this build. During its runs it tracked 4 to 7 satellites (UART load 25 to 41 %). On base it was at 92 % with all four constellations.
  • X20 firmware HPG 2.00/2.02 (no GLONASS).
  • In flight.

@Raffi1202
Raffi1202 marked this pull request as ready for review October 5, 2026 13:41
@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

Recognize ZED-F9P and ZED-X20P and configure their constellations safely

🐞 Bug fix ✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Identify F9P and X20P receivers so their configuration and reported model match their hardware.
• Configure whole constellations without overriding receiver-specific signal-band defaults.
• Use protocol-version detection for unknown hardware and stop polling unsupported MON-GNSS
 responses.
Diagram

graph TD
  VER["MON-VER"] --> ID["Model and protocol"] --> CAP["GNSS capabilities"] --> MODE{"F9 or X20?"} -->|Yes| ENABLE["Enable-only VALSET"] --> RX["u-blox receiver"]
  MODE -->|No| OTHER["Existing GNSS path"] --> RX
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Maintain per-model signal-band plans
  • ➕ Allows explicit control of every supported band.
  • ➖ Requires firmware-specific plans and risks rejected configurations or disabling receiver-default bands.

Recommendation: Prefer constellation-only keys for F9 and X20: they apply user choices while preserving each receiver's valid signal plan. Keep per-signal configuration on the existing paths for other models.

Files changed (8) +532 / -90

Enhancement (3) +29 / -4
gps.cExpose F9 and X20 model names +4/-0

Expose F9 and X20 model names

• Returns distinct hardware-version strings for the newly recognized receiver models.

src/main/io/gps.c

gps_ublox.hDefine distinct F9 and X20 hardware versions +10/-4

Define distinct F9 and X20 hardware versions

• Adds model identifiers and a generation mask so F9 can retain M9-generation decisions despite its separate series value.

src/main/io/gps_ublox.h

gps_ublox_utils.hDeclare receiver-detection and GNSS-key helpers +15/-0

Declare receiver-detection and GNSS-key helpers

• Exposes the new parsing, capability, navigation-rate, and constellation-key functions to the driver and unit tests.

src/main/io/gps_ublox_utils.h

Bug fix (2) +223 / -83
gps_ublox.cRoute receiver detection and GNSS configuration by capability +67/-82

Route receiver detection and GNSS configuration by capability

• Parses MON-VER protocol and module fields, handles unsupported MON-GNSS replies, and chooses constellation-only configuration for F9 and X20. Also applies protocol-aware navigation rates and preserves polling and configuration behavior for other generations.

src/main/io/gps_ublox.c

gps_ublox_utils.cCentralize u-blox detection and configuration decisions +156/-1

Centralize u-blox detection and configuration decisions

• Adds hardware and protocol parsing, F9 refinement, capability and rate decisions, and generation of supported whole-constellation keys. These helpers avoid incompatible per-signal settings on F9 and X20.

src/main/io/gps_ublox_utils.c

Tests (1) +278 / -1
gps_ublox_unittest.ccCover model detection and safe configuration decisions +278/-1

Cover model detection and safe configuration decisions

• Adds table-driven tests for hardware IDs, protocol parsing, F9 refinement, capability selection, rate limits, and supported constellation-enable keys.

src/test/unit/gps_ublox_unittest.cc

Documentation (2) +2 / -2
Settings.mdDocument F9P and X20P navigation-rate limits +1/-1

Document F9P and X20P navigation-rate limits

• Adds firmware-specific F9P and X20P rate guidance to the published setting description.

docs/Settings.md

settings.yamlClarify navigation-rate setting for F9P and X20P +1/-1

Clarify navigation-rate setting for F9P and X20P

• Adds receiver-specific rate guidance to the setting description without changing its default or range.

src/main/fc/settings.yaml

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. GPS never works if version detection fails 🐞 Bug ☼ Reliability
Description
After three MON-VER polls with no recognised hardware ID and no PROTVER, gpsProtocolStateThread
now calls ptStop(0). Before, it went on to gpsConfigure on the legacy path. Once stopped, the
thread no longer runs gpsProcessNewSolutionData (the only caller that refreshes lastMessageMs),
so gpsThread times out and restarts the protocol. This repeats every cycle: a receiver that sends
navigation data but doesn't answer MON-VER, or answers with an unknown ID and no PROTVER extension,
never gets a fix. Before this change, such a receiver was configured with the legacy messages and
worked.
Code

src/main/io/gps_ublox.c[R1239-1242]

+        // Without a version the receiver would be set up on the legacy path, so restart like a communication loss
+        if (gpsState.hwVersion == UBX_HW_VERSION_UNKNOWN && gpsState.swVersionMajor == 0) {
+            ptStop(0);
+        }
Evidence
ptStop sets line = -1 and returns, so the protothread never runs again until it is restarted
(protothreads.h). Only the state thread's gpsProcessNewSolutionData calls
gpsSetProtocolTimeout(baseTimeoutMs), which refreshes lastMessageMs (gps.c:418-421). Once that
call stops, gpsThread sees millis()-lastMessageMs > baseTimeoutMs and moves to
GPS_LOST_COMMUNICATION, then GPS_INITIALIZING, then restart() (gps.c:603-617). Detection fails the
same way every time, so the cycle never ends. The old code skipped GNSS setup but still ran
ptSpawn(gpsConfigure) and the main loop, which also re-polls MON-VER every GPS_CAPA_INTERVAL while
the version is unknown (gps_ublox.c:1276-1279).

src/main/io/gps_ublox.c[1231-1261]
src/main/scheduler/protothreads.h[184-190]
src/main/io/gps.c[418-421]
src/main/io/gps.c[603-617]

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

## Issue description
When no hardware or protocol version is detected after the MON-VER retries, `gpsProtocolStateThread` calls `ptStop(0)`. GPS then restarts over and over, and a receiver that never answers MON-VER (or has an unknown ID and no PROTVER) is never usable. The previous behaviour configured it on the legacy path.

## Fix Focus Areas
- src/main/io/gps_ublox.c[1239-1242]

## Recommended Fix
Don't stop on the first failed detection. Either keep the old fallback (continue to `ptSpawn(gpsConfigure)`; the periodic MON-VER poll in the main loop already retries detection), or restart only a limited number of times (e.g. track a counter across restarts) and then fall back to the legacy configuration instead of stopping forever.

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


Grey Divider

Context sources
Review mode: Auto: 🧠 Deep: This is a substantial, behavior-changing GPS protocol/configuration change spanning multiple independent parsing, capability, timing, and hardware-specific code paths with a high density of subtle compatibility defects.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/main/io/gps_ublox.c
Comment on lines +1239 to +1242
// Without a version the receiver would be set up on the legacy path, so restart like a communication loss
if (gpsState.hwVersion == UBX_HW_VERSION_UNKNOWN && gpsState.swVersionMajor == 0) {
ptStop(0);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Gps never works if version detection fails 🐞 Bug ☼ Reliability

After three MON-VER polls with no recognised hardware ID and no PROTVER, gpsProtocolStateThread
now calls ptStop(0). Before, it went on to gpsConfigure on the legacy path. Once stopped, the
thread no longer runs gpsProcessNewSolutionData (the only caller that refreshes lastMessageMs),
so gpsThread times out and restarts the protocol. This repeats every cycle: a receiver that sends
navigation data but doesn't answer MON-VER, or answers with an unknown ID and no PROTVER extension,
never gets a fix. Before this change, such a receiver was configured with the legacy messages and
worked.
Agent Prompt
## Issue description
When no hardware or protocol version is detected after the MON-VER retries, `gpsProtocolStateThread` calls `ptStop(0)`. GPS then restarts over and over, and a receiver that never answers MON-VER (or has an unknown ID and no PROTVER) is never usable. The previous behaviour configured it on the legacy path.

## Fix Focus Areas
- src/main/io/gps_ublox.c[1239-1242]

## Recommended Fix
Don't stop on the first failed detection. Either keep the old fallback (continue to `ptSpawn(gpsConfigure)`; the periodic MON-VER poll in the main loop already retries detection), or restart only a limited number of times (e.g. track a counter across restarts) and then fall back to the legacy configuration instead of stopping forever.

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

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