Skip to content

Instantly share code, notes, and snippets.

@TravMurav
Last active February 15, 2021 16:52
Show Gist options
  • Save TravMurav/db8c8eb2e8bccf5ed46beefb0b5738d4 to your computer and use it in GitHub Desktop.
Save TravMurav/db8c8eb2e8bccf5ed46beefb0b5738d4 to your computer and use it in GitHub Desktop.

Testing GPS and memshare

It seems like most msm8916 devices need memshare service to use gps but to find devices that don't need it we want to test gps before enabling it.

Installation

For this guide you will need following packages:

libqmi modemmanager gpsd gpsd-clients bash tmux

Optionally you can install gui of your choice and foxtrotgps (I tested it with phosh and it works quite well). Edit: foxtrotgps seems to be broken lately, it couldn't get location data from gpsd last time I checked.

Testing

1. Does it even work?

You can relatively quickly spot non-working gps by running this: (You probably want to use tmux and have wifi configured): ModemManager is only required to keep qmi-proxy running and it may already be started. First qmicli command will give you CID to use in the second one.

sudo service modemmanager start
dmesg -w &
sudo qmicli -pd /dev/modem --loc-start --client-no-release-cid
sudo qmicli -pd /dev/modem --loc-follow-nmea --client-cid=2

You should start getting lots of lines starting with $. Now move your device to a window (or better - outside) and wait 15 minutes. Please note that any output from those commands may contain your location data.
If you can see $GPGSV line with changing numbers - your device can see satellites. \o/
But likely it won't: You need to enable memshare and try again. (see how to do this below)

Assuming it works you can either stop there or try to test it a bit more:

2. How good is it?

I have a hacky script that starts gpsd and feeds it with data. It automatically detects working ModemManager and enables A-GPS if possible. You must have a sim in your device to get A-GPS! (otherwise qmicli commands from above would be used and gps may be a bit less reliable)

You can do something like this:
Run ./msm_gps.sh in one tmux pane and start gpsmon in another. After some time it will get a fix and show your location.

If you want to record a track with cli, you can use something like gpspipe --nmea > my_track.nmea with gpsd script running or just pipe --loc-follow-nmea output to a file in a similar way.

If you decided to use gui:
Run ./msm_gps.sh in the terminal, optionally run gpsmon in another. Then start foxtrotgps. It will show your location on map when device will get a fix.

You can also record gpx tracks after some configuration (set gpx path and enable recording. I recommend to press split button before exit, otherwise gpx file may be corrupted)

When you managed to get a fix, it's a good opportunity to get on a walk! :D Take your mask and go outside: put your msm8916 phone into one one pocket and your real phone with some gpx recording application (e.g. osmand) into another. When you get back you can compare them with something like gpxsee (which also support reading raw nmea data)
I recomend to make sure your device got a fix near the window because gps never got fix in motion for me.

Enabling memshare for your device.

See how it's done for other devices :p
You need to add a memory region with 2mb size labeled gps_mem like there.

wcnss/venus is relocatable with 1 MiB alignment on all devices except crackling so if other devices need memshare (and the memory region works) I would expect that it looks like the a2015 change everywhere

After you added the memory node, remove -please-test-memshare from your -modem.dts(i)

-#include "arm64/qcom/msm8916-modem-please-test-memshare.dtsi"
+#include "arm64/qcom/msm8916-modem.dtsi"

If you see repeating memshare messages in dmesg after running --loc-start, your memory region may be incorrect, tell us about it on matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment