Wake up the clock before loading rtc_ds1307 module #1020
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Under Fedora 39 with kernel 6.5.6, loading the module rtc_ds1307 does not result in a functioning RTC. The clock needs to be read (woken up?) before the module is loaded. This change adds a read of the clock with a timeout.
In addition, the /dev/rtc device file takes a fraction of a second to load so the test for its existence always fails. A 1 second sleep gives time for the file to be created.
It's not clear to me if eventually this will be required for Raspberry OS when it eventually gets to the 6.5.6 kernel. However it seems this change should always work on kernel 5.
Also fix a misspelling of module in the success message.
Tested on Raspberry OS bullseye by copying the pijuice_sys.py file over the old one and restarting the service. Then restarted the RPi checking systemctl status pijuice and sudo hwclock -r. Finally powered off, removed power (without a battery to reset RTC) and booted up. All the same checks and running fine. I have a generic Raspberry OS install running systemd-timesyncd for network time.