&
```
### Via Terminal
* On Master, run the following command to sync the master with GPS time.
```bash
gps-1588-ptp-master
```
* Initially, the application prints the current system time on terminal using `timedatectl` as shown below. It shows the sync status as no.
```bash
Local time: Mon 2023-03-20 14:36:08 UTC
Universal time: Mon 2023-03-20 14:36:08 UTC
RTC time: Thu 1970-01-01 00:04:17
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
```
* Later, it triggers the GPSD and chrony services to synchronize the system time with the GPS time. The application prints the updated chrony sources that can be verified from the output.
```bash
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#* GPS 0 4 177 17 +1922ns[ +15us] +/- 5484ns
#- NMEA 0 4 177 19 -26ms[ -26ms] +/- 101ms
^? prod-ntp-4.ntp1.ps5.cano> 0 7 0 - +0ns[ +0ns] +/- 0ns
^? prod-ntp-5.ntp4.ps5.cano> 0 7 0 - +0ns[ +0ns] +/- 0ns
^? prod-ntp-3.ntp1.ps5.cano> 0 7 0 - +0ns[ +0ns] +/- 0ns
^? pugot.canonical.com 0 7 0 - +0ns[ +0ns] +/- 0ns
^? alphyn.canonical.com 0 7 0 - +0ns[ +0ns] +/- 0ns
^? 157.245.102.2 0 7 0 - +0ns[ +0ns] +/- 0ns
^? ntp-mumbai.gombadi.com 0 7 0 - +0ns[ +0ns] +/- 0ns
^? 139.59.55.93 0 7 0 - +0ns[ +0ns] +/- 0ns
^? 144.24.146.96 0 7 0 - +0ns[ +0ns] +/- 0ns
^? ntp6.mum-in.hosts.301-mo> 0 7 0 - +0ns[ +0ns] +/- 0ns
^? ntp5.mum-in.hosts.301-mo> 0 7 0 - +0ns[ +0ns] +/- 0ns
^? 165.22.211.200 0 7 0 - +0ns[ +0ns] +/- 0ns
^? ec2-13-126-27-131.ap-sou> 0 7 0 - +0ns[ +0ns] +/- 0ns
Reference ID : 47505300 (GPS)
Stratum : 1
Ref time (UTC) : Mon Jun 05 06:58:55 2023
System time : 0.000000001 seconds slow of NTP time
Last offset : +0.000013462 seconds
RMS offset : 0.001221735 seconds
Frequency : 8.821 ppm slow
Residual freq : +0.126 ppm
Skew : 0.101 ppm
Root delay : 0.000000001 seconds
Root dispersion : 0.000031861 seconds
Update interval : 16.0 seconds
```
> ***Note***: The above output shows that Chrony uses GPS as its Reference ID.
* The sync status can be verified from the output of `timedatectl`, printed on the terminal.
```bash
Local time: Mon 2023-06-05 06:59:14 UTC
Universal time: Mon 2023-06-05 06:59:14 UTC
RTC time: Mon 2023-06-05 06:59:14
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
```
> ***Note***: If any sync failure is encountered while using the Adafruit ultimate GPS module, modify the NMEA reference source `offset` parameter mentioned in [chrony configuration](#chronycfg) section to `0.3`. For more information on chrony configurations refer [here](https://chrony-project.org/doc/3.4/chrony.conf.html)
* The application then triggers phc2sys to update the PHC time with system time.
```bash
***** Before triggering phc2sys ******
phc_ctl[1116.247]: clock time is 1679323830.780230286 or Mon Mar 20 14:50:30 2023
***** After triggering phc2sys the PHC time is updated with system time ******
phc_ctl[1121.254]: clock time is 1685948359.063594014 or Mon Jun 5 06:59:19 2023
```
* Start ptp4l utility as Master, to synchronize the slave(s) (PHC time).
* On Second KR260 Board acting as slave, run the following command to sync the slave PHC time with Master PHC time.
```bash
gps-1588-ptp-slave
```
* Initially, the application prints the current system time and PHC time on terminal using `timedatectl && phc_ctl /dev/ptp1 --get` as shown below. It shows the sync status as no.
```bash
Local time: Mon 2023-03-20 14:36:08 UTC
Universal time: Mon 2023-03-20 14:36:08 UTC
RTC time: Thu 1970-01-01 00:04:17
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
phc_ctl[2241.152]: clock time is 1679324955.989310878 or Mon Mar 20 15:09:15 2023
```
* Then, it starts the ptp4l running as slave to align the PHC time from the best master on network.
```bash
********************** Ptp4l Application is Running ***************************
*************** PHC clock Synchronized with Master node PHC clock***************
phc_ctl[2261.160]: clock time is 1685949488.747679092 or Mon Jun 5 07:18:08 2023
```
* Next, it triggers the phc2sys, to synchronize the slave system time with its PHC time. The application prints the output of `timedatectl` before and after running phc2sys to show the sync status.
```bash
Local time: Mon 2023-03-20 15:09:36 UTC
Universal time: Mon 2023-03-20 15:09:36 UTC
RTC time: Thu 1970-01-01 00:37:44
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: no
NTP service: active
RTC in local TZ: no
```
After phc2sys application starts, updated system time shows as follows:
```bash
Local time: Mon 2023-06-05 07:18:13 UTC
Universal time: Mon 2023-06-05 07:18:13 UTC
RTC time: Mon 2023-06-05 07:18:13
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
```
### Via Ubuntu GUI
* On Master, open the terminal in Ubuntu GUI and run the below command to the open GUI
```bash
gps-1588-ptp-master -gui
```
Run the application by clicking on the buttons one after other.

>***Note***: Chrony takes 2-3 mins to sync its sources and when this process is going on, the button turns white. Wait until the process is complete.
* On Slave, open the terminal in Ubuntu GUI and run the following command to the open GUI:
```bash
gps-1588-ptp-slave -gui
```
Run the application by clicking on the buttons one after other.

>***Note***: Make sure to run the slave Application, after running the Application on the master side.
## Next Steps
* [Known Issues](known-issues.md)
* [Software Architecture of the Platform](sw_arch_platform.md)
* Go back to the [KR260 SOM GPS-1588-PTP App Start Page](../gps_1588_ptp_precision_time_mgmt)
Copyright (C) 2023 Advanced Micro Devices, Inc.