Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
subprojects/ | H | - | - | 21 | 15 | |
test/ | H | - | - | 221 | 170 | |
.clang-format | H A D | 03-Mar-2025 | 3.7 KiB | 137 | 135 | |
.clang-tidy | H A D | 30-May-2025 | 12.2 KiB | 326 | 322 | |
.gitignore | H A D | 01-Jul-2022 | 42 | 4 | 3 | |
LICENSE | H A D | 25-Aug-2016 | 11.1 KiB | 202 | 169 | |
OWNERS | H A D | 12-Mar-2024 | 1.7 KiB | 53 | 48 | |
README.md | H A D | 18-Jul-2025 | 4 KiB | 132 | 94 | |
bmc_epoch.cpp | H A D | 24-Jul-2023 | 3.8 KiB | 153 | 115 | |
bmc_epoch.hpp | H A D | 16-Aug-2024 | 3.1 KiB | 116 | 51 | |
main.cpp | H A D | 22-Jul-2024 | 956 | 39 | 22 | |
manager.cpp | H A D | 16-Aug-2024 | 5.7 KiB | 199 | 163 | |
manager.hpp | H A D | 01-Apr-2024 | 4 KiB | 139 | 51 | |
meson.build | H A D | 09-Jul-2025 | 2.5 KiB | 101 | 74 | |
meson.options | H A D | 03-Mar-2025 | 755 | 33 | 26 | |
property_change_listener.hpp | H A D | 28-Apr-2023 | 626 | 27 | 19 | |
settings.cpp | H A D | 30-Nov-2023 | 1.1 KiB | 52 | 42 | |
settings.hpp | H A D | 01-Apr-2024 | 1 KiB | 43 | 25 | |
types.hpp | H A D | 22-Jul-2024 | 669 | 24 | 14 | |
utils.cpp | H A D | 11-Apr-2023 | 2.1 KiB | 81 | 66 | |
utils.hpp | H A D | 01-Apr-2024 | 4.4 KiB | 148 | 73 | |
xyz.openbmc_project.Time.Manager.service | H A D | 26-May-2022 | 332 | 14 | 11 |
README.md
1# Introduction 2 3`phosphor-time-manager` is the time manager service that implements D-Bus 4interface `xyz/openbmc_project/Time/EpochTime.interface.yaml`. The user can get 5or set the BMC's time via this interface. 6 7## Configuration 8 9phosphor-time-manager is configured by setting `-D` flags that correspond to 10options in `phosphor-time-manager/meson.options`. The option names become C++ 11preprocessor symbols that control which code is compiled into the program. 12 13- Compile phosphor-time-manager with default options: 14 15 ```bash 16 meson setup builddir 17 meson compile -C builddir 18 ``` 19 20- Compile phosphor-time-manager with some configurable options: 21 22 ```bash 23 meson setup builddir -Dbuildtype=minsize -Dtests=false 24 meson compile -C builddir 25 ``` 26 27- Generate test coverage report: 28 29 ```bash 30 meson setup builddir -Db_coverage=true -Dtests=true 31 meson compile -C builddir 32 meson test -C builddir 33 ninja -C builddir coverage 34 ``` 35 36### General usage 37 38The service `xyz.openbmc_project.Time.Manager` provides an object on D-Bus: 39 40- /xyz/openbmc_project/time/bmc 41 42where each object implements interface `xyz.openbmc_project.Time.EpochTime`. 43 44The user can directly get or set the property `Elapsed` of the objects to get or 45set the time. For example on an authenticated session: 46 47- To get BMC's time: 48 49 ```bash 50 ### With busctl on BMC 51 busctl get-property xyz.openbmc_project.Time.Manager \ 52 /xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime Elapsed 53 54 ### With REST API on remote host 55 curl -b cjar -k https://${BMC_IP}/xyz/openbmc_project/time/bmc 56 ``` 57 58- To set BMC's time: 59 60 ```bash 61 ### With busctl on BMC 62 busctl set-property xyz.openbmc_project.Time.Manager \ 63 /xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime \ 64 Elapsed t <value-in-microseconds> 65 66 ### With REST API on remote host 67 curl -b cjar -k -H "Content-Type: application/json" -X PUT \ 68 -d '{"data": 1487304700000000}' \ 69 https://${BMC_IP}/xyz/openbmc_project/time/bmc/attr/Elapsed 70 ``` 71 72### Time settings 73 74Getting BMC time is always allowed, but setting the time may not be allowed 75depending on the below two settings in the settings manager. 76 77- TimeSyncMethod 78 - NTP: The time is set via NTP server. 79 - MANUAL: The time is set manually. 80 81A summary of which cases the time can be set on BMC or HOST: 82 83| Mode | Set BMC Time | 84| ------ | ------------ | 85| NTP | Fail to set | 86| MANUAL | OK | 87 88- To set an NTP [server](https://tf.nist.gov/tf-cgi/servers.cgi): 89 90 ```bash 91 ### With busctl on BMC 92 busctl set-property xyz.openbmc_project.Network \ 93 /xyz/openbmc_project/network/eth0 \ 94 xyz.openbmc_project.Network.EthernetInterface NTPServers \ 95 as 1 "<ntp_server>" 96 97 ### With REST API on remote host 98 curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d \ 99 '{"data": ["<ntp_server>"] }' \ 100 https://${BMC_IP}/xyz/openbmc_project/network/eth0/attr/NTPServers 101 ``` 102 103- To go into NTP mode 104 105 ```bash 106 ### With busctl on BMC 107 busctl set-property xyz.openbmc_project.Settings \ 108 /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization \ 109 TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP" 110 111 ### With REST API on remote host 112 curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d \ 113 '{"data": "xyz.openbmc_project.Time.Synchronization.Method.NTP" }' \ 114 https://${BMC_IP}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod 115 ``` 116 117### Special note on changing NTP setting 118 119Starting from OpenBMC 2.6 (with systemd v239), systemd's timedated introduces a 120new beahvior that it checks the NTP services' status during setting time, 121instead of checking the NTP setting: 122 123- When NTP server is set to disabled, and the NTP service is stopping but not 124 stopped, setting time will get an error. 125 126In OpenBMC 2.4 (with systemd v236), the above will always succeed. 127 128This results in [openbmc/openbmc#3459][1], and the related test cases are 129updated to cooperate with this behavior change. 130 131[1]: https://github.com/openbmc/openbmc/issues/3459 132