From 0c4bee7a7be5aa79c8fba1c7e1cf19e6bab42437 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 9 Sep 2026 20:15:57 +0000 Subject: [PATCH] fix(sx126x): let CalibrateImage settle before re-applying RX registers in resetAGC() (#11774) * fix(sx126x): let CalibrateImage settle before re-applying RX registers in resetAGC() CalibrateImage returns as soon as the command is accepted and BUSY does not stay asserted for the rest of the calibration. resetAGC() then re-applies the RX boosted-gain and 0x8B5 registers immediately, and a register write landing in that window fails write-verify (RADIOLIB_ERR_SPI_WRITE_FAILED), leaving the chip needing a full re-init. On RAK3401 + RAK13302 (nRF52840, busy mesh) this hit ~69% of resets with no delay, ~3% at 10-20 ms, and 0 at 50 ms. * fix(sx126x): number the CalibrateImage settle as step 6 and re-wrap the comment Review feedback: the settle is the wait for step 5's image calibration, just as step 4 waits for step 3, so number it and wrap to the width of the other steps. Resume receiving becomes step 7. No functional change. --------- Co-authored-by: Ben Meadors --- src/mesh/SX126xInterface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index aa55335b4..ab1f5eb38 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -569,6 +569,10 @@ template void SX126xInterface::resetAGC() // 5. Re-calibrate image rejection for actual operating frequency // Calibrate(0x7F) defaults to 902-928 MHz which is wrong for other regions. lora.calibrateImage(getFreq()); + // 6. CalibrateImage keeps working internally after it returns, and BUSY does not + // stay asserted for it; a register write in that window fails write-verify + // (RADIOLIB_ERR_SPI_WRITE_FAILED) and stalls the chip. + module.hal->delay(50); // Re-apply settings that calibration may have reset @@ -592,7 +596,7 @@ template void SX126xInterface::resetAGC() LOG_WARN("SX126x resetAGC: 0x8B5 RX patch re-apply failed"); } - // 6. Resume receiving + // 7. Resume receiving startReceive(); }