0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

BH3 RTC設定シーケンス

Last updated at Posted at 2021-08-26

####BH3(産業用RaspberryPi)のRTC設定シーケンスについて説明します。

OS 起動時(/usr/local/sbin/set-rtc)

  1. RTC の I2C 接続を初期化します
  2. RTC 時刻をシステム時刻に設定します
  3. 2.の実行結果が失敗の場合、fake-hwclock を利用して前回のシャットダウン時
    刻をシステム時刻に設定します。

####ネットワーク接続時と毎時 30 分(1 時間毎))に実行(/etc/network/if-up.d/ntpdate)

  1. 重複起動をチェックします(既に起動中の場合は処理を停止)
  2. 20 秒間待機します(ネットワーク接続直後は ntpdate が失敗しやすいため)
  3. /usr/sbin/ntpdate-debian コマンドを実行し、ネットワーク経由でシステム時刻を
    設定します
    1. の実行結果が成功の場合、システム時刻を RTC 時刻に設定します
    1. の実行結果が成功の場合、10 分間待機します。
      (ntpdate が連続して実行されるのを防ぐため)

ntpdate の実行間隔は次のファイルで変更可能です。
(毎時 30 分(1 時間毎)の場合)

$ vi /etc/cron.d/ntpdate
30 * * * * root /etc/network/if-up.d/ntpdate > /dev/null 2>&1

NTP サーバーを指定する場合は次のファイルを修正します。

$ vi /etc/default/ntpdate
NTPSERVERS="ntp.nict.jp ntp.jst.mfeed.ad.jp ntp.ring.gr.jp"

手動で nptdate を実行し、システム時刻を RTC に設定する場合は次のコマンドを
実行します。

$ sudo /usr/sbin/ntpdate-debian
$ sudo hwclock -w

ネットワークに接続しない場合や ntpdate を利用してシステム時刻を合わせる必要
がない場合は次のファイルを削除します。

/etc/cron.d/ntpdate
/etc/network/if-up.d/ntpdate

任意の時刻を RTC に設定する場合は次のコマンドを実行します。

$ sudo date -s '時刻(例: 2015-06-19 00:00:00)'
$ sudo hwclock -w

RTC 時刻を表示する場合は次のコマンドを実行します。

$ sudo hwclock -r

RTC 時刻をシステム時刻に設定する場合は次のコマンドを実行します。

$ sudo hwclock -s
DSCF0562.JPG
ビズライト・テクノロジー社製BH3

BHシリーズは、株式会社ビズライト・テクノロジーが開発・生産する、シングルボードコンピュータの実用化した商品です。BHシリーズではRaspberryPiを産業利用するための対策が施されています。詳しくは、こちらをご覧ください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?