Fix i2c rtc
This commit is contained in:
parent
f6ec2e72ea
commit
eeb1f834c7
@ -1 +1 @@
|
|||||||
rtc-ds1307
|
rtc-ds1307
|
||||||
|
@ -4,7 +4,8 @@ ConditionVirtualization=!container
|
|||||||
DefaultDependencies=no
|
DefaultDependencies=no
|
||||||
Wants=dev-rtc_i2c.device
|
Wants=dev-rtc_i2c.device
|
||||||
After=dev-rtc_i2c.device
|
After=dev-rtc_i2c.device
|
||||||
Before=systemd-timesyncd.service ntpd.service chrony.service
|
Before=sysinit.target
|
||||||
|
Conflicts=shutdown.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
@ -12,10 +13,10 @@ CapabilityBoundingSet=CAP_SYS_TIME
|
|||||||
PrivateTmp=yes
|
PrivateTmp=yes
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
ProtectHome=yes
|
ProtectHome=yes
|
||||||
DeviceAllow=/dev/rtc_i2c rw
|
DeviceAllow=/dev/rtc rw
|
||||||
DevicePolicy=closed
|
DevicePolicy=closed
|
||||||
ExecStartPre=/usr/bin/echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
|
ExecStart=/bin/sh -c "/usr/bin/echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device"
|
||||||
ExecStart=/sbin/hwclock -s
|
ExecStartPost=/usr/bin/logger --tag rtc-i2c 'System clock set from i2c hardware clock'
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=time-sync.target
|
WantedBy=sysinit.target
|
||||||
|
@ -7,6 +7,12 @@
|
|||||||
update_cache: yes
|
update_cache: yes
|
||||||
pkg:
|
pkg:
|
||||||
- i2c-tools
|
- i2c-tools
|
||||||
|
- libraspberrypi-bin
|
||||||
|
|
||||||
|
- name: enable i2c-rtc dtoverlay
|
||||||
|
shell:
|
||||||
|
cmd: |
|
||||||
|
dtoverlay i2c-rtc
|
||||||
|
|
||||||
- name: enable automatic module load
|
- name: enable automatic module load
|
||||||
copy:
|
copy:
|
||||||
@ -18,8 +24,13 @@
|
|||||||
src: etc/systemd/system/rtc-i2c.service
|
src: etc/systemd/system/rtc-i2c.service
|
||||||
dest: /etc/systemd/system/rtc-i2c.service
|
dest: /etc/systemd/system/rtc-i2c.service
|
||||||
|
|
||||||
|
- name: disable systemd service
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
name: rtc-i2c.service
|
||||||
|
enabled: no
|
||||||
|
|
||||||
- name: enable systemd service
|
- name: enable systemd service
|
||||||
systemd:
|
systemd:
|
||||||
name: rtc-i2c.service
|
name: rtc-i2c.service
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
---
|
---
|
||||||
|
- name: Check if rtc is loaded
|
||||||
|
stat:
|
||||||
|
path: /dev/rtc
|
||||||
|
register: rtc_file
|
||||||
|
|
||||||
- become: yes
|
- become: yes
|
||||||
|
when: rtc_file.stat.exists == False
|
||||||
block:
|
block:
|
||||||
- name: load hwclock
|
- name: load hwclock
|
||||||
shell:
|
shell:
|
||||||
|
Loading…
Reference in New Issue
Block a user