MicroPhase / antsdr_uhd

This repo contains both the uhd host driver and firmware for microphase antsdr devices.
GNU General Public License v3.0
46 stars 30 forks source link

get_tx_rates() doesn't return correct values #46

Open andrepuschmann opened 1 year ago

andrepuschmann commented 1 year ago

Hi, I've noticed that when calling usrp->get_tx_rates(); in the application using the E200 UHD is not returning correct ranges. Interestingly, the get_rx_rates() API does seem to work fine.

[INFO] [UHD] linux; GNU C++ version 11.3.0; Boost_107400; UHD_4.1.0.0-3-gaffb1709
[INFO] [LOGGING] Fastpath logging disabled at runtime.
Making USRP object with args 'type=ant'
[INFO] [ANT] Detected Device: ANTSDR
[INFO] [ANT] Initialize CODEC control...
[INFO] [ANT] Initialize Radio control...
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[DEBUG] [AD936X] baseband bandwidth too large for current sample rate. Setting bandwidth to: 5e+07
[INFO] [ANT] Performing register loopback test...
[INFO] [ANT] Register loopback test passed
[INFO] [ANT] Performing register loopback test...
[INFO] [ANT] Register loopback test passed
[DEBUG] [AD936X] Performing CODEC loopback test...
[DEBUG] [AD936X] CODEC loopback test passed.
[DEBUG] [AD936X] Performing CODEC loopback test...
[DEBUG] [AD936X] CODEC loopback test passed.
[INFO] [ANT] Setting master clock rate selection to 'automatic'.
[INFO] [ANT] Asking for clock rate 16.000000 MHz...
[INFO] [ANT] Actually got clock rate 16.000000 MHz.
[DEBUG] [CORES] Performing timer loopback test...
[DEBUG] [CORES] Timer loopback test passed.
[DEBUG] [CORES] Performing timer loopback test...
[DEBUG] [CORES] Timer loopback test passed.
Error: setting Tx sampling rate. Tx Rate 15.36 MHz is invalid. The nearest valid value is 16.00.

Also if I remove the checks and set the desired rate with usrp->set_tx_rate(rate) it runs ok.

lone-boy commented 1 year ago

Hi, I think the problem may be that tx and rx come from the same clock, so when setting different sampling rates for two channels, you need to pay attention to the relationship between the two sampling rates. Can you tell me the sampling rate of rx when setting Tx sampling rate?

nitinvjain commented 4 months ago

@andrepuschmann and @lone-boy,

I picked up AntSDR E200 a few backs and since have been able to try out srsRAN_4G and srsRAN_Project.

I am using Ubutnu 22.04 LTS

(1.) For srsRAN_4G, I was able to run 100 RB case which sets up sampling rate to 23.04 Msps. I was able to set up srsepc, srsenb and I was able to attach to a COTS 4G mobile. It did not make effort to run same since I just had to configure enb.conf for antsdr fixed IP address and it worked beautifully.

(2.) For srsRAN_Project, I tried running gnb with configs/gnb_rf_b200_tdd_n78_20mhz.yml after starting open5GS.

**sudo gnb -c configs/gnb_rf_b200_tdd_n78_20mhz.yml

The PRACH detector will not meet the performance requirements with the configuration {Format B4, ZCZ 0, SCS 30kHz, Rx ports 1}. Lower PHY in quad executor mode.

--== srsRAN gNB (commit 50fe9623c) ==--

Connecting to AMF on 127.0.1.100:38412 Available radio types: uhd. [INFO] [UHD] linux; GNU C++ version 11.4.0; Boost_107400; UHD_4.1.0.0-0-9abe8bc8 [INFO] [LOGGING] Fastpath logging disabled at runtime. Making USRP object with args 'type=ant,addr=192.168.1.10,num_recv_frames=64,num_send_frames=64' [INFO] [ANT] Detected Device: ANTSDR [INFO] [ANT] Initialize CODEC control... [INFO] [ANT] Initialize Radio control... [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Setting master clock rate selection to 'automatic'. [INFO] [ANT] Asking for clock rate 16.000000 MHz... [INFO] [ANT] Actually got clock rate 16.000000 MHz. Error: setting Tx sampling rate. Tx Rate 23.04 MHz is invalid. The nearest valid value is 16.0. srsGNB ERROR: Unable to create radio session.**

So I commented out following check in lib/radio/uhd/radio_uhd_device.h and reran gnb with same config file:

_if (!radio_uhd_device_validate_freq_range(range, rate)) { on_error("Tx Rate {} MHz is invalid. The nearest valid value is {}.", to_MHz(rate), to_MHz(range.clip(rate))); return;_

And voila, gnb is atleast able to set Tx sample rate to 23.04 Msps but lands into bad packet issues continuously:

**sudo gnb -c configs/gnb_rf_b200_tdd_n78_20mhz.yml

The PRACH detector will not meet the performance requirements with the configuration {Format B4, ZCZ 0, SCS 30kHz, Rx ports 1}. Lower PHY in quad executor mode.

--== srsRAN gNB (commit 50fe9623c) ==--

Connecting to AMF on 127.0.1.100:38412 Available radio types: uhd. [INFO] [UHD] linux; GNU C++ version 11.4.0; Boost_107400; UHD_4.1.0.0-0-9abe8bc8 [INFO] [LOGGING] Fastpath logging disabled at runtime. Making USRP object with args 'type=ant,addr=192.168.1.10,num_recv_frames=64,num_send_frames=64' [INFO] [ANT] Detected Device: ANTSDR [INFO] [ANT] Initialize CODEC control... [INFO] [ANT] Initialize Radio control... [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Setting master clock rate selection to 'automatic'. [INFO] [ANT] Asking for clock rate 16.000000 MHz... [INFO] [ANT] Actually got clock rate 16.000000 MHz. [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] Actually got clock rate 23.040000 MHz. [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] OK [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] OK [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] OK [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] OK [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] OK [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] OK [INFO] [ANT] Asking for clock rate 23.040000 MHz... [INFO] [ANT] OK Cell pci=1, bw=20 MHz, dl_arfcn=632628 (n78), dl_freq=3489.42 MHz, dl_ssb_arfcn=632256, ul_freq=3489.42 MHz

==== gNodeB started === Type to view trace [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled**

So basically, for 4G, same sampling rate of 23.04 Msps ran w/o any issues but for 5G, this issue is coming up. I doubt if many people are using antSDR E200 for 5G, so my best bet to resolve this issue is through you folks only.

@andrepuschmann and

@lone-boy , @MicroPhase , @black-pigeon , Do you have any quick solutions to resolve this issue?

Please help.

Cheers!

Nitin

andrepuschmann commented 4 months ago

For 20MHz try to set sample rates to 30.72Msps, not 23.04. Not sure if the driver has been updated/fixed to return the correct sample rates. I needed to comment out a few lines to make it work, that's why this issue was created in the first place.

nitinvjain commented 4 months ago

For 20MHz try to set sample rates to 30.72Msps, not 23.04. Not sure if the driver has been updated/fixed to return the correct sample rates. I needed to comment out a few lines to make it work, that's why this issue was created in the first place.

Thanks Andre for your response. I missed to mention that I had also tried 30.72 MSPS but similar message and it exits. I think I will have to comment out get_tx_rate() in lib/radio/uhd/radio_uhd_device.h Is that so and try out 23.04 or 30.72 Msps. I believe that 30.72 Msps is risky since ethernet speed is only 1Gbps and 30.72 Msps is just at the boundary (30.7216 bits/samples(12 bits adc) 2(I and Q))).

[INFO] [ANT] Initialize CODEC control... [INFO] [ANT] Initialize Radio control... [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Setting master clock rate selection to 'automatic'. [INFO] [ANT] Asking for clock rate 16.000000 MHz... [INFO] [ANT] Actually got clock rate 16.000000 MHz. Error: setting Tx sampling rate. Tx Rate 30.72 MHz is invalid. The nearest valid value is 16.0. srsGNB ERROR: Unable to create radio session.

nitinvjain commented 4 months ago

Hi @lone-boy , @andrepuschmann , @MicroPhase , @black-pigeon I commented out usrp->get_txrates() and subsequent code as follows in the file : lib/radio/uhd/radio_uhd_device.h_

if (!radio_uhd_device_validate_freq_range(range, rate)) { on_error("Tx Rate {} MHz is invalid. The nearest valid value is {}.", to_MHz(rate), to_MHz(range.clip(rate))); return;

Whether I set srate in configs/gnb_rf_b200_tdd_n78_20mhz.yml as 23.04 or 30.72, I still see same error message:

Connecting to AMF on 127.0.1.100:38412 Available radio types: uhd and zmq. [INFO] [UHD] linux; GNU C++ version 11.4.0; Boost_107400; UHD_4.1.0.0-0-9abe8bc8 [INFO] [LOGGING] Fastpath logging disabled at runtime. Making USRP object with args 'type=ant,addr=192.168.1.10,num_recv_frames=64,num_send_frames=64' [INFO] [ANT] Detected Device: ANTSDR [INFO] [ANT] Initialize CODEC control... [INFO] [ANT] Initialize Radio control... [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Performing register loopback test... [INFO] [ANT] Register loopback test passed [INFO] [ANT] Setting master clock rate selection to 'automatic'. [INFO] [ANT] Asking for clock rate 16.000000 MHz... [INFO] [ANT] Actually got clock rate 16.000000 MHz. [INFO] [ANT] Asking for clock rate 30.720000 MHz... [INFO] [ANT] Actually got clock rate 30.720000 MHz. Cell pci=1, bw=20 MHz, dl_arfcn=632628 (n78), dl_freq=3489.42 MHz, dl_ssb_arfcn=632256, ul_freq=3489.42 MHz

==== gNodeB started === Type to view trace [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment [ERROR] [STREAMER] The receive packet handler caught a value exception. ValueError: bad vrt header or packet fragment Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx metadata ERROR_CODE_BAD_PACKET.Error: unhandled error in Rx meta

Please do help. This seems to be deep inside andSDR UHD driver part side. If it does work, it will be a big thing since antSDR can be used for srsRAN_Project for 5G as well. For srsRAN_4G, it does work flawlessly,

Regards