Repository navigation
fix(gps): match Airoha idle_int sleep to the documented sequence - #12167
Conversation
For boards that wake the AG3352 through idle_int (ThinkNode M8 and M9): - Drop $PAIR382,1 before the sleep command. It locks the CPU out of sleep, which works against both $PAIR003 and $PAIR650. - Hold idle_int low 50 ms before sending, and wait 50 ms after the command takes before EN cuts the core, as Elecrow's reference does. - A successful $PAIR650 need not reply, so also accept NMEA going quiet for a full cycle as success; resend once otherwise. Boards with RTC_INT are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
⚡ Try this PR in the Web FlasherNote Building this pull request… the flash button, badges and supported-board |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: 🔵 Low · up to
|
mverch67
left a comment
There was a problem hiding this comment.
Shutdown for M9 still works:
INFO | 21:21:29 48 Enter deep sleep forever
INFO | 21:21:29 49 GPS deep sleep
INFO | 21:21:29 49 GPS power state ACTIVE -> OFF
DEBUG | 21:21:29 49 $GNGGA,000027.012,,,,,0,0,,,M,,M,,*50.
DEBUG | 21:21:29 49 $GNGGA,000027.012,,,,,0,0,,,M,,M,,*50..$GNRMC,000027.012,V,,,,,,,060180,,,N,V*20.
DEBUG | 21:21:29 49 $GNGGA,000027.012,,,,,0,0,,,M,,M,,*50..$GNRMC,000027.012,V,,,,,,,060180,,,N,V*20..$PAIR001,003,1*39.
DEBUG | 21:21:29 49 $GNGGA,000027.012,,,,,0,0,,,M,,M,,*50..$GNRMC,000027.012,V,,,,,,,060180,,,N,V*20..$PAIR001,003,1*39..$GNGGA,000028.012,,,,,0,0,,,M,,M,,*5F.
DEBUG | 21:21:29 49 $GNGGA,000027.012,,,,,0,0,,,M,,M,,*50..$GNRMC,000027.012,V,,,,,,,060180,,,N,V*20..$PAIR001,003,1*39..$GNGGA,000028.012,,,,,0,0,,,M,,M,,*5F..$GNRMC,000028.012,
DEBUG | 21:21:29 49 $GNGGA,000027.012,,,,,0,0,,,M,,M,,*50..$GNRMC,000027.012,V,,,,,,,060180,,,N,V*20..$PAIR001,003,1*39..$GNGGA,000028.012,,,,,0,0,,,M,,M,,*5F..$GNRMC,000028.012,
DEBUG | 21:21:29 49 Found: $PAIR001,003,0
DEBUG | 21:21:29 49 GPS: $PAIR003 took (acked, attempt 1)
DEBUG | 21:21:29 49 Pin EN LOW
There may be merge conflicts with #12113 .
If the MCU resets while the AG3352 is in backup mode, the GPS stays there and the cached-probe check gets no answer, forcing a full re-probe. Pulse RESETB in earlyInitVariant(), as the M5 does with its wake pulse in #12113. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…htastic#12167) * fix(gps): match Airoha idle_int sleep to the documented sequence For boards that wake the AG3352 through idle_int (ThinkNode M8 and M9): - Drop $PAIR382,1 before the sleep command. It locks the CPU out of sleep, which works against both $PAIR003 and $PAIR650. - Hold idle_int low 50 ms before sending, and wait 50 ms after the command takes before EN cuts the core, as Elecrow's reference does. - A successful $PAIR650 need not reply, so also accept NMEA going quiet for a full cycle as success; resend once otherwise. Boards with RTC_INT are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ThinkNode M8: reset the GPS out of backup mode at boot If the MCU resets while the AG3352 is in backup mode, the GPS stays there and the cached-probe check gets no answer, forcing a full re-probe. Pulse RESETB in earlyInitVariant(), as the M5 does with its wake pulse in meshtastic#12113. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Follow-up to #12151 and #12004. Changes the sleep sequence on boards that talk to an AG3352 through idle_int and have no RTC_INT: the ThinkNode M8 (
$PAIR650, reset wake) and the ThinkNode M9 ($PAIR003). Boards with RTC_INT (T1000-E, Wio T1000-S, Mesh Tracker X1) are unchanged.Elecrow measured 1.5 mA in sleep on the M8 and reported that the GPS had not entered low-power mode. Their reference firmware enters sleep differently from ours, and the Quectel GNSS protocol spec explains part of the difference (V1.4, for the Airoha-based LC26G/LC76G/LC86G).
$PAIR382,1$PAIR001,<cmd>,0only$PAIR001,<cmd>,0, or no NMEA sentence for 1.1 sWhy:
$PAIR382isPAIR_TEST_LOCK_SYSTEM_SLEEP: "The CPU core will not enter Sleep mode automatically after the command has been sent." The spec only pairs it with$PAIR003before saving settings, to keep the CPU awake. Here it works against sleep.$PAIR650: "If successful, the module will be set to Backup mode and be prevented from receiving any commands. If failed, the $PAIR001 message will be returned." A successful$PAIR650may never reply, so a missing reply can't be counted as a failure. Instead, either command counts as successful once NMEA stops.$PAIR001replies arriving late are ignored, so a slow$PAIR003,0on the M9 doesn't trigger a resend.cpuDeepSleep(). That reference sends only$PAIR650,0, with idle_int held low for 50 ms beforehand, then waits 50 ms before cutting the 0.8 V core.A debug line now records how each sleep was confirmed:
GPS: $PAIR650 took (acked, attempt 1).M8 boot reset (second commit). If the MCU resets while the AG3352 is in backup mode, the GPS stays there. The cached-probe check then gets no answer, logs
Cached GPS probe stale, and falls back to a full probe.earlyInitVariant()now pulses RESETB once at boot, like the M5's wake pulse in #12113. It isn't ininitVariant(), because on nRF52 that runs before the scheduler, wheredelay()is unsafe.GPS_DEBUG=1trace (M8). Each sleep:After each RESETB wake, the receiver prints its boot banner unprompted:
$PAIR001,002,1/,0,$PAIR011,001(GNSS system startup),$PAIR021,AG3352Q_V3.3.0.AG3352_20251119,..., and$PAIR010aiding requests. So every wake is a full restart out of backup mode. I rebooted the M8 withmeshtastic --rebootwhile the GPS was in backup mode, and it came back withUsing cached GPS probe: AG3352 @ 115200.@mverch67, could you check the M9? #12004 found that
$PAIR003went unanswered without$PAIR382. That was with idle_int low for only 5 ms before sending. With 50 ms it may now be acknowledged; if not, the NMEA check should still confirm sleep and stop the resends.🤝 Attestations
$PAIR382; NMEA resumed after every reset wake. Fixes after waking took 27–32 s, against 36–84 s before. The boot reset recovered the GPS after a reboot during backup mode, using the cached probe.🤖 Generated with Claude Code
Summary by CodeRabbit