Commit a78b5da5 authored by Florian Kaltenberger's avatar Florian Kaltenberger

fixes an issue with clock source

 - command line paramter --clock-source can only be set at UE (removed this option from gNB)
 - at gNB use clock_source from RU section in config file
 - in both cases if clock_source is present in usrp_args, it will override clock_source
parent ee6b18d3
...@@ -2252,6 +2252,9 @@ void RCconfig_RU(void) ...@@ -2252,6 +2252,9 @@ void RCconfig_RU(void)
LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr));
} }
} }
else {
RC.ru[j]->openair0_cfg.clock_source = unset;
}
if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) {
if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) {
......
...@@ -106,7 +106,6 @@ int config_sync_var=-1; ...@@ -106,7 +106,6 @@ int config_sync_var=-1;
#endif #endif
volatile int oai_exit = 0; volatile int oai_exit = 0;
static clock_source_t clock_source = internal;
static int wait_for_sync = 0; static int wait_for_sync = 0;
unsigned int mmapped_dma=0; unsigned int mmapped_dma=0;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \
{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \
{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ {"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \
{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \
{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \
{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \
{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \
......
...@@ -116,7 +116,7 @@ volatile int start_eNB = 0; ...@@ -116,7 +116,7 @@ volatile int start_eNB = 0;
volatile int start_UE = 0; volatile int start_UE = 0;
volatile int oai_exit = 0; volatile int oai_exit = 0;
static clock_source_t clock_source = internal; static clock_source_t clock_source = unset;
int single_thread_flag=1; int single_thread_flag=1;
static double snr_dB=20; static double snr_dB=20;
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \
{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \
{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \
{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ {"clock-source", CONFIG_HLP_EXCCLK, 0, iptr:&clock_source, defintval:0, TYPE_INT, 0}, \
{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \
{"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \
......
...@@ -135,6 +135,8 @@ typedef struct { ...@@ -135,6 +135,8 @@ typedef struct {
/*! \brief Clock source types */ /*! \brief Clock source types */
typedef enum { typedef enum {
//! this means the paramter has not been set
unset=-1,
//! This tells the underlying hardware to use the internal reference //! This tells the underlying hardware to use the internal reference
internal=0, internal=0,
//! This tells the underlying hardware to use the external reference //! This tells the underlying hardware to use the external reference
......
...@@ -1145,27 +1145,34 @@ extern "C" { ...@@ -1145,27 +1145,34 @@ extern "C" {
device->priv = s; device->priv = s;
if (args.find("clock_source")==std::string::npos) { if (args.find("clock_source")==std::string::npos) {
LOG_I(HW, "Using clock_source == '%d'\n", openair0_cfg[0].clock_source);
if (openair0_cfg[0].clock_source == internal) { if (openair0_cfg[0].clock_source == internal) {
//in UHD 3.14 we could use //in UHD 3.14 we could use
//s->usrp->set_sync_source("clock_source=internal","time_source=internal"); //s->usrp->set_sync_source("clock_source=internal","time_source=internal");
s->usrp->set_time_source("internal"); s->usrp->set_time_source("internal");
s->usrp->set_clock_source("internal"); s->usrp->set_clock_source("internal");
LOG_D(HW,"Setting time and clock source to internal\n");
} }
else if (openair0_cfg[0].clock_source == external ) { else if (openair0_cfg[0].clock_source == external ) {
//s->usrp->set_sync_source("clock_source=external","time_source=external"); //s->usrp->set_sync_source("clock_source=external","time_source=external");
s->usrp->set_time_source("external"); s->usrp->set_time_source("external");
s->usrp->set_clock_source("external"); s->usrp->set_clock_source("external");
LOG_D(HW,"Setting time and clock source to external\n");
} }
else if (openair0_cfg[0].clock_source==gpsdo) { else if (openair0_cfg[0].clock_source==gpsdo) {
s->usrp->set_clock_source("gpsdo"); s->usrp->set_clock_source("gpsdo");
s->usrp->set_time_source("gpsdo"); s->usrp->set_time_source("gpsdo");
LOG_D(HW,"Setting time and clock source to gpsdo\n");
}
else {
LOG_W(HW,"Clock source set neither in usrp_args nor on command line, using default!\n");
} }
} else {
LOG_W(HW, "clock_source already specified in device arguments! Ignoring command line parameter\n");
} }
else {
if (openair0_cfg[0].clock_source != unset) {
LOG_W(HW,"Clock source set in both usrp_args and in clock_source, ingnoring the latter!\n");
}
}
if (s->usrp->get_clock_source(0) == "gpsdo") { if (s->usrp->get_clock_source(0) == "gpsdo") {
s->use_gps = 1; s->use_gps = 1;
if (sync_to_gps(device)==EXIT_SUCCESS) { if (sync_to_gps(device)==EXIT_SUCCESS) {
......
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \
{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ {"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \
{"clock", CONFIG_HLP_CLK, 0, uptr:&clock_source, defintval:0, TYPE_UINT, 0}, \ {"clock-source", CONFIG_HLP_CLK, 0, iptr:&clock_source, defintval:0, TYPE_INT, 0}, \
{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \
{"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0} \ {"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0} \
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment