INSTALL.adoc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. = GPSD Installation Instructions =
  2. :title: GPSD Installation Instructions
  3. :description: Steps for installing GPSD and verifying its performance.
  4. :keywords: GPSD, GPS, installation
  5. :author: Eric S. Raymond <esr@thyrsus.com>
  6. :robots:index,follow
  7. Here are the steps for installing GPSD and verifying its performance.
  8. They assume you have GPSD available as an installable binary package,
  9. Instructions for building GPSD from source (including cross-building)
  10. are in the file "build.adoc" in the source distribution.
  11. Most of these installation instructions are generic to Linux (inc
  12. There are some special notes on installation for OS X and the Raspberry Pi
  13. near the end of this file.
  14. == Check that your GPS is live and you can get data from it ==
  15. Start by making sure you can get data from your GPS, otherwise the later
  16. steps will be very frustrating. In this command
  17. stty -F /dev/ttyXXX ispeed 4800 && cat </dev/ttyXXX
  18. replace ttyXXX with the filename of the port. This will probably be
  19. either /dev/ttyUSB0 or /dev/ttyS0. If you are on a *BSD Unix or MacOS X,
  20. replace -F with -f.
  21. When you run this command, you should see text lines beginning with $
  22. come to stdout (possibly after a short initial burst of binary
  23. garbage). If you don't see this, you may have OS-level problems with
  24. your serial support, but more likely have the wrong device. Look
  25. again.
  26. If you have trouble with the preceding step, check your cabling
  27. first. Verify that the device is connected and that its power LED
  28. (if it has one) is lit.
  29. If you seem to have some sort of serial-device problem, check that
  30. your kernel properly supports the device you are using. For GPSes
  31. using an RS-232 port (which is no longer common) you will need
  32. serial-port support compiled into your kernel. Various USB-to-serial
  33. adapter chips found in GPSes require specific drivers.
  34. Under a stock Linux kernel these will all be loaded on demand when
  35. the USB system sees the appropriate vendor/product ID combinations.
  36. See build.adoc for instructions relating to custom kernels.
  37. == Check that your system configuration will allow GPSD to work ==
  38. Ensure that device permissions will enable gpsd to read from and write
  39. to GPS devices even after it drops root privileges. If you are
  40. running Fedora Core, Ubuntu, or stock Debian you can skip this step,
  41. as the stock configuration has the right properties.
  42. gpsd requires two things: (1) that GPS devices have group read and
  43. write enabled, and (2) all of them have the same group ID as a
  44. prototypical device, typically /dev/ttyS0 under Linux or /dev/tty00
  45. under *BSD. It does not actually matter what the owning group is, as
  46. gpsd will look this up on startup. Alternatively, (3), you can set a
  47. fallback group with the gpsd-group option in case the prototype is not
  48. found: this should be the group that has write access to serial
  49. devices. On Debian and derivatives including Ubuntu this is "dialout";
  50. on Gentoo/Fedora/openSuse it is "uucp".
  51. Before dropping privileges, gpsd will ensure that it has access to
  52. devices given to it on the command line by forcing their group read
  53. and write permissions on.
  54. On a Linux with udev, check the files in /etc/udev/permissions.d to
  55. ensure that /dev/tty* devices are all created with the same group
  56. and with 0660 permissions.
  57. When gpsd drops privileges, its default is to set uid to 'nobody' and
  58. group to the owning group of the prototype device (the configure
  59. option gpsd-user=foo will cause gpsd to change to 'foo'
  60. instead).
  61. If your system has the Linux hotplug facility installed you can skip
  62. the permission-setting part; the hotplug scripts will force the
  63. permissions for you. You still have to make sure all the tty devices
  64. are in the same group.
  65. == Check your installation prerequisites ==
  66. A minimum build of GPSD can run pretty close to the metal; all it
  67. absolutely needs is the C runtime support. The test clients and
  68. various additional features have additional prerequisites:
  69. |===============================================================================
  70. |pthreads library | support for PPS timekeeping on serial GPSes
  71. |DBUS | gpsd will issue DBUS notifications
  72. |ncurses | a test client and the GPS monitor depend on this
  73. |libtinfo5 | shared low-level terminfo library (see below)
  74. |libusb-1.0.x or later | better USB device discovery
  75. |Qt + qmake | libQgpsmm depends on this
  76. |python2.x(x>=6) or 3.y(y>=2) | required for various clients and utilities
  77. |python-GI bindings | the test clients xgps and xgpsspeed, need this
  78. |pyserial | for ubxtool and zerk in direct-serial mode
  79. |===============================================================================
  80. Some ncurses packages contain the terminfo library; some break it out
  81. separately as libtinfo5 or libtinfo.
  82. == Installing gpsd ==
  83. === Install your distributions package(s) ===
  84. Up-to-date gpsd packages are generally available for Linux distributions
  85. including Debian and derivatives (including Ubuntu and Mint), Fedora and
  86. derivatives (including CentOS), openSUSE, PCLinuxOS, Mageia, Gentoo, and
  87. Slackware. In the embedded space, CeroWRT and Yocto carry GPSD. The
  88. GPSD package in the FreeBSD ports tree is also reliably up to date.
  89. Even if your distribution is not on this list, it is quite likely GPSD
  90. has already been packaged for it.
  91. Whatever distribution you are running, the name of the core GPSD
  92. package containing the service daemon is almost certainly "gpsd".
  93. However, many distributions break up GPSD into separate installable
  94. packages for the core daemon and clients; you should search your
  95. repository index for anything with gpsd as a prefix.
  96. === Install from source code ===
  97. Directions for installing from source are in the file build.adoc found
  98. in the source distribution.
  99. == How to test the software ==
  100. 1. Start gpsd. You'll need to give it as an argument a path to
  101. a serial or USB port with a GPS attached to it. Your test command
  102. should look something like this:
  103. gpsd -D 5 -N -n /dev/ttyUSB0
  104. 2. Once gpsd is running, telnet to port 2947. You should see a
  105. greeting line that's a JSON object describing GPSD's version.
  106. Now plug in your GPS (or AIS receiver, or RTCM2 receiver).
  107. 3. Type '?WATCH={"enable":true,"json":true};' to start raw and
  108. watcher modes. You should see lines beginning with '{' that are
  109. JSON objects representing reports from your GPS; these are reports
  110. in GPSD protocol.
  111. 4. Start the xgps or cgps client. Calling it with no arguments
  112. should do the right thing. You should see a display panel with
  113. position/velocity-time information, and a satellite display. The
  114. displays won't look very interesting until the GPS acquires satellite
  115. lock.
  116. 5. Have patience. If you are cold-starting a new GPS, it may take
  117. 15-20 minutes after it gets a skyview for it to download an ephemeris
  118. and begin delivering fixes.
  119. 6. A FAQ and troubleshooting instructions can be found at the GPSD
  120. project site.
  121. == Once you have verified correct operation ==
  122. 1. If you installed from a .deb under Debian or a Debian-derived
  123. system, you may need to `dpkg-reconfigure -plow gpsd' to enable the
  124. hotplug magic ("Start gpsd automatically").
  125. 2. Check out the list of supported hardware at the Hardware page on
  126. the GPSD project's website. If your GPS isn't on the list, please send
  127. us information to add a new line to the table. Directions are
  128. included on that page. We can also use updates of the latest version
  129. number known to work with hardware already supported.
  130. 3. GPSD includes gpsd.php, a PHP script, that you can use to generate
  131. a PHP status page for your GPS if you wish. (It may not be in the
  132. core package.) It should be manually copied to your HTTP document
  133. directory. The first time it's invoked, it will generate a file
  134. called 'gpsd_config.inc' in that directory containing configuration
  135. information; edit to taste.
  136. 4. There are other non-essential scripts that may be useful; these
  137. are in the contrib/ directory of the source. They may not be available
  138. in the packages available from distributions.
  139. For special instructions related to using GPSD for time service, see the
  140. GPSD Time Service HOWTO in the distribution or on the web.
  141. == Special Notes for OS X Installation ==
  142. gpsd will build, install and run on OS X (osX). The easiest way to
  143. do so is to first install the MacPorts package. Follow their install
  144. procedure at: http://www.macports.org/install.php
  145. Then use their port command to install scons. Optionally git if you
  146. want to access the development source. Optionally install libxslt and
  147. xmlto to build the documentation.
  148. --------------------------------------------------------------
  149. # port install scons
  150. # port install git
  151. # port install libxslt
  152. # port install xmlto
  153. --------------------------------------------------------------
  154. While running gpsd, or scons check, you may run out of shared memory
  155. segments. If so, you will see this error message:
  156. --------------------------------------------------------------
  157. gpsd:ERROR: shmat failed: Too many open files
  158. --------------------------------------------------------------
  159. By default OS X allows a very small number of shared segments. You
  160. can check your allowed maximum number of shared segments, then increase
  161. the maximum number, with these commands:
  162. --------------------------------------------------------------
  163. # sysctl kern.sysv.shmseg=8
  164. kern.sysv.shmseg: 32 -> 8
  165. # sysctl -a | fgrep shmseg
  166. kern.sysv.shmseg: 8
  167. # sysctl kern.sysv.shmseg=16
  168. kern.sysv.shmseg: 8 -> 16
  169. # sysctl -a | fgrep shmseg
  170. kern.sysv.shmseg: 16
  171. --------------------------------------------------------------
  172. If you are using a USB based GPS you will likely need the Prolific
  173. PL2303 driver. You can find it here:
  174. http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=229&pcid=41
  175. == Special Notes for Raspberry Pi Installation ==
  176. gpsd will build, install and run on the Raspberry Pi (RasPi) and Pi 2
  177. using Debian jessie. Other distributions based on
  178. Debian (raspbian, etc) will work fine as well. The gpsd
  179. package in Debian Wheezy is known to be flaky, be sure to update to a
  180. new version of gpsd from source.
  181. === Raspbian ===
  182. Before compiling gpsd from source, you will need to update your system
  183. as root. Switching to the latest raspbian distribution (jessie)
  184. is strongly recommended.
  185. --------------------------------------------------------------
  186. # apt-get update
  187. # apt-get dist-upgrade
  188. # rpi-update
  189. # reboot
  190. --------------------------------------------------------------
  191. --------------------------------------------------------------
  192. # apt-get install scons libncurses5-dev python-dev pps-tools
  193. # apt-get install git-core
  194. --------------------------------------------------------------
  195. Git-core is only required to build from a git repository. pps-tools is for
  196. testing PPS inputs.
  197. The rest of the installation is just as for any other source based
  198. install, as noted in the file *build.adoc* .
  199. === Other Debian derivatives (including stock) ===
  200. ==== Jessie ====
  201. --------------------------------------------------------------
  202. # apt-get install scons libncurses5-dev python-dev pps-tools
  203. # apt-get install git-core
  204. --------------------------------------------------------------
  205. Git-core is only required to build from a git repository. pps-tools is for
  206. testing PPS inputs.
  207. The rest of the installation is just as for any other source based
  208. install, as noted in the file *build.adoc* .
  209. ==== Wheezy ====
  210. Wheezy, being older, requires updating the tools for compiling
  211. and testing gpsd:
  212. You need scons at 2.3.0 or higher to build.
  213. If your scons is less than 2.3.0 you will need to get a newer scons
  214. from wheezy-backport. Partial instructions are detailed here:
  215. https://backports.debian.org/Instructions/
  216. Basically you need to add this line to /etc/apt/sources.list:
  217. --------------------------------------------------------------
  218. deb http://http.debian.net/debian wheezy-backports main
  219. --------------------------------------------------------------
  220. Then do another update:
  221. --------------------------------------------------------------
  222. apt-get update
  223. --------------------------------------------------------------
  224. Which may lead you to this error if you lack a full set of debian keys:
  225. --------------------------------------------------------------
  226. W: GPG error: http://http.debian.net wheezy-backports Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553
  227. --------------------------------------------------------------
  228. Partial but detailed instructions to fix that are here:
  229. --------------------------------------------------------------
  230. https://wiki.debian.org/SecureApt
  231. --------------------------------------------------------------
  232. Use either of the following code blocks. The first is more robust:
  233. --------------------------------------------------------------
  234. apt-get install debian-archive-keyring
  235. --------------------------------------------------------------
  236. --------------------------------------------------------------
  237. gpg --keyserver pgpkeys.mit.edu --recv 8B48AD6246925553
  238. gpg -a --export 46925553 | apt-key add -
  239. apt-get update
  240. --------------------------------------------------------------
  241. You can now install scons from the wheezy-backports repository:
  242. --------------------------------------------------------------
  243. apt-get -t wheezy-backports install scons
  244. --------------------------------------------------------------
  245. and other tools:
  246. --------------------------------------------------------------
  247. # apt-get install scons libncurses5-dev python-dev pps-tools
  248. # apt-get install git-core
  249. --------------------------------------------------------------
  250. Git-core is only required to build from a git repository. pps-tools is for
  251. testing PPS inputs.
  252. The rest of the installation is just as for any other source based
  253. install, as noted in the file *build.adoc* .
  254. === Other Raspberry Pi tips ===
  255. Any USB connected GPS that is known to work with gpsd will work fine on
  256. the RasPi. No special instructions apply.
  257. A very popular option is to install the AdaFruit Ultimate GPS HAT. With
  258. this GPS you also get a good 1PPS signal. This works as any other GPS
  259. with gpsd, but there are two things to note. The GPS takes over the
  260. serial console: /dev/ttyAMA0. The PPS signal will be on GPIO Pin #4.
  261. Only three specific changes need to be made to make the HAT work. First
  262. in the file /boot/cmdline.txt, remove this part "console=ttyAMA0,115200
  263. kgdboc=ttyAMA0,115200)". That frees the serial port from console use so
  264. the GPS can use it.
  265. Second you need to tell the boot process to load the pps_gpio module
  266. and attach /dev/pps0 to GPIO pin 4. Do that by adding this line
  267. to the bottom of /boot/config.txt: dtoverlay=pps-gpio,gpiopin=4
  268. Reboot so those changes take effect.
  269. Run gpsd like this:
  270. --------------------------------------------------------------
  271. ~ # gpsd -D 5 -N -n /dev/ttyAMA0 /dev/pps0
  272. --------------------------------------------------------------
  273. If you are on the RasPi with gpsd version 3.17, or above, /dev/pps0 can
  274. be autodetected. and used for PPS if available.
  275. gpsd 3.17 and up only:
  276. --------------------------------------------------------------
  277. ~ # gpsd -D 5 -N -n /dev/ttyAMA0
  278. --------------------------------------------------------------
  279. You can verify gpsd is using the PPS by running ntpshmmon:
  280. --------------------------------------------------------------
  281. ~ # ntpshmmon
  282. # Name Seen@ Clock Real L Prec
  283. sample NTP0 1461619703.641899335 1461619703.445224418 1461619703.000000000 0 -1
  284. sample NTP2 1461619703.642203397 1461619702.999262204 1461619703.000000000 0 -20
  285. sample NTP0 1461619704.142097363 1461619703.445224418 1461619703.000000000 0 -1
  286. sample NTP2 1461619704.142204134 1461619703.999258157 1461619704.000000000 0 -20
  287. --------------------------------------------------------------
  288. If you do not see NTP2 then you misconfigured the pps_gpio driver.
  289. The serial time is provided to ntpd on NTP0, the PPS time is on NTP2, not
  290. on NTP1 like described earlier. So your ntp.conf will need to be adjusted
  291. from:
  292. --------------------------------------------------------------
  293. # GPS PPS reference (NTP1)
  294. server 127.127.28.1 prefer
  295. fudge 127.127.28.1 refid PPS
  296. --------------------------------------------------------------
  297. To:
  298. --------------------------------------------------------------
  299. # GPS PPS reference (NTP2)
  300. server 127.127.28.2 prefer
  301. fudge 127.127.28.2 refid PPS
  302. --------------------------------------------------------------
  303. Now proceed as for any other operating system to use gpsd.
  304. Be sure to validate that your PPS signal is not offset by the pulse
  305. width. That would mean gpsd is using the wrong edge.
  306. Detailed instructions are available from their web site:
  307. https://learn.adafruit.com/adafruit-ultimate-gps-hat-for-raspberry-pi/
  308. You will need to dig deeper to make the PPS work, here is a good reference:
  309. http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html
  310. == Special Notes for FreeBSD Installation ==
  311. gpsd will build, install and run on FreeBSD.
  312. Use their pkg command to install scons, and optionally git if you
  313. want to access the development source.
  314. --------------------------------------------------------------
  315. # pkg install scons
  316. # pkg install git
  317. # git clone https://gitlab.com/gpsd/gpsd.git
  318. # cd gpsd
  319. # scons --config=force && scons install
  320. --------------------------------------------------------------
  321. == Special Notes for NetBSD 8.1 Installation ==
  322. gpsd will build, install and run on NetBSD.
  323. Use their pkg_add command to install pkgin. Then use pkgin to
  324. install the required tools.
  325. --------------------------------------------------------------
  326. # export PKG_PATH=\
  327. "http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/8.1/All"
  328. # pkg_add -v pkgin
  329. # echo http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/8.1/All > \
  330. /usr/pkg/etc/pkgin/repositories.conf
  331. # pkgin update
  332. # pkgin install python37 py37-curses
  333. # ln -s /usr/pkg/bin/python3.7 /usr/pkg/bin/python
  334. # ln -s /usr/pkg/bin/python3.7 /usr/pkg/bin/python3
  335. # pkgin install py37-scons
  336. # pkgin install ncurses
  337. # pkgin install openssl mozilla-rootcerts
  338. # mozilla-rootcerts install
  339. # pkgin install git
  340. # git clone https://gitlab.com/gpsd/gpsd.git
  341. # cd gpsd
  342. # scons --config=force && scons install
  343. --------------------------------------------------------------
  344. == Special Notes for CentOS 7 Installation ==
  345. gpsd currently will build, install and run on CentOS 7.
  346. Install the gcc compiler and tools. Install EPEL.
  347. Note: there is no EPEL for i386.
  348. Use the yum command to install git if you
  349. want to access the development source.
  350. --------------------------------------------------------------
  351. # yum group install "Development Tools"
  352. # yum install git
  353. # yum install \
  354. https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  355. # yum install scons
  356. # yum install python-devel
  357. # yum install ncurses-devel
  358. # yum install pps-tools-devel
  359. # git clone https://gitlab.com/gpsd/gpsd.git
  360. # cd gpsd
  361. # scons
  362. --------------------------------------------------------------