BalenaOS OrangePi One -> rtc clock, i2c, spi support

Hello my fellow Balena friends!

3 things

  1. I have a problem with time on OrangePi One - it can’t synchronize time without manual date set. Because of that it can’t connect to my OpenBalena instance, because of “future” certificate.
    I don’t know why. It shows /dev/rtc0 without rtc connected (fake-hwclock?)
  2. I tried to connect ds3231 rtc clock on OrangePi One pinout, but without success. i2c is not enabled, and i can’t enable it by simple way (no support for raspberry-like overlay environment).
    Is there any way to enable it?
    I know that one of the solution will be to dive into the Yocto, and prepare it somehow itself, but maybe there is some out of the box way?
    If not, do you have some materials/tutorial how to prepare yocto with balena?
  3. SPI Devices also are not supported on OrangePi One, is there any solution to enable it?

Same for orange pi zero

After 10 minutes date is automaticaly set, but then i have 10 minute gap of 1970 datetime

Hi, unfortunately I don’t have an OrangePi One board to try and reproduce the problem. But from what you describe, it sounds like NTP sync starts no your device with a big delay.

Chronyd service is responsible for syncing the system clock over NTP. You could try debugging when it starts and if there are issues using

systemctl status chronyd

You can find information about time management in balenaOS in our docs:

Hmm, before reboot:

I don’t have attached RTC

After reboot

+10 minutes after reboot

And after +11 minutes after reboot:

Would you also share the output of chronyc sources/tracking/ntpdata commands (they are described in the docs I linked above)? It might help with debugging.

Okay i will
Can you answer me about yocto?

Regarding Yocto, if it is related to a balenaOS build then sure, though I would suggest that you create a new thread if it is not directly related to this issue with the clock. Let us know when you have the output of the commands as described above to help us debug this one.

chronyc sources

root@acc9d2d:~# chronyc sources

210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ ntp2.tktelekom.pl 2 10 377 907 +467us[ +573us] +/- 51ms
^+ dns1.telbiur.com.pl 2 9 377 390 +1068us[+1068us] +/- 40ms
^+ afrodyta.complex.net.pl 2 8 377 150 -2086us[-2086us] +/- 42ms
^* time.taken.pl 2 9 377 394 +1240us[+1358us] +/- 23ms

root@acc9d2d:~# chronyc tracking

Reference ID : C1465EB6 (time.taken.pl)
Stratum : 3
Ref time (UTC) : Mon Mar 09 18:29:12 2020
System time : 0.000068880 seconds slow of NTP time
Last offset : +0.000118125 seconds
RMS offset : 0.000062668 seconds
Frequency : 21.646 ppm fast
Residual freq : +0.005 ppm
Skew : 0.047 ppm
Root delay : 0.010358873 seconds
Root dispersion : 0.017983422 seconds
Update interval : 518.2 seconds
Leap status : Normal

root@acc9d2d:~# chronyc ntpdata

Reference ID    : C1465EB6 (time.taken.pl)
Stratum         : 3
Ref time (UTC)  : Mon Mar 09 18:29:12 2020
System time     : 0.000068880 seconds slow of NTP time
Last offset     : +0.000118125 seconds
RMS offset      : 0.000062668 seconds
Frequency       : 21.646 ppm fast
Residual freq   : +0.005 ppm
Skew            : 0.047 ppm
Root delay      : 0.010358873 seconds
Root dispersion : 0.017983422 seconds
Update interval : 518.2 seconds
Leap status     : Normal
root@acc9d2d:~# chronyc ntpdata

Remote address  : 213.199.225.40 (D5C7E128)
Remote port     : 123
Local address   : 192.168.1.170 (C0A801AA)
Leap status     : Normal
Version         : 4
Mode            : Server
Stratum         : 2
Poll interval   : 9 (512 seconds)
Precision       : -21 (0.000000477 seconds)
Root delay      : 0.000717 seconds
Root dispersion : 0.043686 seconds
Reference ID    : 5032E7E2 ()
Reference time  : Mon Mar 09 17:50:27 2020
Offset          : -0.000573210 seconds
Peer delay      : 0.014438649 seconds
Peer dispersion : 0.000000644 seconds
Response time   : 0.000019913 seconds
Jitter asymmetry: +0.00
NTP tests       : 111 111 1111
Interleaved     : No
Authenticated   : No
TX timestamping : Kernel
RX timestamping : Kernel
Total TX        : 31
Total RX        : 31
Total valid RX  : 31

Remote address  : 5.226.101.254 (05E265FE)
Remote port     : 123
Local address   : 192.168.1.170 (C0A801AA)
Leap status     : Normal
Version         : 4
Mode            : Server
Stratum         : 2
Poll interval   : 9 (512 seconds)
Precision       : -22 (0.000000238 seconds)
Root delay      : 0.009995 seconds
Root dispersion : 0.025711 seconds
Reference ID    : C21D82FC ()
Reference time  : Mon Mar 09 18:24:25 2020
Offset          : -0.001068198 seconds
Peer delay      : 0.019391680 seconds
Peer dispersion : 0.000000406 seconds
Response time   : 0.000139021 seconds
Jitter asymmetry: +0.00
NTP tests       : 111 111 1111
Interleaved     : No
Authenticated   : No
TX timestamping : Kernel
RX timestamping : Kernel
Total TX        : 33
Total RX        : 24
Total valid RX  : 24

Remote address  : 193.25.222.240 (C119DEF0)
Remote port     : 123
Local address   : 192.168.1.170 (C0A801AA)
Leap status     : Normal
Version         : 4
Mode            : Server
Stratum         : 2
Poll interval   : 8 (256 seconds)
Precision       : -23 (0.000000119 seconds)
Root delay      : 0.003372 seconds
Root dispersion : 0.033035 seconds
Reference ID    : D264B165 ()
Reference time  : Mon Mar 09 18:15:49 2020
Offset          : +0.002085741 seconds
Peer delay      : 0.013776449 seconds
Peer dispersion : 0.000000289 seconds
Response time   : 0.000011460 seconds
Jitter asymmetry: +0.00
NTP tests       : 111 111 1111
Interleaved     : No
Authenticated   : No
TX timestamping : Kernel
RX timestamping : Kernel
Total TX        : 37
Total RX        : 28
Total valid RX  : 28

Remote address  : 193.70.94.182 (C1465EB6)
Remote port     : 123
Local address   : 192.168.1.170 (C0A801AA)
Leap status     : Normal
Version         : 4
Mode            : Server
Stratum         : 2
Poll interval   : 9 (512 seconds)
Precision       : -24 (0.000000060 seconds)
Root delay      : 0.001038 seconds
Root dispersion : 0.018326 seconds
Reference ID    : C21D82FC ()
Reference time  : Mon Mar 09 18:27:18 2020
Offset          : -0.001358169 seconds
Peer delay      : 0.008721580 seconds
Peer dispersion : 0.000000226 seconds
Response time   : 0.000013148 seconds
Jitter asymmetry: +0.00
NTP tests       : 111 111 1111
Interleaved     : No
Authenticated   : No
TX timestamping : Kernel
RX timestamping : Kernel
Total TX        : 33
Total RX        : 24
Total valid RX  : 24

Thanks for the output which I’m looking at now and sorry I misunderstood your last Yocto comment. Regarding an environment, you could try this Docker setup from one of my colleagues, which I’ve used successfully and has all the required dependencies for building balenaOS https://github.com/alexgg/docker-balena

For sure i will look at it! Thank you very much.

Thanks for the above output. From looking at the logs it seems it is synced and no NTP sources are unreachable. Do you see issues when restarting chrony or just on a system reboot i.e. can you try systemctl restart chronyd.service?

To enable further debugging you could also enable support access for this device and share the UUID and we can take a closer look at it?

Hi, this device is connected to OpenBalena, can i somehow give you the access?
i hard rebooted the device - unplugged from power supply, wait for 10 seconds, and issue is still here

Zrzut ekranu z 2020-03-09 21-07-47

Please ignore that comment about gaining access, I missed this was openBalena. Can you just restart chrony and not reboot the device systemctl restart chronyd.service and then provide the full chrony logs via journalctl --no-pager -n 400 -u chronyd.service?

Hi!

From new orange pi one
root> @a0af15b:~# journalctl --no-pager -n 400 -u chronyd.service

– Logs begin at Thu 1970-01-01 00:00:23 UTC, end at Wed 2020-03-11 09:43:32 UTC. –
Mar 23 12:40:23 localhost systemd[1]: Started NTP client/server.
Mar 23 12:40:23 localhost chronyd[768]: 2019-03-23T12:40:23Z chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER -SECHASH -SIGND +ASYNCDNS +IPV6 -DEBUG)
Jan 01 00:00:24 localhost chronyd[768]: 1970-01-01T00:00:24Z System time set from RTC
Mar 11 09:43:32 a0af15b chronyd[768]: 2020-03-11T09:43:32Z Forward time jump detected!
Mar 11 09:43:32 a0af15b chronyd[768]: 2020-03-11T09:43:32Z chronyd exiting
Mar 11 09:43:32 a0af15b systemd[1]: Stopping NTP client/server…
Mar 11 09:43:32 a0af15b systemd[1]: Stopped NTP client/server.
Mar 11 09:43:32 a0af15b systemd[1]: Started NTP client/server.
Mar 11 09:43:32 a0af15b chronyd[1779]: 2020-03-11T09:43:32Z chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER -SECHASH -SIGND +ASYNCDNS +IPV6 -DEBUG)
Mar 11 09:43:32 a0af15b chronyd[1779]: 2020-03-11T09:43:32Z RTC time before last driftfile modification (ignored)
Mar 11 09:43:32 a0af15b chronyd[1779]: 2020-03-11T09:43:32Z Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift

It’s available also for support now, cause i connected it to Balena according this:

If you need this please let me know

Hi Adam, thanks it would be good to get access to the device. Could you also mention what version of the OS you are running. It might be worth trying the 2.46.1 OS we have in our staging environment currently to see if it presents with the same problem.

Hi, im using v2.31.5+rev1
Unfortunately there is no link inside device dashboard to select 2.46.1 OS in Orange Pi One

I can try, but how can i download it?

Hi, yes its available for download in our staging environment at https://dashboard.balena-staging.com/login , you will need to create a new account and app there. There you should be able to download the 2.46.1 and then all that you need to do is take your config.json from the production balenaCloud and put it on the SD card in /resin-boot , this will allow that 2.46.1 image to connect to the balenaCloud production servers and you can continue testing as you have before.

Hi!
I’ve checked balenaos 2.46.1

Problem exists

i2c still doesn’t existsm also spi

Hi,

Trying to make sense of this thread as it seems that we have a lot of moving parts here. Could you clarify a few points for the sake of anyone reading this far:

So my plan is to build custom orange-pi-one balenaOS image with some additional features like: i2c support…

Did you manage to do this? It seems from the logs you posted that chrony managed to set the time from the RTC and you also mentioned that you had connected it to balena. It would be good to know if you have a working image (self built) and what was required if so.

i2c still doesn’t existsm also spi

I am assuming this is using our stock balenaOS 2.46.1 image?

Thanks for the update.