USRP Hardware Driver and USRP Manual: USRP2 ...

28 Oct.,2024

 

USRP Hardware Driver and USRP Manual: USRP2 ...

Comparative features list

  • Hardware Capabilities:
    • 1 transceiver card slot
    • External PPS reference input
    • External 10 MHz reference input
    • MIMO cable shared reference
    • Fixed 100 MHz clock rate
    • Internal GPSDO option (N2x0 only)
  • FPGA Capabilities:
    • 2 RX DDC chains in FPGA
    • 1 TX DUC chain in FPGA
    • Timed commands in FPGA (N2x0 only)
    • Timed sampling in FPGA
    • 16-bit and 8-bit sample modes (sc8 and sc16)
      • Up to 25 MHz of RF BW with 16-bit samples
      • Up to 50 MHz of RF BW with 8-bit samples

Load the Images onto the SD card (USRP2 only)

Warning! Use usrp2_card_burner with caution. If you specify the wrong device node, you could overwrite your hard drive. Make sure that --dev= specifies the SD card.

For more information, please visit our website.

Warning! It is possible to use 3rd party SD cards with the USRP2. However, certain types of SD cards will not interface with the CPLD:

  • Cards can be SDHC, which is not a supported interface.
  • Cards can have unexpected timing characteristics.

For these reasons, we recommend that you use the SD card that was supplied with the USRP2.

Use the card burner tool (UNIX)

sudo <install-path>/lib/uhd/utils/usrp2_card_burner_gui.py

-- OR --

cd <install-path>/lib/uhd/utils
sudo ./usrp2_card_burner.py --dev=/dev/sd<XXX> --fpga=<path_to_fpga_image>
sudo ./usrp2_card_burner.py --dev=/dev/sd<XXX> --fw=<path_to_firmware_image>

Use the --list option to get a list of possible raw devices. The list result will filter out disk partitions and devices too large to be the sd card. The list option has been implemented on Linux, Mac OS X, and Windows.

Use the card burner tool (Windows)

<path_to_python.exe> <install-path>/lib/uhd/utils/usrp2_card_burner_gui.py

Load the Images onto the On-board Flash (USRP-N Series only)

The USRP-N Series can be reprogrammed over the network to update or change the firmware and FPGA images. When updating images, always burn both the FPGA and firmware images before power cycling. This ensures that when the device reboots, it has a compatible set of images to boot into.

Use the image loader

Use default images:

uhd_image_loader --args="type=usrp2,addr=<IP address>"

Use custom-built images:

uhd_image_loader --args="type=usrp2,addr=<IP address>" --fw-path="<firmware path>" --fpga-path="<FPGA path>"

If you immediately want to apply this image, add the reset argument:

uhd_image_loader --args="type=usrp2,addr=<IP address>,reset"

The USRP will drop off the network for a brief moment and reboot.

Note: Different hardware revisions require different FPGA images. Determine the revision number from the sticker on the rear of the chassis. Use this number to select the correct FPGA image for your device.

Device recovery and bricking

Its possible to put the device into an unusable state by loading bad images. Fortunately, the USRP-N Series can be booted into a safe (read-only) image. Once booted into the safe image, the user can once again load images onto the device.

The safe-mode button is a pushbutton switch (S2) located inside the enclosure. To boot into the safe image, hold-down the safe-mode button while power-cycling the device. Continue to hold-down the button until the front-panel LEDs blink and remain solid.

When in safe-mode, the USRP-N device will always have the IP address 192.168.10.2.

For more information on using external tools to unbrick your device when even this fails, see Unbricking an N-Series Device.

Setup Networking

The USRP2 only supports Gigabit Ethernet and will not work with a 10/100 Mbps interface. However, a 10/100 Mbps interface can be connected indirectly to a USRP2 through a Gigabit Ethernet switch.

Setup the host interface

The USRP2 communicates at the IP/UDP layer over the gigabit Ethernet. The default IP address of the USRP2 is 192.168.10.2. You will need to configure the host's Ethernet interface with a static IP address to enable communication. An address of 192.168.10.1 and a subnet mask of 255.255.255.0 is recommended.

On a Linux system, you can set a static IP address very easily by using the 'ifconfig' command:

sudo ifconfig <interface> 192.168.10.1

Note that interface is usually something like eth0. You can discover the names of the network interfaces in your computer by running ifconfig without any parameters:

ifconfig -a

Note: When using UHD software, if an IP address for the USRP2 is not specified, the software will use UDP broadcast packets to locate the USRP2. On some systems, the firewall will block UDP broadcast packets. It is recommended that you change or disable your firewall settings.

Multiple devices per host

For maximum throughput, one Ethernet interface per USRP2 is recommended, although multiple devices may be connected via a Gigabit Ethernet switch. In any case, each Ethernet interface should have its own subnet, and the corresponding USRP2 device should be assigned an address in that subnet. Example:

  • Configuration for USRP2 device 0:
    • Ethernet interface IPv4 address: 192.168.10.1
    • Ethernet interface subnet mask: 255.255.255.0
    • USRP2 device IPv4 address: 192.168.10.2
  • Configuration for USRP2 device 1:
    • Ethernet interface IPv4 address: 192.168.20.1
    • Ethernet interface subnet mask: 255.255.255.0
    • USRP2 device IPv4 address: 192.168.20.2

Change the USRP2's IP address

You may need to change the USRP2's IP address for several reasons:

  • to satisfy your particular network configuration
  • to use multiple USRP2s on the same host computer
  • to set a known IP address into USRP2 (in case you forgot)

Method 1

To change the USRP2's IP address, you must know the current address of the USRP2, and the network must be setup properly as described above. Run the following commands: :

cd <install-path>/lib/uhd/utils
./usrp_burn_mb_eeprom --args=<optional device args> --values="ip-addr=192.168.10.3"

Method 2 (Linux Only)

This method assumes that you do not know the IP address of your USRP2. It uses raw Ethernet packets to bypass the IP/UDP layer to communicate with the USRP2. Run the following commands:

cd <install-path>/lib/uhd/utils
sudo ./usrp2_recovery.py --ifc=eth0 --new-ip=192.168.10.3

Communication Problems

When setting up a development machine for the first time, you may have various difficulties communicating with the USRP device. The following tips are designed to help narrow down and diagnose the problem.

RuntimeError: no control response

This is a common error that occurs when you have set the subnet of your network interface to a different subnet than the network interface of the USRP device. For example, if your network interface is set to 192.168.20.1, and the USRP device is 192.168.10.2 (note the difference in the third numbers of the IP addresses), you will likely see a 'no control response' error message.

Fixing this is simple - just set the your host PC's IP address to the same subnet as that of your USRP device. Instructions for setting your IP address are in the previous section of this documentation.

Firewall issues

When the IP address is not specified, the device discovery broadcasts UDP packets from each Ethernet interface. Many firewalls will block the replies to these broadcast packets. If disabling your system's firewall or specifying the IP address yields a discovered device, then your firewall may be blocking replies to UDP broadcast packets. If this is the case, we recommend that you disable the firewall or create a rule to allow all incoming packets with UDP source port .

Ping the device

The USRP device will reply to ICMP echo requests. A successful ping response means that the device has booted properly and that it is using the expected IP address.

ping 192.168.10.2

Monitor the serial output

Read the serial port to get debug verbose output from the embedded microcontroller. The microcontroller prints useful information about IP addresses, MAC addresses, control packets, fast-path settings, and bootloading. Use a standard USB to 3.3v-level serial converter at baud. Connect GND to the converter ground, and connect TXD to the converter receive. The RXD pin can be left unconnected as this is only a one-way communication.

  • USRP2: Serial port located on the rear edge
  • N210: Serial port located on the left side

Monitor the host network traffic

Use Wireshark to monitor packets sent to and received from the device.

Addressing the Device

Single device configuration

In a single-device configuration, the USRP device must have a unique IPv4 address on the host computer. The USRP can be identified through its IPv4 address, resolvable hostname, or by other means. See the application notes on Device Identification. Please note that this addressing scheme should also be used with the multi_usrp interface.

Example device address string representation for a USRP2 with IPv4 address 192.168.10.2:

addr=192.168.10.2

Multiple device configuration

In a multi-device configuration, each USRP device must have a unique IPv4 address on the host computer. The device address parameter keys must be suffixed with the device index. Each parameter key should be of the format <key><index>. Use this addressing scheme with the uhd::usrp::multi_usrp interface.

  • The order in which devices are indexed corresponds to the indexing of the transmit and receive channels.
  • The key indexing provides the same granularity of device identification as in the single device case.

Example device address string representation for 2 USRP2s with IPv4 addresses 192.168.10.2 and 192.168.20.2:

addr0=192.168.10.2, addr1=192.168.20.2

Using the MIMO Cable

The MIMO cable allows two USRP devices to share reference clocks, time synchronization, and the Ethernet interface. One of the devices will sync its clock and time references to the MIMO cable. This device will be referred to as the slave, and the other device, the master.

  • The slave device acquires the clock and time references from the master device.
  • The master and slave may be used individually or in a multi-device configuration.
  • External clocking is optional and should only be supplied to the master device.

Shared Ethernet mode

In shared Ethernet mode, only one device in the configuration can be attached to the Ethernet.

  • Clock reference, time reference, and data are communicated over the MIMO cable.
  • Master and slave must have different IPv4 addresses in the same subnet.

Dual Ethernet mode

In dual Ethernet mode, both devices in the configuration must be attached to the Ethernet.

  • Only clock reference and time reference are communicated over the MIMO cable.
  • The master and slave must have different IPv4 addresses in different subnets.

Configuring the slave

In order for the slave to synchronize to the master over MIMO cable, the following clock configuration must be set on the slave device: :

usrp->set_time_source(

"mimo"

, slave_index);

usrp->set_clock_source(

"mimo"

, slave_index);

Alternative stream destination

It is possible to program the USRP device to send RX packets to an alternative IP/UDP destination.

Set the subnet and gateway

To use an alternative streaming destination, the device needs to be able to determine if the destination address is within its subnet, and ARP appropriately. Therefore, the user should ensure that subnet and gateway addresses have been programmed into the device's EEPROM.

Run the following commands:

cd <install-path>/lib/uhd/utils
./usrp_burn_mb_eeprom --args=<optional device args> --values="subnet=255.255.255.0, gateway=192.168.10.2"

Create a receive streamer

Set the stream args "addr" and "port" values to the alternative destination. Packets will be sent to this destination when the user issues a stream command.

Note: Calling recv() on this streamer object should yield a timeout.

Hardware Setup Notes

Front panel LEDs

The LEDs on the front panel can be useful in debugging hardware and software issues. The LEDs reveal the following about the state of the device:

  • LED A: transmitting
  • LED B: MIMO cable link
  • LED C: receiving
  • LED D: firmware loaded
  • LED E: reference lock
  • LED F: CPLD loaded

Ref Clock - 10 MHz

Using an external 10 MHz reference clock, a square wave will offer the best phase noise performance, but a sinusoid is acceptable. The reference clock requires the following power level:

  • USRP2 5 to 15 dBm
  • N2XX 0 to 15 dBm

PPS - Pulse Per Second

Using a PPS signal for timestamp synchronization requires a square wave signal with the following amplitude:

  • USRP2 5Vpp
  • N2XX 3.3 to 5Vpp

Test the PPS input with the following app:

  • <args> are device address arguments (optional if only one USRP device is on your machine)

    cd <install-path>/lib/uhd/examples ./test_pps_input &#;args=<args>

Internal GPSDO

Please see Internal GPSDO (USRP-N2x0/E1X0 Models) for information on configuring and using the internal GPSDO.

Miscellaneous

Available Sensors

The following sensors are available for the USRP2/N-Series motherboards; they can be queried through the API.

  • mimo_locked - clock reference locked over the MIMO cable
  • ref_locked - clock reference locked (internal/external)
  • other sensors are added when the GPSDO is enabled

Multiple RX channels

There are two complete DDC chains in the FPGA. In the single channel case, only one chain is ever used. To receive from both channels, the user must set the RX subdevice specification. This hardware has only one daughterboard slot, which has been aptly named slot A.

In the following example, a TVRX2 is installed. Channel 0 is sourced from subdevice RX1, and channel 1 is sourced from subdevice RX2 (RX1 and RX2 are the antenna ports on the TVRX2 daughterboard):

usrp->set_rx_subdev_spec(

"A:RX1 A:RX2"

);

Unbricking an N-Series Device

You'll need:

  • JTAG programmer: please connect it to the JTAG connector on the motherboard as shown in the attachment
  • Xilinx 'iMPACT': launch and cancel the new project wizards. You should be left with the screen which shows a single FPGA chip in the main document (auto-detected by the programmer).

Download the latest FPGA images, e.g. using uhd_images_downloader.

There is a sub-directory in the archive below the firmware/images called 'bit'. Use Impact to load usrp_n210_r4_fpga.bit via the programmer (the filename may be different depending on your device type and revision).

The USRP should now be able to communicate on the network (you'll see some LEDs light up and network link be established). The next step is to flash the device and program the serial number. Both these steps can be done with UHD (the JTAG step is complete).

To be sure, run uhd_find_devices and it should appear in the list - remember this IP address for the image loader utility (should be 192.168.10.2 - make sure your network settings enable to you communicate with that subnet!).

The first step is to flash the unit's safe-mode image, and then do a normal flash - both with the UHD Image Loader utility.

Make sure you have UHD installed, and the images from before, and follow the instructions in Load the Images onto the SD card (USRP2 only). You can combine the --fw-path and --fpga-path arguments into the single invocation of the image loader.

You will probably use "usrp_n210_fw.bin" for the firmware and "usrp_n210_r4_fpga.bin" for the FPGA image parameters (use the full/relative file path if your current directory is not that of the images).

uhd_image_loader --args="type=usrp2,addr=192.168.10.2,overwrite-safe" --fw-path=usrp_n210_fw.bin --fpga-path=usrp_n210_r4_fpga.bin

Use the overwrite-safe option the first time, and then repeat without it for the second time. Don't forget to power-cycle the device after it has been flashed.

You can change the normal IP address by following the instructions in Change the USRP2's IP address.

If you run uhd_usrp_probe, you can see the EEPROM keys at the top. Example:

Mboard: N210r4
 hardware: 
 mac-addr: a0:36:fa:25:34:a7
 ip-addr: 192.168.10.4
 subnet: 255.255.255.255
 gateway: 255.255.255.255
 gpsdo: none
 serial: EAR14U7UP

If you need to change any of there, you should then be able to run:

usrp_burn_mb_eeprom --key=<key> --val=<val>

to set the 'mac-addr', 'serial' and 'Mboard'.

Known Issues

  • When setting clock_source to external, but not providing an external reference, there are cases when a successful lock is reported even though no clock signal is present, which can cause false positives. Terminating the clock input may help in some cases.

USRP in Python — PySDR: A Guide to SDR and DSP ...

In this chapter we learn how to use the UHD Python API to control and receive/transmit signals with a USRP which is a series of SDRs made by Ettus Research (now part of NI). We will discuss transmitting and receiving on the USRP in Python, and dive into USRP-specific topics including stream arguments, subdevices, channels, 10 MHz and PPS synchronization.

If you used the standard from-source install, the following command should benchmark the receive rate of your USRP using the Python API. If using 56e6 caused many dropped samples or overruns, try lowering the number. Dropped samples aren&#;t necessarily going to ruin anything, but it&#;s a good way to test the inefficiencies that might come with using a VM or older computer, for example. If using a B 2X0, a fairly modern computer with a USB 3.0 port running properly should manage to do 56 MHz without dropped samples, especially with num_recv_frames set so high.

For more help see Ettus&#; official Building and Installing UHD from source page. Note that there are also methods of installing the drivers that don&#;t require building from source.

For USB type USRPs you&#;ll need to install VM guest additions. Within the VM go to Devices > Insert Guest Additions CD > hit run when a box pops up. Follow the instructions. Restart the VM, then attempt to forward the USRP to the VM, assuming it shows up in the list under Devices > USB. The shared clipboard can be enabled through Devices > Shared Clipboard > Bidirectional.

Under system > processor > choose at least 3 CPUs. If you have an actual video card then in display > video memory > choose something much higher.

Start the VM. It will ask you for installation media. Choose the Ubuntu 22 desktop .iso file. Choose &#;install Ubuntu&#;, use default options, and a pop up will warn you about the changes you are about to make. Hit continue. Choose name/password and then wait for the VM to finish initializing. After finishing the VM will restart, but you should power off the VM after the restart.

Create the virtual hard disk, choose VDI, and dynamically allocate size. 15 GB should be enough. If you want to be really safe you can use more.

While the Python code provided in this textbook should work under Windows, Mac, and Linux, we will only be providing driver/API install instructions specific to Ubuntu 22 (although the instructions below should work on most Debian-based distributions). We will start by creating an Ubuntu 22 VirtualBox VM; feel free to skip the VM portion if you already have your OS ready to go. Alternatively, if you&#;re on Windows 11, Windows Subsystem for Linux (WSL) using Ubuntu 22 tends to run fairly well and supports graphics out-of-the-box.

Receiving samples off a USRP is extremely easy using the built-in convenience function &#;recv_num_samps()&#;, below is Python code that tunes the USRP to 100 MHz, using a sample rate of 1 MHz, and grabs 10,000 samples off the USRP, using a receive gain of 50 dB:

import

uhd

usrp

=

uhd

.

usrp

.

MultiUSRP

()

samples

=

usrp

.

recv_num_samps

(

,

100e6

,

1e6

,

[

0

],

50

)

# units: N, Hz, Hz, list of channel IDs, dB

print

(

samples

[

0

:

10

])

The [0] is telling the USRP to use its first input port, and only receive one channel worth of samples (for a B210 to receive on two channels at once, for example, you could use [0, 1]).

Here&#;s a tip if you are trying to receive at a high rate but are getting overflows (O&#;s are showing up in your console). Instead of usrp = uhd.usrp.MultiUSRP(), use:

usrp

=

uhd

.

usrp

.

MultiUSRP

(

"num_recv_frames="

)

which makes the receive buffer much larger (the default value is 32), helping to reduce overflows. The actual size of the buffer in bytes depends on the USRP and type of connection, but simply setting num_recv_frames to a value much higher than 32 tends to help.

For more serious applications I recommend not using the convenience function recv_num_samps(), because it hides some of the interesting behavior going on under the hood, and there is some set up that happens each call that we might only want to do once at the beginning, e.g., if we want to receive samples indefinitely. The following code has the same functionality as recv_num_samps(), in fact it&#;s almost exactly what gets called when you use the convenience function, but now we have the option to modify the behavior:

import

uhd

import

numpy

as

np

usrp

=

uhd

.

usrp

.

MultiUSRP

()

num_samps

=

# number of samples received

center_freq

=

100e6

# Hz

sample_rate

=

1e6

# Hz

gain

=

50

# dB

usrp

.

set_rx_rate

(

sample_rate

,

0

)

usrp

.

set_rx_freq

(

uhd

.

libpyuhd

.

types

.

tune_request

(

center_freq

),

0

)

usrp

.

set_rx_gain

(

gain

,

0

)

# Set up the stream and receive buffer

st_args

=

Highmesh contains other products and information you need, so please check it out.

uhd

.

usrp

.

StreamArgs

(

"fc32"

,

"sc16"

)

st_args

.

channels

=

[

0

]

metadata

=

uhd

.

types

.

RXMetadata

()

streamer

=

usrp

.

get_rx_stream

(

st_args

)

recv_buffer

=

np

.

zeros

((

1

,

),

dtype

=

np

.

complex64

)

# Start Stream

stream_cmd

=

uhd

.

types

.

StreamCMD

(

uhd

.

types

.

StreamMode

.

start_cont

)

stream_cmd

.

stream_now

=

True

streamer

.

issue_stream_cmd

(

stream_cmd

)

# Receive Samples

samples

=

np

.

zeros

(

num_samps

,

dtype

=

np

.

complex64

)

for

i

in

range

(

num_samps

//

):

streamer

.

recv

(

recv_buffer

,

metadata

)

samples

[

i

*

:(

i

+

1

)

*

]

=

recv_buffer

[

0

]

# Stop Stream

stream_cmd

=

uhd

.

types

.

StreamCMD

(

uhd

.

types

.

StreamMode

.

stop_cont

)

streamer

.

issue_stream_cmd

(

stream_cmd

)

print

(

len

(

samples

))

print

(

samples

[

0

:

10

])

With num_samps set to 10,000 and the recv_buffer set to , the for loop will run 10 times, i.e., there will be 10 calls to streamer.recv. Note that we hard-coded recv_buffer to but you can find the maximum allowed value using streamer.get_max_num_samps(), which is often around -something. Also note that recv_buffer must be 2d because the same API is used when receiving multiple channels at once, but in our case we just received one channel, so recv_buffer[0] gave us the 1D array of samples that we wanted. You don&#;t need to understand too much about how the stream starts/stops for now, but know that there are other options besides &#;continuous&#; mode, such as receiving a specific number of samples and having the stream stop automatically. Although we don&#;t process metadata in this example code, it contains any errors that occur, among other things, which you can check by looking at metadata.error_code at each iteration of the loop, if desired (errors tend to also show up in the console itself, as a result of UHD, so don&#;t feel like you have to check for them within your Python code).

Receive Gain¶

The following list shows the gain range of the different USRPs, they all go from 0 dB to the number specified below. Note that this is not dBm, it&#;s essentially dBm combined with some unknown offset because these are not calibrated devices.

  • B200/B210/B200-mini: 76 dB

  • X310/N210 with WBX/SBX/UBX: 31.5 dB

  • X310 with TwinRX: 93 dB

  • E310/E312: 76 dB

  • N320/N321: 60 dB

You can also use the command uhd_usrp_probe in a terminal and in the RX Frontend section it will mention the gain range.

When specifying the gain, you can use the normal set_rx_gain() function which takes in the gain value in dB, but you can also use set_normalized_rx_gain() which takes in a value from 0 to 1 and automatically converts it to the range of the USRP you&#;re using. This is convenient when making an app that supports different models of USRP. The downside of using normalized gain is that you no longer have your units in dB, so if you want to increase your gain by 10 dB, for example, you now have to calculate the amount.

Automatic Gain Control¶

Some USRPs, including the B200 and E310 series, support automatic gain control (AGC) which will automatically adjust the receive gain in response to the received signal level, in an attempt to best &#;fill&#; the ADC&#;s bits. AGC can be turned on using:

usrp

.

set_rx_agc

(

True

,

0

)

# 0 for channel 0, i.e. the first channel of the USRP

If you have a USRP that does not implement an AGC, an exception will be thrown when running the line above. With AGC on, setting the gain won&#;t do anything.

Stream Arguments¶

In the full example above you&#;ll see the line st_args = uhd.usrp.StreamArgs("fc32", "sc16"). The first argument is the CPU data format, which is the data type of the samples once they are on your host computer. UHD supports the following CPU data types when using the Python API:

Stream Arg

Numpy Data Type

Description

fc64

np.complex128

Complex-valued double-precision data

fc32

np.complex64

Complex-valued single-precision data

You might see other options in documentation for the UHD C++ API, but these were never implemented within the Python API, at least at the time of this writing.

The second argument is the &#;over-the-wire&#; data format, i.e. the data type as the samples are sent over USB/Ethernet/SFP to the host. For the Python API, the options are: &#;sc16&#;, &#;sc12&#;, and &#;sc8&#;, with the 12 bit option only supported by certain USRPs. This choice is important because the connection between the USRP and host computer is often the bottleneck, so by switching from 16 bits to 8 bits you might achieve a higher rate. Also remember that many USRPs have ADCs limited to 12 or 14 bits, using &#;sc16&#; doesn&#;t mean the ADC is 16 bits.

For the channel portion of the st_args, see the Subdevice and Channels subsection below.

Contact us to discuss your requirements of USRP N Product. Our experienced sales team can help you identify the options that best suit your needs.