-
Notifications
You must be signed in to change notification settings - Fork 0
/
experimenting-with-rtl-sdr-on-netbsd-10.html
81 lines (76 loc) · 6.09 KB
/
experimenting-with-rtl-sdr-on-netbsd-10.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>lab3 | Experimenting with RTL-SDR on NetBSD 10</title>
<link rel="shortcut icon" type="image/png" href="./favicon.png">
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico">
<link href="https://idatum.net/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="lab3 Full Atom Feed" />
<link href="https://idatum.net/feeds/bsd.atom.xml" type="application/atom+xml" rel="alternate" title="lab3 Categories Atom Feed" />
<link rel="stylesheet" href="./theme/css/main.css" type="text/css" />
<link rel="stylesheet" href="./theme/css/pygments.css" type="text/css" />
<meta name="generator" content="Pelican" />
<meta name="description" content="" />
<meta name="author" content="@[email protected]" />
<meta name="keywords" content="NetBSD,RTL-SDR,dump1090,piaware" />
</head>
<body>
<header>
<nav style="overflow: hidden;">
<ul>
<li><a href="./">Home</a></li>
<li class="active"><a href="./category/bsd.html">BSD</a></li>
<li><a href="./category/home-automation.html">Home automation</a></li>
<li><a href="./category/sdr.html">SDR</a></li>
</ul>
</nav>
<div>
<h1><a href="./">
<image src='' class="avatar" width="50px" /><span class="site_title">lab3</span>
</a></h1></div>
<h2>case studies and observations</h2>
</div>
</header>
<div id="wrapper">
<div id="content"> <h4 class="date">Nov 26, 2023</h4>
<article class="post">
<h2 class="title">
<a href="./experimenting-with-rtl-sdr-on-netbsd-10.html" rel="bookmark" title="Permanent Link to "Experimenting with RTL-SDR on NetBSD 10"">Experimenting with RTL-SDR on NetBSD 10</a>
</h2>
<p>The goal of this experiment is to build and run <a href="https://github.com/osmocom/rtl-sdr">rtl-sdr</a> tools (specifically rtl_tcp) and <a href="https://github.com/flightaware/dump1090">dump1090</a> (aka dump1090-fa) on a Pine64 Rock64 running <a href="http://netbsd.org/releases/formal-10/NetBSD-10.0.html">NetBSD 10</a>. The repo <a href="https://github.com/idatum/rtl-sdr-bsd">rtl-sdr-bsd</a> has the patches I created.</p>
<p>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 <a href="https://github.com/merbanan/rtl_433">rtl_433</a> ISM band sensor decoding (e.g. weather station).</p>
<p>In trying to use rtl_433, I was unable to run this on NetBSD. It is related to the use of <code>rtlsdr_read_async</code>. With this rtl-sdr.patch applied, I can build rtl_tcp on the Rock64 and remotely connect a separate Linux device running <code>rtl_433 -d rtl_tcp:[rock64]</code> to use the rtl_tcp protocol. The patch adds a <code>-S</code> option to specify using <code>rtlsdr_read_sync</code> in a pthread e.g. <code>rtl_tcp -d 0 -S -a [rock64]</code>. This has been working successfully in my testing across a 5ghz WiFi bridge.</p>
<p>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 <a href="https://www.adsbexchange.com/">ADS-B Exchange</a> and <a href="https://www.flightaware.com/adsb">Piaware</a> running in Docker containers that connect remotely. This has also been successful in my testing, but I'm not clear why. It still uses <code>rtlsdr_read_async</code> but I don't see any issues until I try to terminate the process.</p>
<h4>More details</h4>
<p>To get started creating the rtl_tcp patch for rtl_433 remote connection, I first looked at the patches included with the <a href="https://pkgsrc.org/">pkgsrc</a> 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.</p>
<p>For dump1090-fa, the Github repo was tagged at v9.0.</p>
<p>To use, clone each repo and apply the patch separately for each (<code>patch -p1</code>). You need gmake for dump1090-fa and cmake for rtl-sdr.</p>
<h4>TODO</h4>
<p>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 <code>rtlsdr_read_async</code> was used unpatched. I can also similarly experiment with pthreads in other rtl-sdr tools or even rtl_433 directly.</p>
<p>Even though dump1090-fa uses <code>rtlsdr_read_async</code>, 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 <code>rtlsdr_read_async</code> and handling the fifo dequeue on the main process thread is stable on NetBSD 10.</p>
<p>I also noticed I can run rtl_adsb unpatched and there might be some learnings there as well.</p>
<p>Ultimately, from what I understand, there needs to be improvements to usb(4) on NetBSD 10 to make these RTL-SDR programs work unpatched.</p>
<div class="clear"></div>
<div class="hidden">
<br/>
<a href="./category/bsd.html" rel="tag">BSD</a>
·
<a href="./tag/netbsd.html" class="tags">NetBSD</a>
<a href="./tag/rtl-sdr.html" class="tags">RTL-SDR</a>
<a href="./tag/dump1090.html" class="tags">dump1090</a>
<a href="./tag/piaware.html" class="tags">piaware</a>
</div>
</article> <div class="clear"></div>
<footer>
<a rel="me" href="https://mastodon.sdf.org/@joelp">© 2024 mastodon.sdf.org/@joelp</a>
<br/>
<a href="https://github.com/idatum">GitHub repos</a>
·
<a href="./feeds/all.atom.xml" rel="alternate">Atom Feed</a>
</footer>
</div>
<div class="clear"></div>
</div>
</body>
</html>