DS3231 RTC on Beagle-bone Black

I am using Beagle-Bone Black with Debian image. I want to wire up my own devices to it (not capes), you might already have heard about the device tree. In my case I want to connect a ds3231 RTC device to the I2C bus on the BBB. I have created a device tree overlay for RTC and a child RTC node in i2c2 node in am33xx.dtsi file. Loaded overlay dynamically by using capemgr. Ds3231 RTC is getting detected with i2cdetect -y -r 2. As per my understanding “rtc-ds1307” driver’s probe function might be called before “rtc-ds3231” driver’s probe function. I need to change the configuration of CONFIG_RTC_DRV_DS1307 is not set in the kernel. So, after doing the changes in configuration my ds3231 probe function is called.
Ds3231 device tree overlay :

/dts-v1/;
/plugin/;

/{ /* this is our device tree overlay root node */

  compatible = "ti,beaglebone", "ti,beaglebone-black";
  part-number = "BBB-I2C2"; // you can choose any name here but it should be memorable
  version = "00A0";

  fragment@0 {
    target = <&am33xx_pinmux>; // this is a link to an already defined node in the device tree, so that node is overlayed with our modification

    __overlay__ {
      i2c2_pins: pinmux_i2c2_pins {
        pinctrl-single,pins = <
          0x178 0x72 
          0x17C 0x72 
        >;
      };
    };
  };

  fragment@1 {
    target = <&i2c2>;

    __overlay__ {
      pinctrl-0 = <&i2c2_pins>;

      clock-frequency = <100000>;
      status = "okay";

      rtc: rtc@68 { /* the real time clock defined as child of the i2c2 bus */
        compatible = "dallas,ds3231";
        #address-cells = <0>;
        #size-cells = <0>;
        reg = <0x68>;
      };
    };
  };
}; /* root node end */

Capture1
capture2
But after loading overlay dynamically it didn’t create a new rtc device (/dev/rtc1 ) in my filesystem.

Your Device tree looks fine.

it looks like your externally built module might have an issue…

Regards,

First in my case configuration was CONFIG_RTC_DRV_DS1307=y . So, I had loaded device tree overlay to capemgr and it generated rtc1 in /dev directory and then inserted .ko file using insmod but ds3231 probe function was not getting called at all.


Dmesg logs:

I found that DS1307 is getting registered as rtc1 so i made the changes in configuration of “CONFIG_RTC_DRV_DS1307 is not set” in linux_bbb_4.14/arch/arm/configs/bb.org.defconfig file. After doing this changes I have loaded the overlay and inserted .ko module. In this case probe function of ds3231 was getting called.

But My issue is that after doing the changes in configuration file I have loaded the overlay dynamically but overlay didn’t generate a rtc1 in /dev directory. I need to load overlay dynamically, insert module and check the external RTC accurate time. Can u suggest me regarding this.

In my case I want to connect a ds3231 RTC device to the I2C bus on the BBB.

we’re doing the same thing in our project…

I have created a device tree overlay for RTC and a child RTC node in i2c2 node

…except on i2c bus 1 (not a big difference) and with (slightly older/outdated)
kernel linux-image-4.19.79-ti-r30.

I need to change the configuration of CONFIG_RTC_DRV_DS1307 is not set
in the kernel.

i think you should consider the normal mainstream ds1307 driver which
does cover the ds3231 (i checked in both the newer kernels as well as in
the old 4.14 series you’re using).

for us with 4.19.79 all that was required to get the ds3231 to be rtc0 on
boot was the loading of an i2c1 overlay early, plus the loading of a slightly
adjusted overlay that renames the on-chip rtc to rtc1 and makes the ds3231
rtc0 (attached).

(Attachment BB-I2C1-RTC-DS3231-oldstyle.dts is missing)

I am a beginner and working on ds3231 RTC device. Yes after dynamic loading of ds3231 RTC it is generating as /dev/rtc0 and on-chip rtc of beaglebone is seen as /dev/rtc1. My task is to call the probe function of ds3231 rtc. Can you suggest me the proper way of execution(rtc).