Thursday, September 28, 2023

[Tech] GPS reception on Raspberry Pi 2 with RTL-SDR

(Nope, still not working yet.)

 

I have an RTL-SDR dongle and an active GPS antenna, so I'd like to attach them to my wee little Raspberry Pi 2 and try and catch some signals with them.

Since I have an RTL SDR Blog v3 dongle, the hardware isn't really that interesting.

What is interesting is the software. My little Pi is not running x64 Windows; in fact, it's running Ubuntu 22.04 Server. I'd like this data reception to be self-contained if possible, so rtl-tcp is out this round.

The RTL SDR Blog has a post about this:

https://www.rtl-sdr.com/rtl-sdr-tutorial-gps-decoding-plotting/

This is from 2017 and points to a neat project:

https://www.github.com/taroz/GNSS-SDRLIB

This repo contains a set of Windows tools and a single Linux CLI tool that doesn't build out of the box.

  1. Per `cli/linux/readme.md`, you need to edit the makefile to select your radio.
  2. You also need to remove -DSSE2_ENABLE, since that won't work on Arm.
  3. Next you need to install libfftw3-dev: `sudo apt install libfftw3-dev`
  4. There's a bug in stereo.h, where STEREO_globalDataBuffer is defined in a header, leading to extra conflicting definitions at link time. I marked it extern in the header and added it to stereo.c, which probably isn't the best place for it.
  5. There are checked-in library binaries that need to be provided for the new platform.
    1. libfec appears to live on at https://github.com/quiet/libfec and is handily installed via `sudo apt install libfec-dev`. Switch the .a file on the LIBS line out for `-lfec`.
    2. libnslstereo is not related to libnsl. I haven't yet been able to track it down, but stereo.h suggests it's just another RF front-end. Since I'm using an RTL-SDR instead, I dropped it from the OPTIONS, LIBS, and OBS lines.
    3. librtlsdr: from your local RTL-SDR build based on https://github.com/rtlsdrblog/rtl-sdr-blog, copy build/src/librtlsdr.a over src/rcv/rtlsdr/rtlsdr.lib and change LIBS+=-lrtlsdr to LIBS+=../../src/rcv/rtlsdr/rtlsdr.lib
      1. FCIB has earned it's 'F' in this repo. Holy cow.

A quick `make -j4` and now we have a binary that, when copied into the `bin` folder next to its INI file, prints:

$ ./gnss-sdrcli
GNSS-SDRLIB start!
error: rcvinit 

Yay!

Editing bin/gnss-sdrcli.ini to point to frontend/rtlsdr_L1.ini seems to be a good start. The RTL-SDR fires up, but then the program crashes. Adding some tracing shows that it's during RTL-SDR init, so maybe the headers and static lib don't match and that's breaking things.

No comments:

Post a Comment