Lab Notes

Various personal weekend projects

Nov 26, 2023

Experimenting with RTL-SDR on NetBSD 10

The goal of this experiment is to build and run rtl-sdr tools (specifically rtl_tcp) and dump1090 (aka dump1090-fa) on a Pine64 Rock64 running NetBSD 10. The repo rtl-sdr-bsd has the patches I created.

My Rock64 is positioned closest to antennas I have mounted outside of my house. It has 2 RTL-SDR USB devices attached to the USB3 port, one for ADS-B and the second as a source for rtl_433 ISM band sensor decoding (e.g. weather station).

In trying to use rtl_433, I was unable to run this on NetBSD. It is related to the use of rtlsdr_read_async. With this rtl-sdr.patch applied, I can build rtl_tcp on the Rock64 and remotely connect a separate Linux device running rtl_433 -d rtl_tcp:[rock64] to use the rtl_tcp protocol. The patch adds a -S option to specify using rtlsdr_read_sync in a pthread e.g. rtl_tcp -d 0 -S -a [rock64]. This has been working successfully in my testing across a 5ghz WiFi bridge.

For ADS-B, the dump1090-fa.patch patch allows me to build dump1090-fa on the Rock64. This just patches the Makefile. Running this on the Rock64, I have both ADS-B Exchange and Piaware running in Docker containers that connect remotely. This has also been successful in my testing, but I'm not clear why. It still uses rtlsdr_read_async but I don't see any issues until I try to terminate the process.

More details

To get started creating the rtl_tcp patch for rtl_433 remote connection, I first looked at the patches included with the pkgsrc ham/rtl-sdr package. I then applied those patches to the cloned rtl-sdr Github repo (tagged at v2.0.1). I then made changes to rtl_tcp. Applying the patches from pkgsrc explains why rtl_fm is also modied in my patch.

For dump1090-fa, the Github repo was tagged at v9.0.

To use, clone each repo and apply the patch separately for each (patch -p1). You need gmake for dump1090-fa and cmake for rtl-sdr.

TODO

I chose to patch only rtl_tcp for now since I'm fine running rtl_433 on another Linux device (e.g. in Docker). I patched rtl_tcp by adding a pthread that essentially uses that thread instance how rtlsdr_read_async was used unpatched. I can also similarly experiment with pthreads in other rtl-sdr tools or even rtl_433 directly.

Even though dump1090-fa uses rtlsdr_read_async, I didn't have to patch any source to run it. I just patched the Makefile. I need to understand why having a pthread to handle rtlsdr_read_async and handling the fifo dequeue on the main process thread is stable on NetBSD 10.

I also noticed I can run rtl_adsb unpatched and there might be some learnings there as well.

Ultimately, from what I understand, there needs to be improvements to usb(4) on NetBSD 10 to make these RTL-SDR programs work unpatched.