Enabling a RTC in LibreElec on a C2

Post Reply
RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Enabling a RTC in LibreElec on a C2

Post by RChadwick »

I've got a DS3231 attached, but can't figure out how to get it recognized. The directions I found are either for the Pi, or a full install on the C2.
Thanks!

User avatar
cdu13a
Posts: 316
Joined: Tue Jan 20, 2015 3:33 pm
languages_spoken: english
ODROIDs: C1, C2, XU4, HC1, N2
Has thanked: 12 times
Been thanked: 94 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by cdu13a »

LibreELEC for the C2 doesn't include the kernel module required to use the DS3231 RTC.

CoreELEC doesn't either, but I can look into adding the kernel module for the DS3231 RTC to CoreELEC for you.

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

That would be awesome. My DS3231 is soldered in :)

User avatar
cdu13a
Posts: 316
Joined: Tue Jan 20, 2015 3:33 pm
languages_spoken: english
ODROIDs: C1, C2, XU4, HC1, N2
Has thanked: 12 times
Been thanked: 94 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by cdu13a »

Ok, I've made a build that includes the kernel module for the ds1307.
https://drive.google.com/drive/folders/ ... rqNr5-5wSM

I don't have that particular RTC. Which makes testing and giving instructions on how to use it a bit more difficult for me. But hopefully the following is good enough to get you started.

The following should be enough to see if you can read from the RTC.

Code: Select all

modprobe rtc-ds1307
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -r

To have the RTC be available at boot you have to add an entry for it in the device tree, and enable it.

Code: Select all

mount -o remount,rw /flash
cp /flash/dtb.img /flash/dtb.img.bak
fdtput -c /flash/dtb.img /i2c@c1108500/rtc@68
fdtput -t s /flash/dtb.img /i2c@c1108500/rtc@68 compatible "maxim,ds3231"
fdtput -t x /flash/dtb.img /i2c@c1108500/rtc@68 reg 0x68
fdtput -t s /flash/dtb.img /i2c@c1108500/rtc@68 status "okay"
mount -o remount,ro /flash
reboot
Last edited by cdu13a on Tue Jan 15, 2019 2:24 am, edited 1 time in total.

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

Awesome! I will try it this weekend and report back.

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

I just gave it a try, and it somewhat seems to work.
If I do a hwclock -r, I get:
Fri Apr 7 14:54:50 2000 0.000000 seconds
Unfortunately, I'm unable to set the time with the hwclock -w command. Am I missing something?
Thanks!

User avatar
cdu13a
Posts: 316
Joined: Tue Jan 20, 2015 3:33 pm
languages_spoken: english
ODROIDs: C1, C2, XU4, HC1, N2
Has thanked: 12 times
Been thanked: 94 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by cdu13a »

RChadwick wrote:
Sun Jan 13, 2019 6:46 pm
I just gave it a try, and it somewhat seems to work.
If I do a hwclock -r, I get:
Fri Apr 7 14:54:50 2000 0.000000 seconds
Unfortunately, I'm unable to set the time with the hwclock -w command. Am I missing something?
Thanks!
What is the output from hwclock -w when it fails?

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

Unfortunately, It's not set up at the moment, and I won't be able to try until tomorrow, but I believe there was no error. It simply didn't change the time. I was hoping that, when CoreELEC got the time from the Internet, typing hwclock -w would write the existing time to the RTC, and then running hwclock -r would show the right time, but it didn't. It could be I just don't know what I'm doing :)

User avatar
cdu13a
Posts: 316
Joined: Tue Jan 20, 2015 3:33 pm
languages_spoken: english
ODROIDs: C1, C2, XU4, HC1, N2
Has thanked: 12 times
Been thanked: 94 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by cdu13a »

Output from dmesg from after you try might be helpful as well. dmesg |paste will upload dmesg output to a pastebin site and provide you a link you can post here, instead of directly posting the dmesg output.

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

OK, I have things up. I'll explain step by step:
Boot up, CoreELEC gets time from network, I SSH in.
Run:
modprobe rtc-ds1307
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -w
hwclock -r
I get:
Sat Apr 8 19:46:02 2000 0.000000 seconds
As the date is different from the last time I tried this, I'm guessing it is correctly reading the RTC.
I never get any errors from any of these commands, but the correct time isn't being set with the hwclock -w command.

The dmesg output is here: http://ix.io/1ykh

When I tried to make the clock settings permanent, the Odroid wouldn't boot, giving this error:

cp: read error: Input/output error
*** Error in prepare_sysroot: mount_common: Could not mount /dev/SYSTEM ***
### Starting debugging shell for boot step: prepare_sysroot... type exit to quit ###

Thanks!

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

I don't know what happened, but everything is working now. My best guess is that for whatever reason the RTC was setting the system time, then hwclock -w was simply writing the same time back. Anyway, after trying it a few more times, it worked!
I then tried again the settings to make it permanent. I think the first time I just wasn''t in the right directory when running commands. This time worked without errors.
I then powered down, disconnected the network, and booted back up to the right time.
Could this change be worked into future CoreELEC releases?
Thanks again!

User avatar
cdu13a
Posts: 316
Joined: Tue Jan 20, 2015 3:33 pm
languages_spoken: english
ODROIDs: C1, C2, XU4, HC1, N2
Has thanked: 12 times
Been thanked: 94 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by cdu13a »

Glad you got it working.

The next official release of CoreELEC will include it.

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

That's awesome! when released, do I follow the same directions?
Also, any ETA on the release? I heard the final Leia could be released any day.

User avatar
cdu13a
Posts: 316
Joined: Tue Jan 20, 2015 3:33 pm
languages_spoken: english
ODROIDs: C1, C2, XU4, HC1, N2
Has thanked: 12 times
Been thanked: 94 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by cdu13a »

When the new release is available, you can manually upgrade the install on the sdcard/emmc that you installed this test build on.
In which case you won't have to do anything besides copy the the .tar file for the new release to /storage/.update and reboot, then you will be on the official builds.

If you do a fresh install when the new release is available, just follow the same instructions as you did to get it working on the test build here.

As for an ETA on the next release I don't know. It will be released when it is ready. :)
There are to many variables, to give an exact timeline.

User avatar
rooted
Posts: 8002
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 724 times
Been thanked: 247 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by rooted »

@cdu13ua

Great support

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

As an update, I installed the latest CE 8.99.1, went through the above steps, and it worked. At first it showed the wrong time, likely a different time zone, so I plugged in the Ethernet cable, and the time updated. I then powered off, unplugged the cable, powered on, and the time was correct. Thanks again!

RChadwick
Posts: 13
Joined: Fri Jan 04, 2019 5:31 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by RChadwick »

As another update, it seems I'm having problems. The time reported from the RTC seems to jump ahead 5 hours, which I'm guessing may be a timezone issue.
As an example, I ran these commands at slightly different times:

CoreELEC (official): 8.99.2 (S905.arm)
CoreELEC:~ # hwclock -r
Thu Feb 14 00:03:03 2019 0.000000 seconds
CoreELEC:~ # hwclock -w
CoreELEC:~ # hwclock -r
Wed Feb 13 19:03:19 2019 0.000000 seconds
CoreELEC:~ # hwclock -r
Thu Feb 14 01:04:38 2019 0.000000 seconds
CoreELEC:~ # hwclock -w
CoreELEC:~ # hwclock -r
Wed Feb 13 20:04:49 2019 0.000000 seconds
CoreELEC:~ # hwclock -r
Thu Feb 14 01:16:46 2019 0.000000 seconds

Is this a problem? I've rebooted without the network, and the time is correct.

User avatar
cdu13a
Posts: 316
Joined: Tue Jan 20, 2015 3:33 pm
languages_spoken: english
ODROIDs: C1, C2, XU4, HC1, N2
Has thanked: 12 times
Been thanked: 94 times
Contact:

Re: Enabling a RTC in LibreElec on a C2

Post by cdu13a »

Are you in a timezone that is +/-5hours.

date +"%Z %z" will tell you current set timezone

then

date -u; hwclock -u;

Is there a difference between the two dates/times, and is the difference the same as the timezone offset?

I believe hwclock is set to store the time as UTC not localtime(time with timezone offset applied).

Post Reply

Return to “CoreELEC/LibreELEC - Kodi Project for C1/C2”

Who is online

Users browsing this forum: No registered users and 0 guests