> Just one problem: you won’t find any SDR on the market that will claim to be able to sample a wave oscillating over a billion times a second.

This was true, but not any more. You can get truly impressive “direct RF sampling” or “direct RF conversion” receivers that are more than fast enough for GPS. For example:

Xilinx RFSoc:

A nice National Instruments article:

And their referenced off-the-shelf hardware:

One might be forgiven for being a bit puzzled as to why NI thinks that direct RF conversion is cost-effective but nonetheless sells the device for $30k :) That being said, if I were prototyping a system that wanted phase-coherent wideband reception around 3 GHz and I had a proper lab and budget, I’d buy a few of these. If I were to go to production, I’d either wait for costs of a homemade board to come down a bit or see whether a traditional heterodyne receiver could do the trick.

Hmm. For military applications, if I were concerned about really advanced RF-seeking weapons pointed at me, a direct conversion receiver is probably great — there won’t be any leakage of the LO that an enemy device could try to detect.

Cool article.

Whenever I see "from scratch," I'm always curious to see how from scratch the author actually means so I'll admit I was a bit disappointed to see that the hardware was just RTL-SDR. Still, the protocol decoding was very interesting and the result is great.

> GPS was launched in 1978, which was 45 years ago at time of writing. Five billion people are currently under 40 years old, so well over half the world’s population has never existed in an environment but this.

A note based on this. While GPS was around since 1978 the signal was intentionally degraded with a process known as "selective availability" until 2000. This largely rendered GPS unusable for many many purposes, definitely useless for road navigation, it had some limited utility in areas like backcountry navigation and was definitely useful for marine navigation.

> gypsum can go from a cold start to a fix on the user’s position, and the precise time, in less than a minute of listening to the antenna

This is very impressive and outclasses what I see even commercial receivers doing today, do you have any idea how? I remember on road trips in the early 2000s I would have to sit on the side of the road and wait for the GPS receiver to get a fix (a 15-20 minute process, when it worked) before we could leave. Or, more likely, my mother would just start driving with paper maps.

Note that GPS receiver capable (i.e. not artificially limited) of providing navigation data while moving 600 m/s or higher used to be considered munition by ITAR. The amount of legalese at updated ruling [1] is well beyond what I can make sense of, to the point I don't even know if it still applies.

While we're at SDRs, ITAR is also responsible for takedown of passive radar GNU Radio module made by Kraken RF team.


A good, decently detailed look at signal processing required. I also like, which has some fantastic visuals to go along with this explanation.
Brilliant! I have no idea what the technical background of the author is but for anyone to tease apart the vast, complex, details of the GPS universe is a massive feat. Coupled with his ability to craft software to both assist his analysis and to implement the final solution, he has created a magnificent project. I've been studying GPS and worked with it professionally for a number of years and I still don't know everything about it. I'm looking forward to digging into the code. Kudos to the author!
Super impressive. Can’t agree more with the author that GPS is a stunningly clever engineering achievement.

For those interested in the story of the development of GPS, I found “GPS Declassified” by Richard Easton to be an engaging retelling.

Amazing! I also had exactly the same experience that led me to research this a few years ago, realizing that:

- GPS works even in airplane mode (while on a literal airplane) - It works without cell service, or wifi, or anything - The United States of America controls the GPS constellation, and they can (and have!) turned off GPS off certain regions at will when necessary (which has prompted other countries to launch their own GNSS constellations) - GPS satellites don't send down a location, they only send down time

I think it's a really fun exercise to do this with data you receive on your phone. Your phone has a direct link to satellite.

(side note: I recently learned the basic principles of star navigation, and while it is a completely different mechanism, it also relies very much on keeping accurate time, which I thought was a fun symmetry!)

> Have you ever noticed that your Maps app still works during a flight?

Yes, and I use that to take pictures of features below my as we fly from one place to the other.

If you have a iPhone, when you land, those pictures will be associated with the place you were when the photo was shot. This enables you to locate those curious features you happen to see.

I really love how this article is paced in real time from the first person as a learning adventure. Even down to the search terms used and the inner monologue. This is my absolute favorite kind of tutorial because you're not just being taught to fish, you're being shown how go about sourcing the parts to built your own fishing machinery.
A documentary which interviews the principals involved in the creation of GPS (The Lonely Halls Meeting) is on YouTube:

Standford has/had a course that is available online on GPS/GNSS and a lot of the nitty-gritty details:


Great project, thanks for posting it!

It just so happens I've got an RTL-SDR, a GPS receiver that outputs raw pseudoranges, and a signal splitter that lets me put the signal from one antenna into two receivers.

So if you like I can get the pseudoranges out of a commercial GPS receiver, and the raw signal from an RTL-SDR at the same time, which might help you pinpoint your last bit of location inaccuracy.

Would you be interested in that? Or do you consider this project complete?

> I’ll be starting a new job next week which isn’t as amenable to publishing side projects

What does a job have to do with publishing hobby projects?

If you really want to see all the gps-like services out there and have android, you must play with the open-source GPStest

I've been fascinated for years how badly GPS does altitude (mean-sea-level)

in the USA they had to build an augmentation system for airplanes for altitude (WAAS)

Just want to say Cody this is a super write up!
It's not entirely clear to me from the write-up, but it seems some of the problems that the author had with the "tracker" come from attempting to do carrier phase synchronization (with the Costas loop) before any kind of clock recovery.
Wow, thank you! While I had a glimpse at various parts of the madness earlier, this is the first article that actually brought it to a level where I could convince my brain to understand it end-to-end.
> Have you ever noticed that your Maps app still works during a flight?

I noticed the opposite, it always fails to locate any satellites, even when GPS is still turned on in aeroplane mode. I'm not sure why.

"Interestingly, the only thing stopping civilians from using the P code is the knowledge of the value of its chipping sequence. If the formula to generate the P code was publicly known, there’d be nothing stopping civilian GPS receivers from locking on to it, with the exact same techniques as are used for the C/A code."

I didn't finish reading the whole thing but was curious. Is there any way of brute forcing it or some other trick to get the chipping sequence to get the P code for more precise GPS?

I find it amazing that they managed to design and build all this in the 1970s when computers were only in their infancy and SDR was complete science-fiction.
This was a delightful read. Reminded me of my time working on low power FHSS radio gear. We truly take modern wireless technologies for granted!
Beautifully written, and educational. Plus very impressive technically! I wish I could upvote this more than once. Thank you!
Would like to add that I have purchased myself the SDR so that I can replicate the experiment/work done here - it seems super cool!
Anyone manage to get this working with pip in Windows? After installing the dependencies:

    Traceback (most recent call last):
      File "C:\dev\gps\gypsum-release\", line 9, in <module>
        from gypsum.receiver import GpsReceiver
     File "C:\dev\gps\gypsum-release\gypsum\", line 20, in <module>
        from gypsum.navigation_message_decoder import EmitSubframeEvent
      File "C:\dev\gps\gypsum-release\gypsum\", line 8, in <module>
        from gypsum.navigation_message_parser import (
      File "C:\dev\gps\gypsum-release\gypsum\", line 62
    SyntaxError: invalid syntax
Is it possible to trick phones with a jammer in a large area to make it look like all phones are in a specific point on Earth. Only with a jammer?
Does anyone know how the data a stored, where at, what tech etc? I can only assume that the retention policies are in decades
Does it only support the US-made GPS (NAVSTAR GPS) or other GNSS systems like Galileo as well?
Really amazing piece of work. I look forward to digging into it. Thanks for sharing.
Really nice writeup!
Now do it for the encrypted signal (the P(Y)-code)!