pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ham/rtl-sdr troubles under NetBSD.



Hi,

I am having some trouble trying to make rtlsdr USB dongle to work properly under NetBSD. This cheap thing is a useful entry level receiver for the amateur radio 2m and 70cm band, also for comercial FM stations and air band reception.

ham/rtl-sdr package comes with the librtlsdr library and some useful utilities:


netbsd-nuc$ pkg_info -L rtl-sdr|grep bin
/usr/pkg/bin/rtl_adsb
/usr/pkg/bin/rtl_biast
/usr/pkg/bin/rtl_eeprom
/usr/pkg/bin/rtl_fm
/usr/pkg/bin/rtl_power
/usr/pkg/bin/rtl_sdr
/usr/pkg/bin/rtl_tcp
/usr/pkg/bin/rtl_test


I have tried also Debian Trixie and FreeBSD-15 just to test that the device works. It works just fine and smooth in both operating systems.

In order to make it work under regular user, I set permissions to the USB device to the wheel group I belong to:


[     2,386124] ugen0: Realtek (0x0bda) RTL2838UHIDIR (0x2838), rev 2.00/1.00, addr 3

netbsd-nuc# ls -lh /dev/ugen0.00
crw-rw----  1 root  wheel  64, 0 Sep 14  2025 /dev/ugen0.00
netbsd-nuc# ls -lh /dev/ugen0.01
crw-rw----  1 root  wheel  64, 1 Sep 14  2025 /dev/ugen0.01


First problem is when using the built in rtl_test program, I get lost samples errors at full speed 2 MHz sample rate:

netbsd-nuc# rtl_test
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...
lost at least 204 bytes
lost at least 32 bytes
lost at least 104 bytes
lost at least 88 bytes
lost at least 68 bytes
lost at least 240 bytes
lost at least 120 bytes
lost at least 68 bytes
lost at least 188 bytes
lost at least 68 bytes
lost at least 68 bytes
lost at least 68 bytes
lost at least 120 bytes
lost at least 120 bytes
lost at least 68 bytes
lost at least 68 bytes
lost at least 168 bytes
lost at least 188 bytes
^CSignal caught, exiting!
...
...

lost at least 128 bytes
lost at least 40 bytes
^CSignal caught, exiting!
lost at least 336 bytes
lost at least 136 bytes
lost at least 196 bytes
lost at least 120 bytes
lost at least 108 bytes
lost at least 188 bytes
lost at least 188 bytes
^CSignal caught, exiting!
lost at least 136 bytes
^CSignal caught, exiting!
lost at least 68 bytes
^CSignal caught, exiting!
lost at least 188 bytes
^CSignal caught, exiting!
lost at least 68 bytes
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 328
netbsd-nuc#



Reducing sample rate to 1.5 MHz it seems to work reliable. That should not be a big problem and would be acceptable, you will be able to watch a smaller portion of the RF bands:



netbsd-nuc$ rtl_test -s 1500000
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
Exact sample rate is: 1500000.014901 Hz
[R82XX] PLL not locked!
Sampling at 1500000 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...
lost at least 16 bytes
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
lost at least 148 bytes
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 3



The real problem starts when you want to use a generic SDR receiving program such as GQRX or Linrad.

GQRX is at /usr/pkgsrc/ham/gqrx/, you can install it from pkgsdr with pkgin.
Linrad can be installed from source: svn checkout https://svn.code.sf.net/p/linrad/code/trunk linrad. It is a not friendly program that needs time to get used to it.

Both programs seem to struggle when setting a new receiving frequency. GQRX is completely stuck and frozen and after 14 seconds or so, it changes frequency and waterfall works again. On the command line it shows this error every time you try to change frequency:


netbsd-nuc$ gqrx
gr-osmosdr 0.2.0.0 (0.2.0) gnuradio 3.10.12.0
built-in source types: file rtl rtl_tcp uhd hackrf rfspace soapy redpitaya
rx_nb_cc :info: set_min_output_buffer on block 10 to 32768
Resampling audio 96000 -> 48000
audio_portaudio_sink :info: /dev/audio is the chosen device using Sun AudioIO as the host
BandPlanFile is /home/ramiro/.config/gqrx/bandplan.csv
BookmarksFile is /home/ramiro/.config/gqrx/bookmarks.csv
[INFO] [UHD] NetBSD 1; GNU C++ version 12.5.0; Boost_108900; UHD_4.9.0.0-0-unknown
[ERROR] [UHD] Device discovery error: send_to: Network is unreachable [system:51 at /pbulk/work/ham/uhd/work/.buildlink/include/boost/asio/detail/reactive_socket_service.hpp:261 in function 'send_to']
audio_portaudio_sink :info: /dev/audio is the chosen device using Sun AudioIO as the host
qt.qpa.theme.gnome: dbus reply error: [ "org.freedesktop.DBus.Error.ServiceUnknown" ] "The name org.freedesktop.portal.Desktop was not provided by any .service files"
gr-osmosdr 0.2.0.0 (0.2.0) gnuradio 3.10.12.0
built-in source types: file rtl rtl_tcp uhd hackrf rfspace soapy redpitaya
Using device #0 Realtek RTL2838UHIDIR SN: 00000001
Found Rafael Micro R820T tuner
[R82XX] PLL not locked!
[R82XX] PLL not locked!
audio_portaudio_sink :info: /dev/audio is the chosen device using Sun AudioIO as the host
Exact sample rate is: 1000000,026491 Hz
[R82XX] PLL not locked!
audio_portaudio_sink :info: Latency =  0.02133, requested sampling_rate = 48000
audio_portaudio_sink :error: Requested sampling rate 48000 not achieved; using 48000 instead

audio_portaudio_sink :info: d_portaudio_buffer_size_frames = 1024
aUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUaUr82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
aUr82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
aUr82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
r82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
r82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
r82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
aUr82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
aU

Linrad seems to handle the situation a bit better: in 2 or 3 seconds it is able to change the frequency , it shows the same messages and complains with "no input" message in the meantime until it recovers. Anyway, that situation is not normal, in a good working system the frequency change is almost instant to the user.

netbsd-nuc$ ./xlinrad64
Found Rafael Micro R820T tuner
Exact sample rate is: 1000000.026491 Hz
[R82XX] PLL not locked!
[R82XX] PLL not locked!
r82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1
r82xx_read: i2c wr failed=-1 reg=00 len=1
r82xx_set_freq: failed=-1

Both program use librtlsdr and libusb to work in order to control and read the USB dongle.

I think that debugging this without having the dongle with you is impossible. Just in case you have some clues or ideas to improve the situation they will be welcome.

Regards.
Ramiro.


Home | Main Index | Thread Index | Old Index