Jump to content

Recommended Posts

Posted

Hello!
I make an image for my device on the base Orange PI PC.

As you know there is a built-in bad hardware RTC. There is no battery for clock.

I make an image with the built-in off the RTC. It works fine!

I want to connect RTC DS3231 or DS1307  i2c bus.

How can I apply them in the kernel at boot time? How to tell the kernel that his master clock are i2s bus?

 

How to remove fake-hwclock step build of the image? :)

Sorry for bad english. I have tried

Posted

Not sure if this is the "official" way, but on a Banana Pro on kernel 3.4.x I solved this by adding the following lines to /etc/rc.local:

 

# enable ds1307 rtc chip connected to i2c-2 bus
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-2/new_device

# wait for one second, then set system time from /dev/rtc1 device
sleep 1
hwclock -s -f /dev/rtc1

 

 

Here 0x68 is the i2c device address of the 1307 (may be DS3231 is different).

Take care of the correct i2c bus number and the correct /dev/rtc device.

After the "echo" a new rtc device should appear.

 

On version 4 kernels however this seems not to work any more, as I just noticed.

It works when executing the commands by hand but not from rc.local.

Is rc.local not executed any more on the mainline kernels?

Posted

Ok, on Kernel 4.5.5 I had to

sudo update-rc.d -f rc.local remove
sudo update-rc.d -f rc.local defaults

for starting rc.local at boot time. Moreover, the bus numbering of the i2c busses has changed in contrast to legacy kernel.

 

However, this way the hardware clock is set quite at the end of the boot process. It would be fine to have the correct time

as soon as possible. No idea how to do that.

Posted

solution with start script also works, but this is not a native solution :)

it runs already on the userspace level. which of course is not good :( 

 

I see only one way out  -  make  kernel module and include it in the kernel hacking thread

I think this is the real solution. how do you think?

Posted

So I found some information.

 

For kernel version 4.x:

The solution is used raspbian Device Tree - https://github.com/raspberrypi/firmware/tree/master/boot/overlays

For example - added   "device_tree_param=i2c1=on dtoverlay=i2c-rtc,ds3231" to /boot/config.txt

 

For kernel version 3.X:

added "rtc.i2c=ds1307,1,0x68" to /boot/cmdline.txt

 

But these solutions to RaspBian :huh:

Is it possible to apply these solutions to armbian?

Posted

I connected module ds1307 and adding arguments to the boot line.

but unfortunately it did not work.

root@orangepipc:~# dmesg |grep i2c
[    0.000000] Kernel command line: console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup_enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 panic=10 consoleblank=0 enforcing=0 rtc.i2c=ds1307,0,0x68 loglevel=1
[    0.926760] i2c /dev entries driver
root@orangepipc:~# dmesg |grep rtc
[    0.000000] Kernel command line: console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup_enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 panic=10 consoleblank=0 enforcing=0 rtc.i2c=ds1307,0,0x68 loglevel=1
[    0.969232] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

Here you can see that i2s bus starts earlier than the time synchronization of the kernel.

If the option is worked then the solution would be native :)

Can help the developers?

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines