Hi,
I am new to vocore, openwrt etc, so please be gentle!
I am trying to get a DS1307 I2C real time clock (RTC) to work with a vocore using the kernel RTC module kmod-rtc-ds1307.
I have got the I2C interface working. I can detect a device at the correct I2C address (0x68) and I can communicate with the DS1307 using the i2c-tools applications. I can see the seconds and minutes registers counting up on the DS1307 so I am happy that that part of the system is working correctly.
I want to use the kmod-rtc-ds1307 module so I can use the "hwclock" application to simplify synchronising the hardware clock to the system clock.
I am not able to find the kmod-rtc-ds1307 module to enable it when I run "make menuconfig", it is not there under kernel modules or available using opkg or from anywhere else I have looked.
Can anyone tell me how I go about enabling the kmod-rtc-ds1307 module?
I have also looked at what is available under "make kernel_menuconfig" and found a generic sounding "Real Time Clock" option under "Device Drivers", but I am not sure if just enabling this setting is enough or how the settings under "make kernel_menuconfig" interact with those under "make menuconfig".
I have run "./scripts/feeds update", but I have not installed all feeds. Last time I did this I wasn't able to get the system to compile because of broken links to source code that it was trying to download (they were also things that I'd never use and it was also taking forever to compile)... so I am reluctant to run "./scripts/feeds install -a" again. But either way, I can't see the kernel module in the feeds list anyway.
I have also created a build environment and successfully downloaded and compiled CHAOS CALMER (15.05.1) and flashed it to my vocore. I have also downloaded and cross-compiled the i2c-tools applications, which also didn't seem to be available in the opkg list or feeds.
Any idea how to proceed or where to enable the kmod-rtc-ds1307kernel module?
Cheers,
Tom
Vocore, openwrt and DS1307 kernel module
- letaage
- Posts: 3
- Joined: Tue Apr 25, 2017 12:35 pm
- noblepepper
- Posts: 240
- Joined: Sat Nov 29, 2014 3:22 pm
Re: Vocore, openwrt and DS1307 kernel module
It looks like kmod-rtc-ds1307 isn't in chaos calmer.
This leaves you in a painful place. To get it working you will need to figure out why it was dropped and take care of the reasons.
Info that may be useful:
Original addition
Place things like this live (search repo for 1307)
Poor documentation (scroll down to crosscompile.& packages)
Get ready to learn, if you are lucky the package got dropped because of lack of interest and an experienced openwrt geek could get it working in 1/2 hour or so, if not you will need to resolve whatever issues exist which could be a big hill to climb.
If all you want is reliable time you may want to use ntp.
This leaves you in a painful place. To get it working you will need to figure out why it was dropped and take care of the reasons.
Info that may be useful:
Original addition
Place things like this live (search repo for 1307)
Poor documentation (scroll down to crosscompile.& packages)
Get ready to learn, if you are lucky the package got dropped because of lack of interest and an experienced openwrt geek could get it working in 1/2 hour or so, if not you will need to resolve whatever issues exist which could be a big hill to climb.
If all you want is reliable time you may want to use ntp.
- letaage
- Posts: 3
- Joined: Tue Apr 25, 2017 12:35 pm
Re: Vocore, openwrt and DS1307 kernel module
Ok thanks, that gives me something to work with!
I have had a poke around in the openwrt source and found a couple of things.
Firstly the DS1307 driver code does seem to be present in the codebase under:
Secondly, I have found the kmod-rtc-ds1307 kernel module by running
Then selecting:
You don't get to see the I2C RTC devices without selecting I2C support, even though I2C support wasn't originally selected, and despite the i2c_core, i2c_dev and i2c_ralink kernel modules being present and loaded in the image I compiled.
I am busy backing up my build environment right now and will try compiling these settings when the backup is done.
FYI I am using the vocore to drive an old synchronous train station clock. It doesn't have a normal clock movement, it requires a pulse every 30 seconds to move the hands forward in 1/2 minute increments.
I plan to use ntp to keep the clock time accurate, but I want to use the battery backed up DS1307 RTC to keep track of the current time and use the RAM in the DS1307 to keep track of the current position of the hands for when the power inevitably goes off. Then the clock can adjust itself to the correct time when the power comes back on.
I was hoping to use the kernel module to make synchronising ntp and the DS1307 RTC easier - we'll have to see how easy that is in practice...
I have had a poke around in the openwrt source and found a couple of things.
Firstly the DS1307 driver code does seem to be present in the codebase under:
- Code: Select all
openwrt/build_dir/target-mipsel_24kec+dsp_musl-1.1.16/linux-ramips_rt305x/linux-4.4.14/drivers/rtc/rtc-ds1307.c
Secondly, I have found the kmod-rtc-ds1307 kernel module by running
- Code: Select all
make kernel_menuconfig
Then selecting:
- Code: Select all
Device Drivers ---> <M> I2C support
Device Drivers ---> [*] Real Time Clock ---> <M> Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025
You don't get to see the I2C RTC devices without selecting I2C support, even though I2C support wasn't originally selected, and despite the i2c_core, i2c_dev and i2c_ralink kernel modules being present and loaded in the image I compiled.
- Code: Select all
root@OpenWrt:/# lsmod | grep i2c
i2c_core 18650 2 i2c_ralink,i2c_dev
i2c_dev 3872 0
i2c_ralink 2672 0
root@OpenWrt:/#
I am busy backing up my build environment right now and will try compiling these settings when the backup is done.
FYI I am using the vocore to drive an old synchronous train station clock. It doesn't have a normal clock movement, it requires a pulse every 30 seconds to move the hands forward in 1/2 minute increments.
I plan to use ntp to keep the clock time accurate, but I want to use the battery backed up DS1307 RTC to keep track of the current time and use the RAM in the DS1307 to keep track of the current position of the hands for when the power inevitably goes off. Then the clock can adjust itself to the correct time when the power comes back on.
I was hoping to use the kernel module to make synchronising ntp and the DS1307 RTC easier - we'll have to see how easy that is in practice...
- noblepepper
- Posts: 240
- Joined: Sat Nov 29, 2014 3:22 pm
Re: Vocore, openwrt and DS1307 kernel module
Looks like you may have an easy time of it. I'm not sure if selecting it in kernel config will produce an ipk that opkg wants but it will definitely produce a .ko you can load manually. If you select builtin (*) instead of module it will be builtin (duh) to the kernel when you load the image. You can check with
The openwrt documentation on kernel module packages and the original patch should give you some hints on how to make an ipk if you want to go that way.
- Code: Select all
lsmod| grep rtc
The openwrt documentation on kernel module packages and the original patch should give you some hints on how to make an ipk if you want to go that way.
- noblepepper
- Posts: 240
- Joined: Sat Nov 29, 2014 3:22 pm
Re: Vocore, openwrt and DS1307 kernel module
Here is the easy answer(obvious once I thought of it): change to designated driver or lede.
I'm not sure what your issues with feeds were caused by but they shouldn't be hard to fix and feeds/update feeds/install are very reliable for me (and many others). It may be worth your time to find the problem so they work. Yes, there is A LOT of stuff you don't need but there is also some very useful stuff. The packages repository I referenced earlier is where the feeds live.
It will take a long time to compile the first time but once done subsequent build go much faster as long as you don't do something to nuke the toolchain. If you don't select a package in the make menuconfig step they won't affect build time.
I'm not sure what your issues with feeds were caused by but they shouldn't be hard to fix and feeds/update feeds/install are very reliable for me (and many others). It may be worth your time to find the problem so they work. Yes, there is A LOT of stuff you don't need but there is also some very useful stuff. The packages repository I referenced earlier is where the feeds live.
It will take a long time to compile the first time but once done subsequent build go much faster as long as you don't do something to nuke the toolchain. If you don't select a package in the make menuconfig step they won't affect build time.
- letaage
- Posts: 3
- Joined: Tue Apr 25, 2017 12:35 pm
Re: Vocore, openwrt and DS1307 kernel module
It turns out I am using Designated Driver but not everything I have tried has worked. Possibly I am doing things in the wrong order?
I have tried to compile in RTC kernel support as a module using make kernel_menuconfig and for some reason it didn't work. No rtc module under /lib/modules/4.4.14/ and modprobe rtc-ds1307 returned module not found.
So I recompiled with the RTC kernel support compiled built into the kernel, and this time it worked!
I ran the following and hey presto, I now have a /dev/rtc0 and the hwclock command works!
Here's the config changes that seemed to do the trick.
Now all I need to configure ntp and make sure it all comes up properly on a restart.
Thanks for your guidance through this, it has been much appreciated.
PS I did consider moving to lede but thought I would give openwrt one last chance.
I have tried to compile in RTC kernel support as a module using make kernel_menuconfig and for some reason it didn't work. No rtc module under /lib/modules/4.4.14/ and modprobe rtc-ds1307 returned module not found.
So I recompiled with the RTC kernel support compiled built into the kernel, and this time it worked!
I ran the following and hey presto, I now have a /dev/rtc0 and the hwclock command works!
- Code: Select all
echo ds1307 0x68 > '/sys/class/i2c-dev/i2c-0/device/new_device'
Here's the config changes that seemed to do the trick.
- Code: Select all
ubuntu:~/vocore/cc/openwrt$ git diff target/linux/ diff --git a/target/linux/ramips/rt305x/config-4.4 b/target/linux/ramips/rt305x/config-4.4 index 9911d92..41bfd08 100644
--- a/target/linux/ramips/rt305x/config-4.4
+++ b/target/linux/ramips/rt305x/config-4.4
@@ -104,6 +104,9 @@ CONFIG_HAVE_PERF_EVENTS=y
CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
CONFIG_HZ_PERIODIC=y
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_RALINK=y
CONFIG_INITRAMFS_SOURCE=""
CONFIG_IRQCHIP=y
CONFIG_IRQ_DOMAIN=y
@@ -162,6 +165,8 @@ CONFIG_RALINK=y
CONFIG_RALINK_WDT=y
# CONFIG_RCU_STALL_COMMON is not set
CONFIG_RESET_CONTROLLER=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_DS1307=y
CONFIG_SCHED_HRTICK=y
# CONFIG_SCHED_INFO is not set
# CONFIG_SCSI_DMA is not set
Now all I need to configure ntp and make sure it all comes up properly on a restart.
Thanks for your guidance through this, it has been much appreciated.
PS I did consider moving to lede but thought I would give openwrt one last chance.
6 posts
Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests