Which image and kernel do you use? Official kernel may have no i2c-support (dts-nodes missing/disabled,kernel-module not included).
Have you tried the 2nd and 3rd line from here?
Which image and kernel do you use? Official kernel may have no i2c-support (dts-nodes missing/disabled,kernel-module not included).
Have you tried the 2nd and 3rd line from here?
i use ubuntu 1.2.1 from here BPI-R2 new image : ubuntu 16.04 V1.2.1 BT and WIFI AP mode are working fine 2017-11-27
i assume that you are using the default kernel in that image (not replaced).
as of https://github.com/BPI-SINOVOIP/BPI-R2-bsp/blob/master/linux-mt/arch/arm/boot/dts/mt7623n-bpi-r2.dts i2c0-i2c2 are enabled in dts,
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pins_a>;
status = "okay";
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins_a>;
status = "okay";
wm8960: wm8960@1a {
compatible = "wlf,wm8960";
reg = <0x1a>;
};
};
&i2c2 {
pinctrl-names = "default";
pinctrl-0 = <&i2c2_pins_a>;
status = "okay";
};
i2c is also enabled in Kernel-config: https://github.com/BPI-SINOVOIP/BPI-R2-bsp/blob/master/linux-mt/arch/arm/configs/mt7623n_evb_bpi_defconfig
#
# I2C support
#
CONFIG_I2C=y
CONFIG_I2C_BOARDINFO=y
CONFIG_I2C_COMPAT=y
CONFIG_I2C_CHARDEV=m
have you tried the 2 lines i’ve mentioned?
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
modprobe rtc-ds1307
which device do you want to connect? do you have /sys/class/i2c-adapter/*?
i dont tried. i have connect rtc module and display oled ssd1306 128x32, but modules in mailed to my country, from china.
when does this error occur? Remember most i2c-device operating with 5v…bpi/rpi with 3v3…you can damage your board
so, ive added an rtc ds1307 (with removed pullups) to i2c0 (I2C_SDA0=pin3,I2C_SCL0=pin5, 5v=pin4,gnd=pin6)
modprobe i2c-dev
“i2cdetect -y 0” shows only address 0x50 (eeprom), not the 0x68 from the clock, i tried the connections on the other side (first 7pol, then the 5pol-connector), same behaviour. Tried with another module (had 2), also the same.
now i tried to add the rtc and ignoring that it was not found:
modprobe rtc-ds1307
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
cat /sys/class/i2c-dev/i2c-0/device/0-0068/rtc/rtc0/time
00:00:10
hwclock -w
cat /sys/class/i2c-dev/i2c-0/device/0-0068/rtc/rtc0/time
17:13:05
the shown time is in UTC (my local time is UTC+1)
i2cdetect shows now address 0x68 as UU like expected…i assume that the lir2032 on my boards was discharged, try to load it
i can read the rtc also via
hwclock -r
then the time is shown with timezone-setting (in CET=UTC+1)
tried reboot, but here bpi-r2 do not loose clock (disconnected lan of course so that ntp will fail) so i have to completely switch it off
created a script:
#!/bin/bash
modprobe i2c-dev
modprobe rtc-ds1307
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
#cat /sys/class/i2c-dev/i2c-0/device/0-0068/rtc/rtc0/time
#read rtc
hwclock -r
#set system-clock to rtc-value
#hwclock -s
and still loading the battery
after a while i have powered down the r2 some minutes, these are now missing in the clock (clock is now ~5minutes behind)
[20:27] root@bpi-r2:~# ./rtc.sh
Fri 09 Mar 2018 08:32:15 PM CET -0.559925 seconds
[20:27] root@bpi-r2:~# date
Fri Mar 9 20:27:52 CET 2018
[20:27] root@bpi-r2:~# hwclock -s
[20:32] root@bpi-r2:~#
as you see i have set the clock of bpi-r2 to the value of external rtc
Well I having no luck. I removed the pull up resisters on the clock modules i ordered earlier in the thread. I have it wired up in the same way you suggest but I am not communicating with it.
I am running 4.14 checked out from your repo and compiled locally. I looked at the DTS and it appears the i2c bus is configured there. I have added support for the ds1307 to the config as well.
I am not sure this is a hardware issue through because i2cdetect does not show any devices. It looks like you indicate I should see a device at 0x50 and I don’t see that.
Any thoughts and help much appreciated.
If you have this ultra compact rtc,there is no such eeprom-chip on it so you can’t see adress 0x50 of this
Have you tried to access by creating the device like me (no search). Which pins do you use? Which kernel? are you sure that the resistors are pullups? i have more resistors in my board (some for loading-circuit)
Pretty sure the resisters were acting as pull-ups. Sorry I misunderstood and thought perhaps the eeprom you mentioned as something on board the BPI-R2. I am running 4.14 compiled after a checkout from your repo. I do see error -110 in the dmesg output after attempting to insert the device via echo > new_device.
I might just try grabbing another module designed for a RPI where everything is expecting 3v logic based on your clarification, as I don’t have anything else to test this module out with.
Maybe you got a broken module ? I bought 4 module from the network, but I got one of it missing the ds1307…
Hi. I am trying to use i2c1 on pin 3 &5. My “i2cdetect -y 1” not detected my I2C module. I already loaded i2c-dev and ds1307 modules.
#i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --
TIA.
I used i2c0 for testing my RTC.
Thanks for @frank-w, My module works fine now
(My RTC modules is “Tiny RTC I2C modules”)
Steps:
i2cdetect -y -r -a 0
to scan the i2c bus 0 (/dev/i2c-0) --> “0x68”modprobe rtc-ds1307
echo ds1307 0x68 > /sys/bus/i2c/devices/i2c-0/new_device
cat /sys/bus/i2c/devices/i2c-0/0-0068/rtc/rtc0/time
date
, hwclock -w
and hwclock -r
to test your moduleHi. I am Frank’s 4.14.28 kernel and I can find that the I2C0 & I2C1 are exist on /dev/. However, i2cdetect -y 0/1 detected nothing. I am using 420mA Serial to I2C converter. I confirmed that my I2C module is working fine on RPI board. So I assume, I no need to worry up the pullups.
For experiment, I also tried with DS3231 RTC module. Still it is not detected anything on the I2C port.
TIA.
I have an issue on BPi-R2 and time is always behind. After one night the clock is 15minutes behind current time. I have sync (ntp) the time yesterday after boot as it was 1 week behind current time. How come the BPI-R2 is always behind current time? I have “RTC_DRV_DS1307” enable in the kernel. Do i have to buy a physical new card for RTC (Real Time Clock) ?
Is that the same as for BPI-R1, https://bananapi.gitbooks.io/bpi-accessories/content/en/rtcmodule.html?
For external rtc you need an external board like ds1307 but care about the data-levels (5v are not good for pi-pins which are operating with 3v3)
I feel like an archeologist, but, just in case…
adding rtc notes to mt7623n-bananapi-bpi-r2.dts like:
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pins_a>;
status = "okay";
ds1307: ds3231@68 {
compatible = "maxim,ds3231";
reg = <0x68>;
status = "okay";
};
};
will add driver autodetect on boot:
[ 5.992725] i2c-dev: adapter [mediatek-hdmi-ddc] registered as minor 0
[ 6.000117] i2c-dev: adapter [i2c-mt65xx] registered as minor 1
[ 6.006148] i2c i2c-1: adapter [i2c-mt65xx] registered
[ 6.011331] i2c i2c-1: of_i2c: walking child nodes
[ 6.016164] i2c i2c-1: of_i2c: register /i2c@11007000/ds3231@68
[ 6.022258] i2c i2c-1: client [ds3231] registered with bus id 1-0068
[ 6.029347] i2c-dev: adapter [i2c-mt65xx] registered as minor 2
[ 6.035375] i2c i2c-2: adapter [i2c-mt65xx] registered
[ 6.040570] i2c i2c-2: of_i2c: walking child nodes
... rtc_ds1307 module loading...
[ 21.760493] rtc-ds1307 1-0068: probe
[ 21.760641] i2c-core: using bounce buffer for addr=0x68, len=1
[ 21.760654] i2c-core: using bounce buffer for addr=0x68, len=2
[ 21.761371] i2c-core: using bounce buffer for addr=0x68, len=2
[ 21.761795] i2c-core: using bounce buffer for addr=0x68, len=1
[ 21.761810] i2c-core: using bounce buffer for addr=0x68, len=8
[ 21.763065] i2c-core: using bounce buffer for addr=0x68, len=1
[ 21.763084] i2c-core: using bounce buffer for addr=0x68, len=7
[ 21.764574] rtc-ds1307 1-0068: registered as rtc1
[ 21.764783] i2c-core: using bounce buffer for addr=0x68, len=1
[ 21.764797] i2c-core: using bounce buffer for addr=0x68, len=1
[ 21.766003] i2c-core: driver [rtc-ds1307] registered
I have ds3231, but it uses ds1307 driver so it’s possible to use ds1307 dts notes
I’ve attached DS3231 HW-022 to bpi-r2, on gpio 1, 3, 5, 7, 9 :
And read specification :
The module itself can adapt to 3.3V and 5V systems without level shifting, which is super convenient!
Modified your script a bit for i2c-1, but guess it’s not working!
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
hwclock -r
2020-12-03 13:35:48.304171+01:00
Following from dmesg :
[ 217.045826] i2c /dev entries driver
[ 217.085742] rtc-ds1307 1-0068: registered as rtc1
[ 217.086037] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68
[ 310.540830] mediatek-hdmi-ddc 11013000.i2c: i2c ack err!
[ 310.540875] mediatek-hdmi-ddc 11013000.i2c: ddc failed!
[ 1383.733606] i2c i2c-1: Failed to register i2c client ds1307 at 0x68 (-16)
[ 1396.525472] i2c i2c-1: Failed to register i2c client ds1307 at 0x68 (-16)
What did I wrong? Can I damage my board with this module?
Which script did you mean? @DeadMeat have changed dts which needs recompiling kernel also for adding the driver.
You can damage board if your module uses 5v levels…bpi has 3.3v
Now it’s seems to me working :
[ 312.306782] rtc-ds1307 1-0068: SET TIME!
[ 312.309498] rtc-ds1307 1-0068: registered as rtc1
[ 312.311286] i2c i2c-1: new_device: Instantiated device ds3231 at 0x68
I used your script :
#!/bin/bash
modprobe i2c-dev
modprobe rtc-ds1307
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
#cat /sys/class/i2c-dev/i2c-1/device/1-0068/rtc/rtc1/time
#read rtc
hwclock -r
#set system-clock to rtc-value
hwclock -w -f /dev/rtc1
hwclock -r -f /dev/rtc1
hwclock -s -f /dev/rtc1
Output from date && hwclock -r :
Thu Dec 3 14:18:37 CET 2020
2020-12-03 14:18:38.393795+01:00
Ah, long time ago…march 2018 (Has anyone added an RTC) Good to head it works now…what have you changed? I see in your log that maybe a collision with hdmi-ddc happened