Jump to content

Enable i2c ports in bpi m2 berry-ultra.


hbars

Recommended Posts

2 hours ago, martinayotte said:

Since H3 and R40 are similar, I presume the overlays already provided in any Armbian images under /boot/dtb/overlay should already work.

 

 ____  ____  _   __  __ ____    ____
| __ )|  _ \(_) |  \/  |___ \  | __ )  ___ _ __ _ __ _   _
|  _ \| |_) | | | |\/| | __) | |  _ \ / _ \ '__| '__| | | |
| |_) |  __/| | | |  | |/ __/  | |_) |  __/ |  | |  | |_| |
|____/|_|   |_| |_|  |_|_____| |____/ \___|_|  |_|   \__, |
                                                     |___/

Welcome to ARMBIAN 5.81 user-built Debian GNU/Linux 9 (stretch) 5.0.7-sunxi
package bsp-kernel[5.81] u-boot[5.81] dtb[5.81] firmware[5.81] config[5.81]

root@bpi-m2-berry(192.168.6.20):/# more /boot/armbianEnv.txt
verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootfstype=ext4
overlays=analog-codec i2c0

 

Link to comment
Share on other sites

59 minutes ago, martinayotte said:

Since H3 and R40 are similar, I presume the overlays already provided in any Armbian images under /boot/dtb/overlay should already work. 

But not work. And how can they work when in dts and dtsi nowhere describes the pins of the ports.

 

Link to comment
Share on other sites

1 hour ago, hbars said:

But not work. And how can they work when in dts and dtsi nowhere describes the pins of the ports.

At least for I2C-0, where the PMIC is attached, they are there, but for the other ports, you can prepare a patch and submit a PR to Armbian ...

Link to comment
Share on other sites

35 minutes ago, martinayotte said:

At least for I2C-0, they are there, but for the other ports, you can prepare a patch and submit a PR to Armbian ...

I2C-0 doenst work for me on the M2 Berry (like - with the same commands - on my NanoPi Neo Core2)

But I also cant compile the V40-I2C-0 :(
 

root@bpi-m2-berry(192.168.6.20):/home/guido# dtc -I dts -O dtb v40-bananapi-m2-berry-i2c-0.dts -o v40-bananapi-m2-berry-i2c-0.dtbo
Error: v40-bananapi-m2-berry-i2c-0.dts:2.2-8 syntax error
FATAL ERROR: Unable to parse input tree

I did wget the raw version od the dts and also did a clipboard-copy - but the has the same error.

 

When I activate i2C-0 from normal armbian-config I do get
 

root@bpi-m2-berry(192.168.6.20):/home/guido# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 31 32 33 34 35 36 37 -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@bpi-m2-berry(192.168.6.20):/home/guido# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

but my I2C clock should be at 68 on I2C-0 like on my NanoPi Neo Core2

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
modprobe rtc-ds1307

i2cdetect -y 0

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

armbian:
https://raw.githubusercontent.com/armbian/sunxi-DT-overlays/master/sun8i-h3/sun8i-h3-i2c0.dts
V40:
https://raw.githubusercontent.com/hbars/BPI-M2-Ultra-Berry-i2c-enable/master/v40-bananapi-m2-berry-i2c-0.dts

 

V40_DTS_against_armbian_DTS.jpg

Link to comment
Share on other sites

On 4/20/2019 at 9:34 PM, martinayotte said:

At least for I2C-0, where the PMIC is attached, they are there, but for the other ports, you can prepare a patch and submit a PR to Armbian ...

So they already are.

https://github.com/hbars/BPI-M2-Ultra-Berry-i2c-enable/blob/master/v40-bananapi-m2-berry-i2c-1.dts

https://github.com/hbars/BPI-M2-Ultra-Berry-i2c-enable/blob/master/v40-bananapi-m2-berry-i2c-2.dts

Just gonna leave this here, because-as how to promote the patch does not know... And about PMIC pins I saw.

Strange why was not describe the rest.

Link to comment
Share on other sites

Get it working with a newer version

 

$ wget http://httpredir.debian.org/debian//pool/main/d/device-tree-compiler/device-tree-compiler_1.4.7-3_armhf.deb

$ dpkg --install device-tree-compiler_1.4.7-3_armhf.deb

Link to comment
Share on other sites

On 4/24/2019 at 10:04 PM, hbars said:

So they already are.

https://github.com/hbars/BPI-M2-Ultra-Berry-i2c-enable/blob/master/v40-bananapi-m2-berry-i2c-1.dts

https://github.com/hbars/BPI-M2-Ultra-Berry-i2c-enable/blob/master/v40-bananapi-m2-berry-i2c-2.dts

Just gonna leave this here, because-as how to promote the patch does not know... And about PMIC pins I saw.

Strange why was not describe the rest.

 

Howdy,

I pick-up this old thread since I've been experimenting with i2c on m2u berry.

The above patches did not work with 5.4.14, but with my own customized dts I was able to activate /dev/i2c-2 on 'buster'

Linux bananaberry 5.4.14-sunxi #rc1 SMP Sat Jan 25 15:19:01 CET 2020 armv7l GNU/Linux
Spoiler

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3";

        fragment@0 {
                target-path = "/aliases";
                __overlay__ {
                        i2c2 = "/soc/i2c@01c2b400";
                };
        };

        fragment@1 {
                target = <&pio>;
                __overlay__ {
                        i2c2_pins_a: i2c2@0 {
                                pins = "PB20", "PB21";
                                function = "i2c2";
                        };
                };
        };

        fragment@2 {
                target = <&i2c2>;
                __overlay__ {
                        pinctrl-names = "default";
                        pinctrl-0 = <&i2c2_pins_a>;
                        status = "okay";
                };
        };
};

 

> i2cdetect -y 2
	0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77

I can retrieve data from all i2c devices attached, however, enabling other overlays, such as spi-spidev in /boot/armbianEnv.txt with

 

overlay_prefix=sun8i-h3
overlays=spi-spidev
param_spidev_spi_bus=1
param_spidev_max_freq=100000000 

resulted in the loss of /dev/i2c-2 and no spidev at all. I tried different combinations of stock spi-spidev and i2c0, i2c1 ...

found in /boot/dtb/overlay. Furthermore, none of the uart overlays seem to work either.

 

At least I would like to enable i2c2, spidev and uart at the same time, but I couldn't find the desired information within
the existing threads.

 

Link to comment
Share on other sites

5 hours ago, luetzel said:

resulted in the loss of /dev/i2c-2 and no spidev at all.

If you look at schematic, SPI1 bus is sharing pins with UART2, so you can't have both at the same time !

I woulkd rather suggest to use SPI0 instead, it won't conflict with UART2 ...

Link to comment
Share on other sites

7 minutes ago, luetzel said:

param_spidev_spi_bus=1

This still SPI1, you should have specified for SPI0 :

param_spidev_spi_bus=0

 

EDIT : Oh ! I've just saw a difference between M2-Berry UART2 compared to other board using H3 instead of V40. The UART2 is defaulted to PI18/PI19 instead of PA0/PA1. So, you will have to tweak DT here again ...

Link to comment
Share on other sites

2 hours ago, luetzel said:

I have no clue how to fix it.

Maybe by editing Main DT directly instead of using overlays ...

 

EDIT: Ok ! I added UART2 patches to my build, and I will commit them in Armbian as soon tests will be done.

EDIT2: Committed : https://github.com/armbian/build/commit/64e494384b546be7ba35b32a1ab904389fed4e35

Link to comment
Share on other sites

On 2/3/2020 at 9:17 AM, luetzel said:

I have no clue how to fix it.

I've done more work and few more commits : there is now R40 distinct overlays for UART2/UART4/UART5/UART7 and SPIDEV0/SPIDEV1.

Feel free to build new images using Armbian build scripts ...

Link to comment
Share on other sites

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

Important Information

Terms of Use - Privacy Policy - Guidelines