Librem 5 GPS/Location Tracking

Howdy,
I’ve been trying to figure out how to get location tracking working on the librem 5 in order to get puremaps to be used for navigation. However, unless I’m connected to a wifi network, it says I’m in Lake Michigan near Chicago. Which unless I’m in the matrix, is nowhere near where I’m actually at.

I read a topic posted earlier that talks about people getting within 30 feet to a mile of where they actually are, so it sounds like it somewhat works for people. Not sure why it doesn’t work for me. Any suggestions or hacks on how to get this working?

Edit: I’m using byzantium

4 Likes

Did you try the following to configure/check the GPS:
wget https://source.puri.sm/angus.ainslie/librem5-devkit-tools/-/blob/gnss/test_scripts/gps_config.py

You propably have to Install some python3 parts before gps_config executes without errors, but I am not sure which ones:

apt install python3-???
python3 gps_config.py

Set up gpsd as root

apt install gpsd-clients gpsd

vi /etc/default/gpsd
DEVICE="/dev/gnss0"

service gpsd start

run the text client and wait for getting cordinates. This will take quite some time for the first fix (60 minutes?)

cgps

2 Likes

Thank you for the instructions!
gpsd doesn’t seem to be able to read /dev/gnss0 sadly… I’ve tried changing it to be owned by the gspd user to no effect.

Here’s the error I’m getting form gpsd when I try running cgps:

Jul 25 15:51:12 librem gpsd[8956]: gpsd:ERROR: SER: device open of /dev/gnss0 failed: Permission denied - retrying read-only
Jul 25 15:51:12 librem gpsd[8956]: gpsd:ERROR: SER: read-only device open of /dev/gnss0 failed: Permission denied
Jul 25 15:51:12 librem gpsd[8956]: gpsd:ERROR: /dev/gnss0: device activation failed, freeing device.

Odly if I become the gpsd user and cat /dev/gnss0 I get output. So I’m not sure what’s going on there.

Figured out what was stopping that, apparently apparmor was blocking it. (Ironically it is the only program apparmor appears to be trying to enforce against that’s running).
So I set it to complain mode aa-complain /usr/sbin/gpsd and it’s now trying to get a fix on it’s position via cgps!
I’ll try puremaps once that finishes.

2 Likes

For getting the first fix try also to put the Librem5 in different orientations. Not only with the display upside.

I think putting it with the display to earth helped for the first fix for me, but I am not sure.

After the first fix the further ones are done in a few seconds/minutes.

1 Like

Ok, I’ve flipped the phone over. It’s still trying after 13 hours with no fix. I see 9 satellites listed, so I’m not sure why it’s taking soo long.

During the first time fixed something is downloaded through the GPS connection. But I don’t know why you don’t get your cordinates if you already have 9 satelites for some time.

May be somebody else has some tipps.

Please be so kind and point to some spec or doc about „download over GPS“. Thanks

My Ubuntu running BQ E4.5 gets a first fix in less than a minute and nothing is downloaded. I always use some app showing the states if the various sensors and then I launch the app using OSM server and my location.

It says it won’t use any of the satellites for some reason:
(started a new one that sees 5)

──────────────────Seen  5/Used  0┐
GNSS   PRN  Elev   Azim   SNR Use│
GP 10   10  xx.0  173.0   0.0  N │
GP 16   16  xx.0  209.0   0.0  N │
GP 29   29  xx.0   99.0   0.0  N │
GP 31   31  xx.0  315.0   0.0  N │
GP 32   32  xx.0   75.0   0.0  N │

Should I just set it outside for awhile? Not sure why it chooses not to use any of them with a signal to noise ratio of 0.0…

Some one from Purism can propably describe it better. It was not important for me (as normal user) to know so I don’t know the exact name of it.

I just searched the matrix channel and they (Angus for example) called it “Almanac”.

There’s an almanac and ephemeris. They descrbe the current satellite locations, they are valid for relatively short periods of time, and if not received otherwise, they are received from the satellites.

I can’t say anything about your problem, but my work unit doesn’t do GPS very well either.

Hmm ok,
This does make me wonder… Do we know if this is a hardware or software issue that makes it not work so well? I’m wondering if the librem 5 is capable of reliable navigation.

I know there’s a gps tuning section of the fund your app page. Does the gps just need more tuning to be reliable?

Is this was a real measurement (I doubt), then the signal is not usable (as in random noise). In real live you seldom find 0.0 for S/N, even when no signal available. Most probably a software error. (if unconnected antenna no satellite would be detected)

1 Like

Thanks, the required python package is python3-nmea2.

cgps starts fine now, but is this the expected output before a fix or at least some info like “Time” should be fileld in?

┌───────────────────────────────────────────┐┌──────────────────Seen  0/Used  0┐
│ Time:          n/a (0)                    ││GNSS   PRN  Elev   Azim   SNR Use│
│ Latitude:        n/a                      ││                                 │
│ Longitude:       n/a                      ││                                 │
│ Alt (HAE, MSL):        n/a,       n/a     ││                                 │
│ Speed:           n/a                      ││                                 │
│ Track (true, var):                n/a deg ││                                 │
│ Climb:           n/a                      ││                                 │
│ Status:         NO FIX (1914 secs)        ││                                 │
│ Long Err  (XDOP, EPX):  n/a ,  n/a        ││                                 │
│ Lat Err   (YDOP, EPY):  n/a ,  n/a        ││                                 │
│ Alt Err   (VDOP, EPV):  n/a ,  n/a        ││                                 │
│ 2D Err    (HDOP, CEP):  n/a ,  n/a        ││                                 │
│ 3D Err    (PDOP, SEP):  n/a ,  n/a        ││                                 │
│ Time Err  (TDOP):       n/a               ││                                 │
│ Geo Err   (GDOP):       n/a               ││                                 │
│ ECEF X, VX:              n/a    n/a       ││                                 │
│ ECEF Y, VY:              n/a    n/a       ││                                 │
│ ECEF Z, VZ:              n/a    n/a       ││                                 │
│ Speed Err (EPS):        n/a               ││                                 │
│ Track Err (EPD):        n/a               ││                                 │
│ Time offset:            n/a               ││                                 │
│ Grid Square:            n/a               ││                                 │
└───────────────────────────────────────────┘└─────────────────────────────────┘
{"class":"TPV","device":"/dev/gnss0","mode":1}
{"class":"TPV","device":"/dev/gnss0","mode":1}
{"class":"TPV","device":"/dev/gnss0","mode":1}
{"class":"TPV","device":"/dev/gnss0","mode":1}

Someone reported GPS positioning kind of working in February, via sudo cat /dev/gnss0:

When I just tried sudo cat /dev/gnss0 myself (on a Librem 5 Evergreen running byzantium), it does give NMEA-style output (including GPRMC and GPGGA NMEA sentences) which looks promising. I have not tried the gpsbabel conversion yet.

Edit: after looking more carefully at the NMEA output, maybe it is not that promising, it says there is no fix and the time that is supposed to be UTC time looks way off.

To get a fix with a GNSS receiver you need to have a good antenna connection and the GNSS module must have downloaded an almanac and the ephemerides for the satellites it is tracking. To speed up the process you can upload the almanac and ephmerides to the module , this is know as AGPS.

gnss_share can handle the AGPS portion and it also will share data with geoclue which is used by most L5 navigation software for geolocation.

You can copy the almanac and ephemeris from a phone that has a 3D fix to one that doesn’t and then have gnss_share upload it to the GNSS module.

If you don’t use AGPS the almanac and ephemeris will automatically get downloaded from the satellites. This takes at least 12 minutes and must have a clear view of the sky, preferably a window sill or outside. Once the initial navigation messages ( almanac and ephemeris https://en.wikipedia.org/wiki/GPS_signals#Navigation_message ) is downloaded it gets saved to battery backed RAM. If you are using gnss_share it will also get saved to the filesystem.

The second part of this is how well the antenna is receiving the satellites. As others have stated you can directly dump the output of the GNSS module using cat /dev/gnss0. You need to find the GSV sentences as these show the number and strength of the satellites being received ( section 11.4.4 https://www.st.com/resource/en/user_manual/dm00398983-teseoliv3-gnss-module--software-manual-stmicroelectronics.pdf ).

Initially you need to see a single satellite with a SNR of > 20 for the navigation messages to be downloaded and it must be active for more than 12 minutes. You’ll slowly see more and more satellites in the GSV messages. Once the module starts tracking satellites you will see a GSA message with satellites in it and that shows the current satellites being used for your location solution. After that you should see a GGA message that indicates a fix.

If you never see a GSV message with a SNR above 20 or a GSA message tracking satellites then it could either be a hardware problem or not enough of a view of the sky problem. The view of the sky problem can be cause by tall trees , tall buildings, metal or concrete roofs and the eaiest way is to take the L5 out into a field or some area with a full view of the sky.

If all the above fails then it may be a hardware problem. A common issue is the ground on the GNSS antenna https://puri.sm/wp-content/uploads/2021/03/22_v2.png. This part is both delicate and also must be touching the frame of the phone. On visual inspection if it is not touching the frame it can be GENTLY bent to touch it, see the dis-assembly instructions here https://puri.sm/posts/disassemble-librem-5/

11 Likes

How do I know whether I should be expecting Rev 3.1 messages or Rev 4.10 messages?

Either way though

I think I need to spend some time out in a field because I don’t seem to be getting any satellite signals sitting inside.

See how the Signal to Noise ratio is zero for all satellites listed? I believe that means that although the ephemeris says those satellites are in view, the signal is absent or NFG.

1 Like

That would explain why when I was testing this the number of satellites “in view” according to GPGSV sentences did not change when I moved the phone from the window to somewhere far away from the window. I was expecting to see fewer satellites in view, but there was no change. Probably I had never any satellite at all truly in view, the info shown was just what should be in view in theory based on the saved position and time info which are very far off.

Looks like it thinks I am in China, then I get to know which satellites would be in view it I was in China (and if the time was correct which it is not). :slight_smile:

I’ll try taking it into a field.

1 Like

Watching it for awhile it does sometimes get 2 satellites that it will say yes and have a SNR of 20-27 for me. Going to try taking it into a field. Sadly my hikes don’t seem to give it what it needs being outside.

edit: even with those two it doesn’t get a fix. I think it needs 3.