myriadrf / LimeSuite

Driver and GUI for LMS7002M-based SDR platforms
https://myriadrf.org/projects/lime-suite/
Apache License 2.0
468 stars 185 forks source link

lime::ADF4002 infinite loop #372

Closed pgreenland closed 1 year ago

pgreenland commented 1 year ago

LimeUtils allows an external reference clock to be enabled, featuring the sequence:

lime::ADF4002* m_pModule;
m_pModule = new lime::ADF4002();
...
m_pModule->SetDefaults();
m_pModule->SetFrefFvco(fref, fvco, rCount, nCount);
m_pModule->GetConfig(data);
...

The LimeSDR native API port of srsRAN, makes use of a virtually identical sequence of operations when setting up the external reference during device initialisation.

The ADF4002 module doesn't appear to initialise the variables txtFref and txtFvco, which can lead to an infinite loop in SetDefaults (via the call to CalculateRN using the uninitialised floating point variables as part of a loop condition).

In the srsRAN LimeSDR native API port I've seen these initialised to NaN on my machine, leading to the infinite loop.

It seems that either CalculateRN shouldn't be called from SetDefaults. Or the constructor of the ADF4002 should set some default values / just simply zero the variables to prevent the loop.

See srsRAN LimeSDR native API port issue for more information: https://github.com/myriadrf/srsRAN/issues/2