User avatar
hukuzatuna
Posts: 13
Joined: Mon Aug 19, 2013 7:06 pm
Location: Delaware

gpsd failing on boot, but starts manually

Fri Aug 23, 2013 4:06 pm

Hi all. I have a AdaFruit Ultimate GPS board wired to a USB cable. It is running on /dev/ttyUSB0. I have run "dpkg-reconfigure gpsd" and set the values correctly. I have a powered USB hub into which the GPS is connected, so it never loses its fix when the Pi is shut down.

When I reboot the Pi, and then run "cgps -s", it shows no fix and then times out and exits. If, however, I run

sudo killall gpsd
sudo /etc/init.d/gpsd start

... all becomes well with the world, "cgps -s" returns fix data, and my python navigation modules work just fine.

I'm planning to use this in an embedded application (AUV), so I'd strongly prefer it work on boot. Does anyone have any ideas? I'd like to avoid inelegant hacks like appending "sleep 15; killall gpsd ; /etc/init.d/gpsd start" to /etc/rc.local.

Cheers,
Phil

brodieh
Posts: 4
Joined: Thu Sep 05, 2013 9:25 am

Re: gpsd failing on boot, but starts manually

Thu Sep 05, 2013 9:35 am

Hi,

I spent an hour or so diagnosing the same issue and thought I'd sign up so that others don't have to spend as long on it.

In my case I noticed that, on boot, gpsd wasn't running with the appropriate command line flags, e.g.:

Code: Select all

[email protected] ~ $ ps aux | grep gps
nobody    2203  0.0  0.3   4968  1616 ?        S<s  19:25   0:00 /usr/sbin/gpsd -F /var/run/gpsd.sock
Normally when running from the command line you would specify your GPS device (/dev/ttyUSB0 etc.) but that wasn't happening on boot.

After mucking around with the init script, trying other methods of running on startup I came across a hint in the udev rule -- that the udev rule would accept parameters from systemd.

In short -- disabling USB hot plug in sudo dpkg-reconfigure gpsd (USBAUTO in /etc/default/gpsd) did the trick for me.

My Linux skills aren't great but I'm assuming this is happening as the udev rule fires before the init.d script and, when it can't find the appropriate device port etc., just launches gpsd with the default parameters (i.e. the control port). There's probably a better fix out there.

Hopefully that helps.

Cheers.

amrbekhit
Posts: 21
Joined: Wed Apr 16, 2014 11:02 am

Re: gpsd failing on boot, but starts manually

Wed Apr 16, 2014 11:10 am

I know this is quite an old post, but it shows up frequently in search results related to gpsd problems on bootup.

Here's a simpler solution than messing around with udev.

As brodieh rightly pointed out, running ps aux | grep gps shows that gpsd is not being started up with the correct paramters, despite the /etc/defaults/gpsd file being set up "correctly" via dpkg-reconfigure gpsd.

A simple way to fix that is to modify /etc/default/gpsd so that rather than the device name being placed under the DEVICES option, place it under the GPSD_OPTIONS option instead. For example, do this:

Code: Select all

# Default settings for gpsd.
# Please do not edit this file directly - use `dpkg-reconfigure gpsd' to
# change the options.
START_DAEMON="true"
GPSD_OPTIONS="/dev/ttyACM0"
DEVICES=""
USBAUTO="true"
GPSD_SOCKET="/var/run/gpsd.sock"
Now, when you reboot, gpsd should work just fine.

ve7epq
Posts: 11
Joined: Sat Dec 06, 2014 5:03 pm

Re: gpsd failing on boot, but starts manually

Sat Dec 06, 2014 5:05 pm

Fantastic solution. I was having real trouble getting Xastir to use my USB gsp. This did the trick and fixed the problem.

Thanks

Mike Donovan

bob-wallace-ri
Posts: 1
Joined: Sun Dec 28, 2014 3:15 pm

Re: gpsd failing on boot, but starts manually

Sun Dec 28, 2014 3:19 pm

Thanks for the great response. You saved me hours of digging into unknown territory.

thanks
Bob Wallace

dpenezic
Posts: 99
Joined: Sat Dec 22, 2012 2:36 pm

Re: gpsd failing on boot, but starts manually

Wed Apr 22, 2015 10:33 pm

Hi all,
just for correct information.
gpsd come with two way of starting up:
1) automatic start up on boot (START_DAEMON="true")
2) "manually" startup (START_DAEMON="false")

All issue in this thread come from badly written documentation of gpsd. One small part is missing automatically detecting GPS USB dongle with udev rule /lib/udev/gpsd.hotpluge and /lib/udev/rules.d/60-gpsd.rules which do very nice magic of detecting link to device.

So my suggestion is to use START_DAEMON="false" and enable automatic detection of USB dongles.
In that case theoretically gpsd wouldnt be start on boot , but it will start when first USB dongle is found (no meter what /dev/somnthing is). Basically if dongle is connect on boot gpsd will start on boot.

Hope that help some one to use gpsd on automatic way instead of using in in hard coded way which isnt always good decision.

Dubravko

InsideJob
Posts: 58
Joined: Sat Jul 04, 2015 3:00 pm

Re: gpsd failing on boot, but starts manually

Fri Jul 31, 2015 6:31 pm

You know why this thread show up frequently in search result? Because the problem still hasn't been fixed!

I don't have this problem with gpsd under other distros. I'm pretty sure the default permissions on /var/run/gpsd.sock are wrong for one thing. That's why all the how-tos on the web suggest you delete that file first. Then as other have said, dpkg-reconfigure doesn't seem to like /dev/ttyACM0 which happens to be where my Microsoft GPS shows up (u-blox 5). Luckily the solution above worked for me too: swap the parameters in the config file manually.

The gpsd config file under Kubuntu 14.10 looks VERY different... has comments and everything. :roll:

dpenezic
Posts: 99
Joined: Sat Dec 22, 2012 2:36 pm

Re: gpsd failing on boot, but starts manually

Fri Jul 31, 2015 8:51 pm

Hi InsideJob,

have you any suggestion, i have HW setup that work correctly for some time, how ever i am wiling to help if you have suggestion to fix that issue. On same time i have very good experience with implementing fixes to raspbian distro.

Dubravko

peterm6881
Posts: 1
Joined: Thu May 19, 2016 9:55 am

Re: gpsd failing on boot, but starts manually

Thu May 19, 2016 10:08 am

amrbekhit wrote:I know this is quite an old post, but it shows up frequently in search results related to gpsd problems on bootup.

Here's a simpler solution than messing around with udev.

As brodieh rightly pointed out, running ps aux | grep gps shows that gpsd is not being started up with the correct paramters, despite the /etc/defaults/gpsd file being set up "correctly" via dpkg-reconfigure gpsd.

A simple way to fix that is to modify /etc/default/gpsd so that rather than the device name being placed under the DEVICES option, place it under the GPSD_OPTIONS option instead. For example, do this:

Code: Select all

# Default settings for gpsd.
# Please do not edit this file directly - use `dpkg-reconfigure gpsd' to
# change the options.
START_DAEMON="true"
GPSD_OPTIONS="/dev/ttyACM0"
DEVICES=""
USBAUTO="true"
GPSD_SOCKET="/var/run/gpsd.sock"
Now, when you reboot, gpsd should work just fine.
I registered on this forum just to say amrbekhit, you are a legend sir. My U-Blox 7 ttyACM0 USB GPS is now working in Debian 8, after a few hours of head scratching cumulating in your 30 second fix. Awesome, truly awesome.

AJB2K3
Posts: 215
Joined: Sun Aug 11, 2013 3:25 pm

Re: gpsd failing on boot, but starts manually

Thu Aug 11, 2016 6:44 pm

I have tried this but it does not work.
I have to issue
sudo gpsd /dev/ttyACM0 -F /var/run/gpsd.sock/
each start
and before the gps will.
Back in the old days, we were smarter then the technology.
Nowadays technology makes us look like villages fools in front of the children!

alsecaii
Posts: 1
Joined: Sat Sep 24, 2016 3:36 pm

Re: gpsd failing on boot, but starts manually

Sat Sep 24, 2016 4:17 pm

Came across this post while trying to find a way to get gpsd to boot automatically (after finally resolving my configuration issues with gpsd by following this post: http://catb.org/gpsd/installation.html). I too could manually run the gpsd command to start it up, and then I could get programs like cgps and ntp to read form the gpsd daemon.

First check to see that your configuration file has this line set to true: /etc/default/gpsd:

Code: Select all

START_DAEMON="true"
To get gpsd to start automatically I needed to learn more about how Debian Jessie with SystemD controls start and stop scripts for the os (and this article helped a a lot: (https://blog.sleeplessbeastie.eu/2015/0 ... an-jessie/).

The basics commands to start or stop the service are:

Code: Select all

sudo service gpsd start
 sudo service gpsd stop
After starting the service you should be able to see it running with a ps:

Code: Select all

 $ ps -ef |grep gpsd
gpsd     12609     1  2 16:01 ?        00:00:00 /usr/sbin/gpsd -N -D 5 -N -n /dev/ttyUSB0
And then you should be able to run

Code: Select all

cgps -s
and show the gps data flowing.

If starting and stopping the service works as expected, then you just need to enable the service and make sure it's not 'masked'.

To enable or disable the service run:

Code: Select all

 sudo systemctl enable gpsd
 sudo systemctl disable gpsd
To check if the service is or is not enabled, you can run a command like this:

Code: Select all

systemctl is-enabled --quiet gpsd && echo "Enabled" || echo "Disabled"
Then after enabling the service you have to make sure it's also unmasked with the following command:

Code: Select all

sudo systemctl unmask gpsd
Hope that helps!

User avatar
federico.human
Posts: 11
Joined: Wed Jul 15, 2015 8:41 pm

Re: gpsd failing on boot, but starts manually

Wed Oct 05, 2016 11:30 pm

After trying everything in this thread, and still having this issue when startup, I found this beauty which did the trick:

Code: Select all

sudo ln -s /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/
Got the information from this web-site, which makes a wonderful step to step to configure NTP and GPSD:

http://www.satsignal.eu/ntp/Raspberry-P ... start.html

I really hope this helps someone!

propergol
Posts: 21
Joined: Mon Aug 15, 2016 1:39 pm

Re: gpsd failing on boot, but starts manually

Sat Oct 29, 2016 11:10 pm

InsideJob wrote:You know why this thread show up frequently in search result? Because the problem still hasn't been fixed!

I don't have this problem with gpsd under other distros. I'm pretty sure the default permissions on /var/run/gpsd.sock are wrong for one thing. That's why all the how-tos on the web suggest you delete that file first. Then as other have said, dpkg-reconfigure doesn't seem to like /dev/ttyACM0 which happens to be where my Microsoft GPS shows up (u-blox 5). Luckily the solution above worked for me too: swap the parameters in the config file manually.

The gpsd config file under Kubuntu 14.10 looks VERY different... has comments and everything. :roll:
I agree...
I have spent (take a sit...) 6 days, 7-9 hours per days to simply being able to run :
xgps :roll:

I have had to bookmark 31 webpages all over the Internet in 3 differents languages :twisted:

On this 31 bookmark, take a sit again, all of them have at least one of the multiple parameters than differs from all other with each time something that explain why.

THAT GPS THING IS A HUDGE MESS on Raspbian and since 2012 nearly each month you can find a blog that explain something deferent from all the others.

Even Adafruit (I am not using there gps products but...) states :
this does not yet work on the Pi 3 due to intense firmware/hardware changes that affected the hardware UART. Please stick to Pi 2 or 'lower' for now!
:shock: :shock: :shock:

I realy think Raspberry team should take it seriously and release some clear HOW TO on this GPS things.
I am not sure everybody is ready to spent a full week to simply get such clever thing to work.

xstrex
Posts: 1
Joined: Mon Nov 07, 2016 11:39 pm

Re: gpsd failing on boot, but starts manually

Tue Nov 08, 2016 12:02 am

I know this is a very old post, but finding it helped me get mine working.
Running gpsd -N -n -F /var/run/gpsd.sock /dev/ttyS2 from the command line worked fine, but running it from systemd failed. Checking journalctl -xe returned the following:

Code: Select all

gpsd.socket: Failed to listen on sockets: Cannot assign requested address
Failed to listen on GPS (Global Positioning System) Daemon Sockets.
-- Subject: Unit gpsd.socket has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit gpsd.socket has failed.
--
-- The result is failed.
Dependency failed for GPS (Global Positioning System) Daemon.
Until I found this: https://bugs.debian.org/cgi-bin/bugrepo ... bug=818332

Which pointed me to look at this file: /lib/systemd/system/gpsd.socket
Basically gpsd.socket is created once all of the dependencies in that file are met. In my case, I've permanently disabled IPv6, so this line ListenStream=[::1]:2947 would never be satisfied. Commenting it out, and running systemctl daemon-reload followed by systemctl start gpsd is what finally did it.

In short, be sure that every ListenStream option in the [Socket] section found in /lib/systemd/system/gpsd.socket can be fulfilled. If it can't gpsd.sock will fail.

Hope this helps anyone struggling with gpsd..

Lomax
Posts: 164
Joined: Wed May 20, 2015 9:43 pm

Re: gpsd failing on boot, but starts manually

Sun Aug 06, 2017 10:39 pm

I was battling with this recently, and someone pointed me to the startup troubleshooting section on the official GPSD website (http://catb.org/gpsd/troubleshooting.ht ... leshooting). I had already tried most of the methods mentioned in this thread with no luck, but the solution suggested by them worked for me (my emphasis):
The .deb package supplied for the Debian and Ubuntu Linux distributions launch at boot either using systemd with gpsd.socket and gpsd.service, or on older releases from the system V-like script /etc/init.d/gpsd. However, both are governed by a control file, /etc/default/gpsd. If necessary, edit the control file as root.

Please note that systemd will only start gpsd on request by clients connecting to the unix or tcp socket. In case you need gpsd to run always, you'll need to configure systemd to start it. One way would be to create /etc/systemd/system/gpsd.service with the following content:

[Unit]
Description=GPS (Global Positioning System) Daemon
Requires=gpsd.socket
# Needed with chrony SOCK refclock
# After=chronyd.service

[Service]
EnvironmentFile=-/etc/default/gpsd
EnvironmentFile=-/etc/sysconfig/gpsd
ExecStart=/usr/sbin/gpsd -N $GPSD_OPTIONS $DEVICES

[Install]
WantedBy=multi-user.target
Also=gpsd.socket

To ask systemd to reload its config run systemctl daemon-reload; systemctl reenable gpsd.service. Instead of using the EnvironmentFile(s) you could just edit the command line as necessary for your system. Don't forget to run systemctl daemon-reload after changing the file.

Let me tell you I am *shocked* to find that this confusing and unintuitive behaviour stems from SystemD...

Return to “HATs and other add-ons”