[[Include(WikiToC)]] == Basic usage == === Description === In this tutorial we'll demonstrate how to navigate from the COSMOS sandbox to a single SDR on a node and run an application to read samples from the SDR. === Prerequisites === In order to access the test bed, create a reservation and have it approved by the reservation service. Access to the resources are granted after the reservation is confirmed. Please follow the process shown on [wiki:CosmosOverview/Workflow the COSMOS work flow page] to get started. === Resources required === For this example we used one USRP 2974 SDR on [wiki:Architecture/Domains/cosmos_sb1 sandbox 1]. === Tutorial Setup === Follow the steps below to gain access to this console and set up your node with an appropriate image. 1. Sign up for a [https://cosmos-lab.org/portal-2/ COSMOS account]. 2. [GettingStarted#MakeaReservation Create a resource reservation] for sandbox 1. 3. Once reservation is approved, [wiki:GettingStarted#LogintoyourReservation login into the console]. 4. Use OMF commands to [GettingStarted#ControlResourceswithOMF load baseline-uhd.ndz image] on your resource. {{{#!shell omf load -i baseline-uhd.ndz -t sdr2-s1-lg1 }}} 1. Once the node is successfully imaged, turn it on and check the status {{{#!shell omf tell -a on -t sdr2-s1-lg1 }}} {{{#!shell omf stat -t sdr2-s1-lg1 }}} 1. After giving it some time to power up and boot, ssh to the node {{{#!shell ssh root@sdr2-s1-lg1 }}} When opening a terminal into console.sb1.cosmos-lab.org [wiki:/UserGuide/RemoteAccess/SshTunnel set up a tunnel] from localhost:5002 to sdr2-s1-lg1.sb1.cosmos-lab.org:9002. This will be used by the web app to connect to a server running on the USRP 2974(Krypton)'s host. === Experiment Execution === ==== Configure and detect the radio ==== * The USRP 2974 requires a PCIe driver to control the FPGA with the embedded PC. In the provided images, this will load automatically on boot. If it has issues, you can run it manually via {{{ systemctl restart niusrprio.service}}}. Detailed steps for driver installation and radio detection are on the [Resources/Notes/KryptonUsage Krypton usage page]. There is also a trouble shooting section at the bottom on that page to update the Krypton's internal firmware if necessary. * Run ''uhd_find_devices' and check if the X310 is detected {{{#!shell-session root@sdr2-s1-lg1:~# uhd_find_devices --args="type=x300" [INFO] [UHD] linux; GNU C++ version 7.5.0; Boost_106501; UHD_3.15.0.HEAD-0-gaea0e2de -------------------------------------------------- -- UHD Device 0 -------------------------------------------------- Device Address: serial: 3171336 fpga: HG name: product: X310 resource: RIO0 type: x300 }}} The output enumerates all the SDRs that were detected. Krypton has only one PCIe radio device of type=x300. * Use the ''uhd_usrp_probe'' command to get more details on the x300. Specifying ''resource=rio0'' ensures only the directly connected radio is probed, instead of the radios on the network. {{{#!shell-session root@sdr2-s1-lg1:~# uhd_usrp_probe --args="resource=rio0,type=x300" [INFO] [UHD] linux; GNU C++ version 7.5.0; Boost_106501; UHD_3.15.0.HEAD-0-gaea0 e2de [INFO] [X300] X300 initialization sequence... [INFO] [X300] Connecting to niusrpriorpc at localhost:5444... [INFO] [X300] Using LVBITX bitfile /usr/local/share/uhd/images/usrp_x310_fpga_HG .lvbitx [INFO] [X300] Radio 1x clock: 200 MHz [INFO] [GPS] Found an internal GPSDO: LC_XO, Firmware Rev 0.929b [INFO] [0/DmaFIFO_0] Initializing block control (NOC ID: 0xF1F0D00000000000) [INFO] [0/DmaFIFO_0] BIST passed (Throughput: 1311 MB/s) [INFO] [0/DmaFIFO_0] BIST passed (Throughput: 1303 MB/s) [INFO] [0/Radio_0] Initializing block control (NOC ID: 0x12AD100000000001) [INFO] [0/Radio_1] Initializing block control (NOC ID: 0x12AD100000000001) [INFO] [0/DDC_0] Initializing block control (NOC ID: 0xDDC0000000000000) [INFO] [0/DDC_1] Initializing block control (NOC ID: 0xDDC0000000000000) [INFO] [0/DUC_0] Initializing block control (NOC ID: 0xD0C0000000000000) [INFO] [0/DUC_1] Initializing block control (NOC ID: 0xD0C0000000000000) _____________________________________________________ / | Device: X-Series Device | _____________________________________________________ | / | | Mboard: NI-2974 | | revision: 12 | | revision_compat: 7 | | product: 31131 | | mac-addr0: 00:80:2f:26:08:92 | | mac-addr1: 00:80:2f:26:08:93 | | gateway: 192.168.10.1 | | ip-addr0: 192.168.10.2 | | subnet0: 255.255.255.0 | | ip-addr1: 192.168.20.2 | | subnet1: 255.255.255.0 | | ip-addr2: 192.168.30.2 | | subnet2: 255.255.255.0 | | ip-addr3: 192.168.40.2 | | subnet3: 255.255.255.0 | | serial: 3171336 | | FW Version: 6.0 | | FPGA Version: 36.0 | | FPGA git hash: fde2a94 | | RFNoC capable: Yes | | | | Time sources: internal, external, gpsdo | | Clock sources: internal, external, gpsdo | | Sensors: gps_gpgga, gps_gprmc, gps_time, gps_locked, gps_servo, ref_lock ed | | _____________________________________________________ | | / | | | RX Dboard: A | | | ID: UBX-TDD (0x0203) | | | Serial: 318D9DE | | | _____________________________________________________ | | | / | | | | RX Frontend: 0 | | | | Name: UBX RX | | | | Antennas: TX/RX, RX2, CAL | | | | Sensors: lo_locked | | | | Freq range: 10.000 to 6000.000 MHz | | | | Gain range PGA0: 0.0 to 31.5 step 0.5 dB | | | | Bandwidth range: 160000000.0 to 160000000.0 step 0.0 Hz | | | | Connection Type: IQ | | | | Uses LO offset: No | | | _____________________________________________________ | | | / | | | | RX Codec: A | | | | Name: ads62p48 | | | | Gain range digital: 0.0 to 6.0 step 0.5 dB | | _____________________________________________________ | | / | | | RX Dboard: B | | | ID: UBX-TDD (0x0203) | | | Serial: 318D9EF | | | _____________________________________________________ | | | / | | | | RX Frontend: 0 | | | | Name: UBX RX | | | | Antennas: TX/RX, RX2, CAL | | | | Sensors: lo_locked | | | | Freq range: 10.000 to 6000.000 MHz | | | | Gain range PGA0: 0.0 to 31.5 step 0.5 dB | | | | Bandwidth range: 160000000.0 to 160000000.0 step 0.0 Hz | | | | Connection Type: IQ | | | | Uses LO offset: No | | | _____________________________________________________ | | | / | | | | RX Codec: B | | | | Name: ads62p48 | | | | Gain range digital: 0.0 to 6.0 step 0.5 dB | | _____________________________________________________ | | / | | | TX Dboard: A | | | ID: UBX-TDD (0x0202) | | | Serial: 318D9DE | | | _____________________________________________________ | | | / | | | | TX Frontend: 0 | | | | Name: UBX TX | | | | Antennas: TX/RX, CAL | | | | Sensors: lo_locked | | | | Freq range: 10.000 to 6000.000 MHz | | | | Gain range PGA0: 0.0 to 31.5 step 0.5 dB | | | | Bandwidth range: 160000000.0 to 160000000.0 step 0.0 Hz | | | | Connection Type: QI | | | | Uses LO offset: No | | | _____________________________________________________ | | | / | | | | TX Codec: A | | | | Name: ad9146 | | | | Gain Elements: None | | _____________________________________________________ | | / | | | TX Dboard: B | | | ID: UBX-TDD (0x0202) | | | Serial: 318D9EF | | | _____________________________________________________ | | | / | | | | TX Frontend: 0 | | | | Name: UBX TX | | | | Antennas: TX/RX, CAL | | | | Sensors: lo_locked | | | | Freq range: 10.000 to 6000.000 MHz | | | | Gain range PGA0: 0.0 to 31.5 step 0.5 dB | | | | Bandwidth range: 160000000.0 to 160000000.0 step 0.0 Hz | | | | Connection Type: QI | | | | Uses LO offset: No | | | _____________________________________________________ | | | / | | | | TX Codec: B | | | | Name: ad9146 | | | | Gain Elements: None | | _____________________________________________________ | | / | | | RFNoC blocks on this device: | | | | | | * DmaFIFO_0 | | | * Radio_0 | | | * Radio_1 | | | * DDC_0 | | | * DDC_1 | | | * DUC_0 | | | * DUC_1 }}} ==== Configure and run the application ==== * Go back to SandBox1 console, download the application source code from the attachment section below and copy it to the SDR. {{{#!shell-session username@console:~$ wget https://wiki.cosmos-lab.org/raw-attachment/wiki/Tutorials/BasicUsage/spectrum_view.tar.gz username@console:~$ scp spectrum_view.tar.gz root@sdr2-s1-lg1:~/ }}} * Untar the source code. {{{#!shell-session root@sdr2-s1-lg1:~# tar -zxvf spectrum_view.tar.gz root@sdr2-s1-lg1:~# cd SPECTRUM_VIEW }}} * Please refer to the README file in SPECTRUM_VIEW directory for instructions on compiling and running the application. Before compiling install a few required libraries. {{{#!shell-session root@sdr2-s1-lg1:~/SPECTRUM_VIEW# apt update root@sdr2-s1-lg1:~/SPECTRUM_VIEW# apt-get -y install libboost-all-dev liblog4cxx-dev cmake libfftw3-dev libxml2-dev libpopt-dev libsqlite3-dev pkg-config libxml2-utils gnulib }}} * Now compile and make the websocket library. {{{#!shell-session root@sdr2-s1-lg1:~/SPECTRUM_VIEW# make websock }}} * Lastly compile the application - this will generate the executable ''app_read_sdr_samples'' that reads samples from the SDR. {{{#!shell-session root@sdr2-s1-lg1:~/SPECTRUM_VIEW# make }}} * Run the application - this will start a server that listens for commands to configure the radio and stream received spectrum samples. {{{#!shell-session root@sdr2-s1-lg1:~/SPECTRUM_VIEW# ./app_read_sdr_samples . INFO 21:17:51.808 (main.cpp:649) - Starting command server at 5180 INFO 21:17:51.808 (main.cpp:171) - Starting websock server at 9002 ..... }}} ==== Visualize spectrum samples ==== * Download the spectrum visualizer web client to your desktop. It is all in another zip file - ''spectrum_view.zip''. Unzip this folder and open ''spectrum_view.html'' in a Chrome browser. When the viewer is first opened, the page display should be similar to the following || [[Image(basic_usage_spectrum_view_1.png, width=500px)]] || * Set the localhost field to ''localhost:5002''. (Recall from the set up section to create a tunnel from localhost:5002 to sdr2-s1-lg1.sb1.cosmos-lab.org:9002 since the ''app_read_sdr_samples'' application has a websock server listening on that address:port.) Set the device type field to ''type=x300''. Click the ''connect'' button once and a "Websocket Connection" statement should be output by the application. Now click on ''make'' to create a device handle. The RF radio parameters are already populated with default values for 2.4 GHz WIFI band. To view other active spectrum bands change the RATE, FREQ, GAIN fields. || RF Parameter || value || description || || RATE || 25e6 || Sampling rate || || FREQ || 2400e6 || Center frequency || || GAIN || 30 || Receive gain || Then click on ''Submit'' to update the SDR. Click on the ''Halted'' button to begin streaming samples from the radio to the browser. This should display the spectrum if all went well. || [[Image(basic_usage_spectrum_wifi_sb1.png, width=500px)]] || ==== Troubleshooting ==== * Check the troubleshooting section in the [https://wiki.cosmos-lab.org/wiki/Resources/Notes/KryptonUsage Krypton usage page] for common errors.