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