Upstream submission of existing rtl-sdr patches

Continuing the discussion from Failed observations due to USB traffic:

Hi @PE0SAT ,

Which options are those? I’d be happy to isolate the underlying patches and submit them upstream to the Osmocom rtl-sdr project. This would also make them available to default SatNOGS installations eventually.

Sincerely,
Fabian

Here is the overview of all the options, but the main one I am using is the serial option.
This gives me the opportunity to select the specific RTL-SDR that I want to use for a function.

Usage:	rtl_sdr -f frequency_to_tune_to [Hz]
	[-s samplerate (default: 2048000 Hz)]
	[-w tuner_bandwidth (default: automatic)]
	[-d device_index or serial (default: 0)]
	[-g gain (default: 0 for auto)]
	[-p ppm_error (default: 0)]
	[-O	set RTL driver options seperated with ':', e.g. -O 'bc=30000:agc=0' ]
		f=<freqHz>            set tuner frequency
		bw=<bw_in_kHz>        set tuner bandwidth
		bc=<if_in_Hz>         set band center relative to the complex-base-band '0' frequency
		                        puts the tuner frequency onto this if frequency (default: 0)
		sb=<sideband>         set tuner sideband/mirror: 'L' or '0' for lower side band,
		                        'U' or '1' for upper side band. default for R820T/2: 'L'
		agc=<tuner_gain_mode> activates tuner agc with '1'. deactivates with '0'
		gain=<tenth_dB>       set tuner gain. 400 for 40.0 dB
		ifm=<tuner_if_mode>   set R820T/2 tuner's variable-gain-amplifier (VGA). default: 10011
		                        0: activate agc controlled from RTL2832's feedback
		                        around 0: set gain in 10th dB. 408 for +40.8 dB
		                        5000+val: set gain to val in 10th dB. 5408 for +40.8 dB
		                        10000+idx: set gain idx 0 .. 15: 10015 for maximum gain
		dagc=<rtl_agc>        set RTL2832's digital agc (after ADC). 1 to activate. 0 to deactivate
		ds=<direct_sampling>  deactivate/bypass tuner with 1
		dm=<ds_mode_thresh>   set dynamic direct threshold mode or threshold frequency:
		                        0: use I & Q; 1: use I; 2: use Q; 3: use I below threshold frequency;
		                        4: use Q below threshold frequency (=RTL-SDR v3)
		                        other values set the threshold frequency
		harm=<Nth_harmonic>   R820T/2: use Nth harmonic for frequencies above 1.76 GHz. default: 5
		vcocmin=<current>     set R820T/2 VCO current min: 0..7: higher value is more current
		vcocmax=<current>     set R820T/2 VCO current max: 0..7
		vcoalgo=<algo>        set R820T/2 VCO algorithm. 0: default. 1: with vcomax=3.9G. 2: Youssef/Carl
		Tp=<gpio_pin>         set GPIO pin for Bias T, default =0 for rtl-sdr.com compatible V3
		T=<bias_tee>          1 activates power at antenna one some dongles, e.g. rtl-sdr.com's V3
	[-b output_block_size (default: 16 * 16384)]
	[-n number of samples to read (default: 0, infinite)]
	[-S force sync output (default: async)]
	[-N no dithering (default: use dithering)]
	[-H write wave Header to file (default: off)]
	filename (a '-' dumps samples to stdout)

Also the updated SoapRTL drivers has this option and I use it when configuring the SAtNOGS client both on bare metal and within a docker container.

SATNOGS_SOAPY_RX_DEVICE="driver=rtlsdr,serial=00001220"

1 Like

One of the stations has all these SDR’s connected, one used by bare metal and two in different containers and then you need make sure by serial you configure the correct device.

Bus 001 Device 006: ID 1d50:60a1 OpenMoko, Inc. Airspy
Bus 001 Device 003: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
Bus 001 Device 002: ID 0bda:2832 Realtek Semiconductor Corp. RTL2832U DVB-T

This seems to be an easy one! The upstream rtl-sdr does already support selecting a device using its serial number with -d <string>. In librtlsdr/librtlsdr the only relevant patch as far as I can see is… e30dbd … documenting it! :smiley:

I’m already in contact with osmocom (via IRC #osmocom:libera.chat), expect to see a PR here soon: Pull Requests - rtl-sdr - Osmocom gitea

The patch we apply which resets the device after 10 seconds of bulk transfer timeout could be accepted upstream. But I doubt that they would accept the proactive reset before each initialization.

Docs patch submitted in osmocom:rtl-sdr!5.

for context:

handle-usb-bulk-transfer-timeouts.patch

always-reset-usb-device.patch

[I extracted those two patches from `rtl-sdr_0.6-1+rpt1satnogs3.debian.tar.xz` at <Welcome - openSUSE Build Service>]

Are you the author of both? I’d recommend to submit the first of those patches upstream too, yes. We would probably need to document why this patch is needed & that it is well tested.

And alternative to apply rejected patches in the deb build on obs.

Yes, I’m the author. I had done extensive stress tests and managed to find a way to cause lock-ups within a few minutes. The root cause of the timeout though is still unknown to me. I suspect it might have to do with the device itself. So, I ended up writing a couple of patches that address the symptom. The observation may still fail but hopefully it will be reset for the next observation without a need for a reboot.

2 Likes

Regarding these stress tests, I’m sure you have told them already, but I did discover that radiosonde auto rx did cause any of my rtlsdr’s to overheat and hang in a day or so. The scanning auto selects bw based on how many sections it needs to scan the range, needing testing and adjusting it to run at ~2Msps is necessary. That image did not use the patches, so it was pretty much always down.

I’d been keen to link to a patched version of librtlsdr in the auto_rx documentation!
Which repository should I be linking to, and does it have RTLSDR v4 support?

Which one ?
Osmocom GitHub - osmocom/rtl-sdr: library for turning a RTL2832 based DVB dongle into a Software DefinedReceiver; mirror from https://gitea.osmocom.org/sdr/rtl-sdr
Rtl-sdr blog (from osmocom) GitHub - rtlsdrblog/rtl-sdr-blog: Modified Osmocom drivers with enhancements for RTL-SDR Blog V3 and V4 units.
More experimental GitHub - rtlsdrblog/rtl-sdr: RTL-SDR experimental branch

When the V4 came out I tried the first two repos in my builder + Dockerfile and as expected they did work but ended up with failed observations after a while.

I see you build from another source, we probably need a fork with a branch or two for these MR’s so perhaps build from that ?
Looks like the debian package and our on OBS is using based on osmocom 0.6.0

Well, If I’d paid attention to the patches I would see that they are already in kerel’s branch.

Upstream of rtl-sdr is (and has always been) Osmocom.

Sorry for creating confusion. The sole purpose of this branch “satnogs” was to simplify reasoning in our thread here, it is supposed to be ephemeral and I won’t update it.

If you ask me which version of librtlsdr to promote? Upstream or the packages built for satnogs in OBS. :stuck_out_tongue:
Yes, the patches referenced above are not merged yet, but hopefully soon.

Since version 2.0.0 the rtl-sdr-blog dongle v4 is supported. Latest release is 2.0.1 (changelog).

[addendum: https://gitea.osmocom.org/sdr/rtl-sdr/ and https://github.com/steve-m/librtlsdr are the same. The latter has been the semi-official github mirror of the osmocom tree when git.osmocom.org didn’t exist yet]
[addendum 2: markdown hyperlink formatting is slightly broken in this wiki atm]

Two tries on this, a package built (not tested) Show home:knegge:branches:home:librespace:satnogs-unstable / rtl-sdr_bullseye - openSUSE Build Service
And one branch with the patches applied knegge/rtl-sdr: Software to turn the RTL2832U into a SDR receiver - rtl-sdr - Osmocom gitea

It can be built on my docker image build with a few changes: https://github.com/kng/satnogs-client-docker/blob/main/sa2kng/build.sh
with something like this:

ARGS+=" --build-arg RTLSDR_URL=https://gitea.osmocom.org/knegge/rtl-sdr.git"
ARGS+=" --build-arg RTLSDR_BRANCH=satnogs"
ARGS+=" --build-arg RTLSDR_VER=2.0.2+${TAG}"

Anyone up for the task testing this ? I have a system but it is not hooked up with a v4 now.

edit: Big warning, issues with library file names and it looks like it is not working.

1 Like