INSTALL.adoc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. = GPSD Installation Instructions
  2. :author: Eric S. Raymond
  3. :date: 24 August 2021
  4. :description: Steps for installing GPSD and verifying its performance.
  5. :docinfodir: www
  6. :email: <esr@thyrsus.com>
  7. :keywords: GPSD, GPS, installation
  8. :robots: index,follow
  9. :sectlinks:
  10. :toc: macro
  11. include::www/inc-menu.adoc[]
  12. Here are the steps for installing GPSD and verifying its performance.
  13. They assume you have GPSD available as an installable binary package.
  14. Most of these installation instructions are generic to POSIX.
  15. Instructions for building GPSD from source (including cross-building), and
  16. some special notes on installation on *BSD, WSL, OS X, macOS, and the
  17. Raspberry Pi are in the file "build.adoc" in the source distribution.
  18. == Check that your GPS is live and you can get data from it
  19. Start by making sure you can get data from your GPS, otherwise the later
  20. steps will be very frustrating. In this command:
  21. stty -F /dev/ttyXXX ispeed 4800 && cat </dev/ttyXXX
  22. replace ttyXXX with the filename of the port. This will probably be
  23. either /dev/ttyUSB0 or /dev/ttyS0. If you are on a *BSD Unix or MacOS X,
  24. replace -F with -f.
  25. When you run this command, you should see text lines beginning with $
  26. come to stdout (possibly after a short initial burst of binary
  27. garbage). If you don't see this, you may have OS-level problems with
  28. your serial support, but more likely have the wrong device. Look
  29. again.
  30. If you have trouble with the preceding step, check your cabling
  31. first. Verify that the device is connected and that its power LED
  32. (if it has one) is lit.
  33. If you seem to have some sort of serial-device problem, check that
  34. your kernel properly supports the device you are using. For GPSes
  35. using an RS-232 port (which is no longer common) you will need
  36. serial-port support compiled into your kernel. Various USB-to-serial
  37. adapter chips found in GPSes require specific drivers.
  38. Under a stock Linux kernel these will all be loaded on demand when
  39. the USB system sees the appropriate vendor/product ID combinations.
  40. See build.adoc for instructions relating to custom kernels.
  41. == Check that your system configuration will allow GPSD to work
  42. Ensure that device permissions will enable gpsd to read from and write
  43. to GPS devices even after it drops root privileges. If you are
  44. running Fedora Core, Ubuntu, or stock Debian you can skip this step,
  45. as the stock configuration has the right properties.
  46. gpsd requires two things: (1) that GPS devices have group read and
  47. write enabled, and (2) all of them have the same group ID as a
  48. prototypical device, typically /dev/ttyS0 under Linux or /dev/tty00
  49. under *BSD. It does not actually matter what the owning group is, as
  50. gpsd will look this up on startup. Alternatively, (3), you can set a
  51. fallback group with the gpsd-group option in case the prototype is not
  52. found: this should be the group that has write access to serial
  53. devices. On Debian and derivatives including Ubuntu this is "dialout";
  54. on Gentoo/Fedora/openSuse it is "uucp".
  55. Before dropping privileges, gpsd will ensure that it has access to
  56. devices given to it on the command line by forcing their group read
  57. and write permissions on.
  58. On a Linux with udev, check the files in /etc/udev/permissions.d to
  59. ensure that /dev/tty* devices are all created with the same group
  60. and with 0660 permissions.
  61. When gpsd drops privileges, its default is to set uid to 'nobody' and
  62. group to the owning group of the prototype device (the configure
  63. option gpsd-user=foo will cause gpsd to change to 'foo'
  64. instead).
  65. If your system has the Linux hotplug facility installed you can skip
  66. the permission-setting part; the hotplug scripts will force the
  67. permissions for you. You still have to make sure all the tty devices
  68. are in the same group.
  69. == Check your installation prerequisites
  70. A minimum build of GPSD can run pretty close to the metal; all it
  71. absolutely needs is the C runtime support. The test clients and
  72. various additional features have additional prerequisites:
  73. |===============================================================================
  74. |asciidoctor | to build the documentation and www
  75. |dbus | gpsd will issue DBUS notifications
  76. |gnuplot | to plot gpsprof output.
  77. |GTK | for python-GI
  78. |libtinfo5 | low-level terminfo library (see below)
  79. |libusb-1.0.x or later | for older Garmin USB devices
  80. |ncurses | for cgps and gpsmon clients
  81. |pps-tools | for PPS time keeping
  82. |PyGObject | for xps and xgpsspeed clients (see below)
  83. |pyserial | for ubxtool and zerk in direct-serial mode
  84. |python2.x(x>=6) or 3.y(y>=2) | required for various clients and utilities
  85. |python-cairo | for python-GI
  86. |Qt | libQgpsmm depends on this
  87. |===============================================================================
  88. Some ncurses packages contain the terminfo library; some break it out
  89. separately as libtinfo5 or libtinfo.
  90. The PyGObject package goes by several names, and is split up into sub
  91. packages different ways, depending on the distribution. Sometimes
  92. python-gi, python-gobject, python-cairo, etc. The packages also need
  93. the underlying system libraries (GTK, GLib, etc.)
  94. The asynchronous python module (gps/aiogps.py) and its example client
  95. (example_aiogps.py) require Python 3.6+.
  96. See below for more specific module requirements in the individual
  97. distribution instructions.
  98. == Installing gpsd
  99. Before installing gpsd on your system, make sure that all parts of any
  100. previous installation have been removed. Do not mix gpsd parts from
  101. different sources. The gpsd clients and the server must be of the same
  102. version.
  103. === Install your distributions package(s)
  104. Up-to-date gpsd packages are generally available for Linux distributions
  105. including Debian and derivatives (including Ubuntu and Mint), Fedora and
  106. derivatives (including CentOS), openSUSE, PCLinuxOS, Mageia, Gentoo, and
  107. Slackware. In the embedded space, CeroWRT and Yocto carry GPSD. The
  108. GPSD package in the FreeBSD ports tree is also reliably up to date.
  109. Even if your distribution is not on this list, it is quite likely GPSD
  110. has already been packaged for it.
  111. Whatever distribution you are running, the name of the core GPSD
  112. package containing the service daemon is almost certainly "gpsd".
  113. However, many distributions break up GPSD into separate installable
  114. packages for the core daemon and clients; you should search your
  115. repository index for anything with gpsd as a prefix.
  116. == How to test the software
  117. 1. You should start gpsd while running as root. Starting as a normal
  118. user will cause some loss of functionality. Starting with sudo will cause
  119. a different loss of functionality.
  120. 2. Start gpsd. You'll need to give it as an argument a path to
  121. a serial or USB port with a GPS attached to it. Your test command
  122. should look something like this:
  123. gpsd -D 5 -N -n /dev/ttyUSB0
  124. 3. Once gpsd is running, telnet to port 2947. You should see a
  125. greeting line that's a JSON object describing GPSD's version.
  126. Now plug in your GPS (or AIS receiver, or RTCM2 receiver).
  127. 4. Type '?WATCH={"enable":true,"json":true};' to start raw and
  128. watcher modes. You should see lines beginning with '{' that are
  129. JSON objects representing reports from your GPS; these are reports
  130. in GPSD protocol.
  131. 5. Start the xgps or cgps client. Calling it with no arguments
  132. should do the right thing. You should see a display panel with
  133. position/velocity-time information, and a satellite display. The
  134. displays won't look very interesting until the GPS acquires satellite
  135. lock.
  136. 6. Have patience. If you are cold-starting a new GPS, it may take 15-20
  137. minutes after it gets a good skyview for it to download an ephemeris
  138. for each satellites in view, and the current almanac. Only then can it
  139. deliver the best quality fixes.
  140. 7. A FAQ and troubleshooting instructions can be found at the GPSD
  141. project site.
  142. == Once you have verified correct operation
  143. 1. If you installed from a '.deb' package under Debian or a
  144. Debian-derived system, you may need to `dpkg-reconfigure -plow gpsd' to
  145. enable the hotplug magic ("Start gpsd automatically").
  146. 2. Check out the list of supported hardware at the Hardware page on
  147. the GPSD project's website. If your GPS isn't on the list, please send
  148. us information to add a new line to the table. Directions are
  149. included on that page. We can also use updates of the latest version
  150. number known to work with hardware already supported.
  151. 3. GPSD includes gpsd.php, a PHP script, that you can use to generate
  152. a PHP status page for your GPS if you wish. (It may not be in the
  153. core package.) It should be manually copied to your HTTP document
  154. directory. The first time it's invoked, it will generate a file
  155. called 'gpsd_config.inc' in that directory containing configuration
  156. information; edit to taste.
  157. 4. There are other non-essential scripts that may be useful; these
  158. are in the contrib/ directory of the source. They may not be available
  159. in the packages available from distributions.
  160. For special instructions related to using GPSD for time service, see the
  161. GPSD Time Service HOWTO in the distribution or on the web.
  162. == Raspberry Pi tips
  163. Any USB connected GPS that is known to work with gpsd will work fine on
  164. the RasPi. No special instructions apply.
  165. A very popular option is to install the AdaFruit Ultimate GPS HAT. With
  166. this GPS you also get a good 1PPS signal. This works as any other GPS
  167. with gpsd, but there are two things to note. The GPS takes over the
  168. serial console: /dev/ttyAMA0. The PPS signal will be on GPIO Pin #4.
  169. Only three specific changes need to be made to make the HAT work. First
  170. in the file /boot/cmdline.txt, remove this part "console=ttyAMA0,115200
  171. kgdboc=ttyAMA0,115200". That frees the serial port from console use so
  172. the GPS can use it.
  173. Second you need to tell the boot process to load the pps_gpio module
  174. and attach /dev/pps0 to GPIO pin 4. Do that by adding this line
  175. to the bottom of /boot/config.txt: dtoverlay=pps-gpio,gpiopin=4
  176. Reboot so those changes take effect.
  177. Run gpsd like this:
  178. --------------------------------------------------------------
  179. ~ # gpsd -D 5 -N -n /dev/ttyAMA0 /dev/pps0
  180. --------------------------------------------------------------
  181. If you are on the RasPi with gpsd version 3.17, or above, /dev/pps0 can
  182. be autodetected, and used for PPS if available.
  183. gpsd 3.17 and up only:
  184. --------------------------------------------------------------
  185. ~ # gpsd -D 5 -N -n /dev/ttyAMA0
  186. --------------------------------------------------------------
  187. You can verify gpsd is using the PPS by running ntpshmmon:
  188. --------------------------------------------------------------
  189. ~ # ntpshmmon
  190. # Name Seen@ Clock Real L Prec
  191. sample NTP0 1461619703.641899335 1461619703.445224418 1461619703.000000000 0 -1
  192. sample NTP2 1461619703.642203397 1461619702.999262204 1461619703.000000000 0 -20
  193. sample NTP0 1461619704.142097363 1461619703.445224418 1461619703.000000000 0 -1
  194. sample NTP2 1461619704.142204134 1461619703.999258157 1461619704.000000000 0 -20
  195. --------------------------------------------------------------
  196. If you do not see NTP2 then you misconfigured the pps_gpio driver.
  197. The serial time is provided to ntpd on NTP0, the PPS time is on NTP2, not
  198. on NTP1 like described earlier. So your ntp.conf will need to be adjusted
  199. from:
  200. --------------------------------------------------------------
  201. # GPS PPS reference (NTP1)
  202. server 127.127.28.1 prefer
  203. fudge 127.127.28.1 refid PPS
  204. --------------------------------------------------------------
  205. To:
  206. --------------------------------------------------------------
  207. # GPS PPS reference (NTP2)
  208. server 127.127.28.2 prefer
  209. fudge 127.127.28.2 refid PPS
  210. --------------------------------------------------------------
  211. Now proceed as for any other operating system to use gpsd.
  212. Be sure to validate that your PPS signal is not offset by the pulse
  213. width. That would mean gpsd is using the wrong edge.
  214. Detailed instructions are available from their website:
  215. https://learn.adafruit.com/adafruit-ultimate-gps-hat-for-raspberry-pi/
  216. You will need to dig deeper to make the PPS work, here is a good reference:
  217. http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html
  218. == Special Notes for Windows
  219. Only Windows Subsystem for Linux 1 provides a reasonable means
  220. of running gpsd at this time. WSL2 lacks a GUI, USB and serial
  221. support making it unsuitable at this time.
  222. === About WSL 1
  223. WSL 1 is a component of Microsoft
  224. Windows that implements an alternate kernel. Linux
  225. distributions, notably Alpine, Debian, Kali, OpenSUSE, and
  226. Ubuntu may run on top of it.
  227. There are some issues known which affect gpsd.
  228. * /dev/ttyS* nodes have a 1 indexed number, like in MS Windows.
  229. * Windows 10 may attempt to use your GPS itself.
  230. * Older pl2303 (knockoff) serial chipsets are no longer supported \
  231. in Windows 10
  232. === Installing a Linux distribution on WSL 1 or WSL 2
  233. 1. Install a Linux distribution by clicking on the `Microsoft Store` \
  234. Icon in the taskbar.
  235. 2. Click on the search icon (it is a magnifying glass).
  236. 3. Type in 'Linux' or the name of a supported distribution. (see list)
  237. 4. Click on the icon of your chosen Linux Distribution
  238. 5. Click 'Get' then click 'Install' and busy-wait.
  239. 6. Click on the start menu and scroll to your Linux distribution and \
  240. click it.
  241. 7. Follow the distribution-specific on-screen instructions to finish \
  242. installing your Linux distribution.
  243. === Recommended packages
  244. Due to current WSL limitations, it is recommended at this time that you
  245. only install the equivalent of the following packages on your distribution.
  246. ----
  247. Python
  248. SCons (preferably 3.0+)
  249. ncurses-dev (to build/run cgps and gpsmon)
  250. asciidoctor (to build the documentation)
  251. ----
  252. Optionally, the following packages might also be installed
  253. ----
  254. pyserial (for direct control of UBlox GPS and GREIS devices)
  255. gnuplot (to generate graphs of gpsprof data)
  256. libusb-dev (to possibly use crusty old Garmin GPS receivers)
  257. git (if building from the development sources)
  258. ----
  259. === Building on WSL 1 or WSL 2
  260. Follow instructions in the distro-specific section in the file
  261. *build.adoc*.