nmaas87 / gpsTime

balena enabled GPS NTP timeserver
GNU General Public License v3.0
10 stars 2 forks source link

Doesn't seem to be doing anything #1

Open eagleDiego opened 2 years ago

eagleDiego commented 2 years ago

Hello, I fiddled a bit with this and I cannot seem to be able to get to anything usable.

My board is a RPi4B and I'm using a GPS board with an u-blox NEO-6M-0-001 and UART+PPS pinout. All pins are connected with the relative GPIOs as per instructions.

I tried using the debug commands provided in the documentation but I don't get similar results to those shown:

# chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
#? PPS0                          0   3     0     -     +0ns[   +0ns] +/-    0ns
#? GPS0                          0   3     0     -     +0ns[   +0ns] +/-    0ns
#? PSM0                          0   3     0     -     +0ns[   +0ns] +/-    0ns
#? PST0                          0   3     0     -     +0ns[   +0ns] +/-    0ns

and running gpsmon -n shows something completely different

tcp://localhost:2947          JSON slave driver>
(82) {"class":"VERSION","release":"3.22","rev":"3.22","proto_major":3,"proto_minor":14}
(264) {"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyAMA0","activated":"2022-02-09T10:35:22.336Z","native":0,"bps":9600,"parity":"N","
stopbits":1,"cycle":1.00},{"class":"DEVICE","path":"/dev/pps0","driver":"PPS","activated":"2022-02-09T10:35:22.339Z"}]}
(122) {"class":"WATCH","enable":true,"json":false,"nmea":false,"raw":2,"scaled":false,"timing":false,"split24":false,"pps":true}

This is the output from the Balena Cloud logs:

09.02.22 11:32:44 (+0000)  gpsTime  method return time=1644406364.136153 sender=:1.0 -> destination=:1.774 serial=2129 reply_serial=2
09.02.22 11:32:44 (+0000)  gpsTime     object path "/org/freedesktop/systemd1/job/1101"
09.02.22 11:32:44 (+0000)  gpsTime  method return time=1644406364.136153 sender=:1.0 -> destination=:1.774 serial=2129 reply_serial=2
09.02.22 11:32:44 (+0000)  gpsTime     object path "/org/freedesktop/systemd1/job/1101"
09.02.22 11:32:45 (+0000)  gpsTime  gpsd:ERROR: can't bind to IPv6 port gpsd, Cannot assign requested address
09.02.22 11:32:46 (+0000)  gpsTime  2022-02-09T11:32:46Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
09.02.22 11:32:46 (+0000)  gpsTime  2022-02-09T11:32:46Z Initial frequency -1.000 ppm

It doesn't look like there's anything major going wrong, at least from the logs.

The GPS module has a fix, and the PPS led on the board is flashing to indicate that PPS is provided. Connecting the board with uBlox Center doesn't show any particular issue and boud rate is correct as default 9600.

I tried digging deeper in how UART ports are addressed, but from the documentation I just cannot understand if in RPi4 dev/ttyAMA0 is the right port or if it is attached to the Bluetooth module.

Has anyone else found similar issues with RPi4?

eagleDiego commented 2 years ago

After a day of fiddling (don't tell my wife) I managed to get it to work, and figured out the issue.

in balena.yml the applicationConfigVariables are completely ignored. These however contain the precious settings that disable BlueTooth and free up GPIO14 and GPIO15 for UART. It also contains the definition for the PPS pin and enables UART, so basically nothing would work without these.

I modified these values directly from Balena Cloud and in the time of a restart everything works as intended!

Now on to figuring out why the configurations are ignored... In my project gpsTime is not the only service I'm running and another service uses an applicationConfigVariables which instead of starting with BALENA_HOST starts with RESIN_HOST. I wonder if the two cannot be mixed, or if they have any difference in behaviour.

I will report if I figure out more. Hopefully this is useful to someone stuck some time.

Tissy commented 2 years ago

@eagleDiego I'm seeing the same issues, are you able to confirm what you changed in balena please to ensure the applicationConfigVariables are used correctly.

Many thanks.

eagleDiego commented 2 years ago

@Tissy I didn't manage to get Balena to read the configVariables from the YML file, so I added them manually as fleet-wide configurations in https://dashboard.balena-cloud.com/fleets/{fleet-id}/config.

Tissy commented 2 years ago

Thank you @eagleDiego, much appreciated. I think I am getting somwehere with the config. Does your fleetwide configuration look like this please? image I don't think I have the variables quite right as still getting this as an error. image