Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RTC detection for devices that have it (newer MM+) #1665

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tGecko
Copy link
Member

@tGecko tGecko commented Sep 12, 2024

Since the newest hardware revisions of the Miyoo Mini+ have RTC, it should be handled accordingly.

Detects if RTC is present, and does not restore and/or advance time if it is.
Works with newest Miyoo Mini+ with built in RTC as well as modded in RTC.

Edit: will also work on MM with RTC, see #1673

@tGecko tGecko added the enhancement New or improved feature label Sep 12, 2024
@tGecko tGecko self-assigned this Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to check if the hardware exists instead of this threshold?

You can check that on /sys/class/rtc, or find it on /dev/rtcX. Though, I'm not sure if devices without RTC have a dummy RTC dev node. The only MM+ I got a week ago does have a RTC.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I'm currently using on my device to update system's time:

diff --git a/static/build/.tmp_update/runtime.sh b/static/build/.tmp_update/runtime.sh
index 1ea12957..154356f6 100644
--- a/static/build/.tmp_update/runtime.sh
+++ b/static/build/.tmp_update/runtime.sh
@@ -25,7 +25,13 @@ main() {
     clear_logs
 
     init_system
-    update_time
+    # check if a device node for the RTC exists
+    if [ -e /dev/rtc0 ]; then
+        # updating time using RTC
+        hwclock -s
+    else
+        update_time
+    fi
 
     # Remount passwd/group to add our own users
     mount -o bind $sysdir/config/passwd /etc/passwd

But I've set the RTC (after updating the system's time on network) through terminal with hwclock -w.
Clock app should be able to set that automatically.

Copy link
Member Author

@tGecko tGecko Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to check if the hardware exists instead of this threshold?

You can check that on /sys/class/rtc, or find it on /dev/rtcX. Though, I'm not sure if devices without RTC have a dummy RTC dev node. The only MM+ I got a week ago does have a RTC.

The RTC hardware always existed, it's part of the SoC. Older units just had it wired to the same voltage rail as the chip itself, so it wouldn't be powered when the device was off.

See https://github.com/anzz1/miyoomini-resources/wiki/Hardware-Mod:-RTC-on-the-Miyoo-Mini-Plus---Miyoo-Mini

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad, I should've checked. Thanks for the link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New or improved feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants