首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >rtl-sdr在运行rtl_tcp或rtl_test时出现“总线错误”崩溃。

rtl-sdr在运行rtl_tcp或rtl_test时出现“总线错误”崩溃。
EN

Stack Overflow用户
提问于 2019-02-12 19:08:17
回答 2查看 1.8K关注 0票数 3

我有一个SDR连接在一个Raspberry 3运行Kali Linux Arm64。特别提款权本身就是这个特殊的模型

问题是,每当我远程连接到rtl_tcp服务器时,它就会退出:

代码语言:javascript
复制
rtl_tcp -a 192.168.200.132
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
[R82XX] PLL not locked!
Tuned to 100000000 Hz.
listening...
Use the device argument 'rtl_tcp=192.168.200.132:1234' in OsmoSDR (gr-osmosdr) source
to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).
client accepted! 192.168.200.102 64098
Allocating 15 zero-copy buffers
Bus error

rtl_test -t进行测试很好:

代码语言:javascript
复制
rtl_test -t
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[R82XX] PLL not locked!
Sampling at 2048000 S/s.
No E4000 tuner found, aborting.

但是,用样本率进行测试会导致同样的不期望行为。

代码语言:javascript
复制
rtl_test -s 2048000
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
Allocating 15 zero-copy buffers
Bus error

如何防止这种情况发生,并使RTL-SDR正常运行?

我试过的东西

不变:

  1. 我在Kali的repos中使用了RTL-SDR,以及使用git.osmocom.org/rtl-sdr.git回购程序编译的
  2. 将交换文件大小增加到2gb-没有更改

一些变化:

rtl_test中强制同步模式不会产生错误。

代码语言:javascript
复制
rtl_test -s 2048000 -S
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in sync mode...
(Samples are being lost but not reported.)

通过在b中引入rtl_tcp标志,我可以设置缓冲区的数量,这似乎做得不多:

代码语言:javascript
复制
rtl_tcp -a 192.168.200.132 -b 1
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
[R82XX] PLL not locked!
Tuned to 100000000 Hz.
listening...
Use the device argument 'rtl_tcp=192.168.200.132:1234' in OsmoSDR (gr-osmosdr) source
to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).
client accepted!
Allocating 1 zero-copy buffers
Bus error
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-02-13 01:18:45

我仍然不知道是什么问题,但基于@jsr给我的指示,我继续删除了zerocopy代码并重新编译了rtl-sdr,它工作了。

这里有个差别。这可能是程序中的一个错误,需要解决。

代码语言:javascript
复制
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index 89ec903..61bcebc 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -1748,50 +1748,6 @@ static int _rtlsdr_alloc_async_buffers(rtlsdr_dev_t *dev)
        dev->xfer_buf = malloc(dev->xfer_buf_num * sizeof(unsigned char *));
        memset(dev->xfer_buf, 0, dev->xfer_buf_num * sizeof(unsigned char *));

-#if defined (__linux__) && LIBUSB_API_VERSION >= 0x01000105
-       fprintf(stderr, "Allocating %d zero-copy buffers\n", dev->xfer_buf_num);
-
-       dev->use_zerocopy = 1;
-       for (i = 0; i < dev->xfer_buf_num; ++i) {
-               dev->xfer_buf[i] = libusb_dev_mem_alloc(dev->devh, dev->xfer_buf_len);
-
-               if (dev->xfer_buf[i]) {
-                       /* Check if Kernel usbfs mmap() bug is present: if the
-                        * mapping is correct, the buffers point to memory that
-                        * was memset to 0 by the Kernel, otherwise, they point
-                        * to random memory. We check if the buffers are zeroed
-                        * and otherwise fall back to buffers in userspace.
-                        */
-                       if (dev->xfer_buf[i][0] || memcmp(dev->xfer_buf[i],
-                                                         dev->xfer_buf[i] + 1,
-                                                         dev->xfer_buf_len - 1)) {
-                               fprintf(stderr, "Detected Kernel usbfs mmap() "
-                                               "bug, falling back to buffers "
-                                               "in userspace\n");
-                               dev->use_zerocopy = 0;
-                               break;
-                       }
-               } else {
-                       fprintf(stderr, "Failed to allocate zero-copy "
-                                       "buffer for transfer %d\nFalling "
-                                       "back to buffers in userspace\n", i);
-                       dev->use_zerocopy = 0;
-                       break;
-               }
-       }
-
-       /* zero-copy buffer allocation failed (partially or completely)
-        * we need to free the buffers again if already allocated */
-       if (!dev->use_zerocopy) {
-               for (i = 0; i < dev->xfer_buf_num; ++i) {
-                       if (dev->xfer_buf[i])
-                               libusb_dev_mem_free(dev->devh,
-                                                   dev->xfer_buf[i],
-                                                   dev->xfer_buf_len);
-               }
-       }
-#endif
-
        /* no zero-copy available, allocate buffers in userspace */
        if (!dev->use_zerocopy) {
                for (i = 0; i < dev->xfer_buf_num; ++i) {

在重新编译之后,该程序按预期工作:

代码语言:javascript
复制
~/sandbox/rtl-sdr# rtl_tcp -a 192.168.200.132 -f 89000 -b 100
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
[R82XX] PLL not locked!
[R82XX] PLL not locked!
Tuned to 89000 Hz.
listening...
Use the device argument 'rtl_tcp=192.168.200.132:1234' in OsmoSDR (gr-osmosdr) source
to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).
client accepted!
set gain mode 1
set agc mode 0
set direct sampling 0
Disabled direct sampling mode
[R82XX] PLL not locked!
set offset tuning 0
set bias tee 0
set sample rate 1800000
[R82XX] PLL not locked!
ll+, now 1
set freq 24000000
set gain 495
ll+, now 2
set gain 495
set gain 495
set freq 106661000
ll+, now 3
ll+, now 4
ll+, now 5
ll+, now 6
票数 1
EN

Stack Overflow用户

发布于 2019-02-12 23:13:41

我不知道是否能完全回答这个问题,但我在调试USB3设备时也遇到过类似的错误。这个问题似乎出现了,不是因为USB3不受支持(它是一个USB3适配器),而是因为卡驱动程序无法分配足够的背板带宽来动态分配特定的USB管道。

我对RPi不太熟悉--你是想通过USB以太网/Wifi dongle将捕获路由出去吗?撇开USB3不说,我想知道这是否是类似的动态带宽分配问题。

--与零拷贝缓冲区代码有关的事情在一段时间前就报告过了:https://www.mail-archive.com/osmocom-sdr@lists.osmocom.org/msg01204.html从它以不同方式显示的描述中得到了报告,并应用了一种解决方法。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54657089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档