Files
openairinterface5g/radio/USRP
Robert Schmidt ce4e647fd8 USRP: move time/clock source setting to later
Doing this before using set_master_clock_rate() on the B200 seems to
invalidate clock settings:

    [HW]   USRP clock set to 1759836386.000000 sec
    [...]
    [HW]   current pps at 3.286750, starting streaming at 4.286750

In other words, the current time setting was reset. With this change
now, we see

    [HW]   USRP clock set to 1759929873.000000 sec
    [...]
    [HW]   current pps at 1759929873.000000, starting streaming at 1759929874.000000

This is because changing clock sources (I assume setting the master
clock rate impacts the clock) can result in changing the time.  From the
documentation of set_time_next_pps() [1]:

> Note: When changing clock sources, a previously set time will most
> likely be lost. It is recommended to set the time after changing the
> clock source. Otherwise, an unexpected time may line up with future PPS
> edges.

[1] https://files.ettus.com/manual/classuhd_1_1usrp_1_1multi__usrp.html#a75b1c5375549e6a446d686ee7d9b4e14
2025-10-10 12:49:29 +02:00
..

[[TOC]]

USRP device documentation

General

OAI works with most common USRP models, like B200, B200mini/B205mini, B210, X310, N300, N310, N320, X410. This is achieved by using the Ettus Universal Hardware Driver (UHD) (https://github.com/EttusResearch/uhd). The file usrp_lib.cpp provides an abstraction layer of UHD to OAI.

Example files can be found in the ci-scripts/conf_files/ directory with a usrp in the name, for instance gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf.

Configuration

The USRP can be configured in the RU section of the config file. The field sdr_addrs uses the USRP device identification string. Here are a few examples

sdr_addrs = "addr=192.168.10.2" # uses a single 10Gb Ethernet interface on an N3x0 or X3x0 or X4x0
sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2" # uses 2 10Gb Ethernet interfaces on a N3x0 or X3x0 or X4x0 (requires that you flashed the FPGA wth the XG image)
sdr_addrs = "serial=ABC1234" # globally unique identifier of this device

you can also use the multi USRP feature and specify multiple USRPs, in which case you will get the aggregated number of channels on all the devices

sdr_addrs = "addr0=192.168.10.2,addr1=192.168.30.2"

You can specify to use external or interal clock or time source either by adding the parameters in the sdr_addrs field or by using the fields clock_src or time_src

sdr_addrs = "addr=192.168.10.2,clock_source=external,time_source=external"

is equivalent to

sdr_addrs = "addr=192.168.10.2"
clock_src = "external"
time_src  = "external"

Valid choices for clock and time source are internal, external, and gpsdo.

Note 1: the USRP remembers the choice of the clock source. If you want to make sure it uses always the same, always specify the clock_source and time_source.

Note 2: when using multiple USRPs they always have to be synchronized using external or gpsdo

Last but not least you may specify that only a specfic subdevice of the USRP is used. See also the section Specifying the Subdevice in the UHD manual.

For example, on a USRP N310, the following fields will specify that you use channel 0 of subdevice A. You can enter this information after providing the ip addresses of the USRPs in sdr_addrs.

tx_subdev = "A:0"
rx_subdev = "A:0"

Here is an example of the RUs configuration for a setup with 2 USRP N310.

RUs = (
{
  local_rf       = "yes"
  nb_tx          = 2
  nb_rx          = 2
  att_tx         = 0
  att_rx         = 0;
  bands          = [78];
  max_pdschReferenceSignalPower = -27;
  max_rxgain                    = 75;
  eNB_instances  = [0];
  sdr_addrs = "addr0=192.168.10.2,addr1=192.168.20.2,clock_source=external,time_source=external"
  tx_subdev ="A:0 B:0"
  rx_subdev ="A:1 B:1"
}
);

Hint: You cannot see TX/RX spread over multiple USRPs, if you use internal as a refrence of the clock and time source.

Furthur information about synchronization on the USRP N3xx devices can be found here: https://kb.ettus.com/Using_Ethernet-Based_Synchronization_on_the_USRP%E2%84%A2_N3xx_Devices

When combining this with the multi USRP feature you can create a distributed antenna array with only 1 channel used at each USRP.