0

I'm having a problem creating a DTB for a HAT auto-configuration.

I have a DS3231 RTC module attached on I2C0 (GPIO0 and GPIO1). It incorporates an AT24C32 EEPROM at address 0x50.

To get it working, without getting into the HAT part yet, I've added following lines to /boot/config.txt. I've checked and I need i2c_vc=on in order for it to create /dev/rtc0 and detect the RTC as it should.

dtparam=i2c_vc=on
dtoverlay=i2c-rtc,ds3231,i2c0

Now I want to create a DTB to be embedded in HAT EEPROM so it would be auto-configured without requiring to edit any file. For this, I just checked out eepromutils and created eeprom.eep successfully, also flashing it to the AT24C32 without problems, verified it creates /proc/device-tree/hat with the parameters.

I know I can load a DTB blob or name at boot using the EEPROM, so I installed dtc and used arch/arm/boot/dts/overlays files from raspberrypi/linux at default branch. However, after flashing the new eeprom.eep and also putting hub.dtbo in /boot/overlays and adding dtoverlay=hub to /boot/config.txt doesn't create /dev/rtc0 at all, and i2cdetect shows up 0x68 as free (not UU).

Things I tried to create hub-overlay.dts (and hub.dtbo):

# try 1
ovmerge -c i2c-rtc-overlay.dts,ds3231,i2c0
dtc -@ -Hepapr -I dts -O dtb -o hub.dtbo hub-overlay.dts
# try 2
ovmerge -c i2c0-overlay.dts,pins_0_1 i2c-rtc-overlay.dts,ds3231,i2c0
dtc -@ -Hepapr -I dts -O dtb -o hub.dtbo hub-overlay.dts

I also tried writing the hub-overlay.dts manually like so:

/dts-v1/;
/plugin/;

/ { compatible = "brcm,bcm2835"; fragment@0 { target = <&i2c0>; overlay { status = "okay"; #address-cells = <1>; #size-cells = <0>; ds3231@68 { compatible = "maxim,ds3231"; reg = <0x68>; }; }; }; };

I'm aware that I need something like dtparam=i2c_vc=on but in DTS form, but setting <&i2c0> status to "okay" is far more than completely what I need given that it doesn't create a /dev/i2c-0 device nor loads any driver for RTC workings.

Any advice on how to get it working? I'm trying to get this done without any file modifications if possible. Thanks in advance for your help!

1 Answers1

0

You're not actually meant to use i2c0 for any of your own devices - it's meant to handle just the VideoCore stuff and the HAT EEPROM. Normally, it is made unavailable to the CPU during boot, after the EEPROM has been read, and I've read several warnings that keeping it active may cause problems. It might work better if you put the RTC on i2c1 instead.

However, I'm having trouble getting a HAT working with i2c1, so I'm not sure yet what to recommend. :) I've posted a question today about that one.

Hans Liss
  • 51
  • 5