kreestyahn Posted June 18 Posted June 18 Hi, How to enable i2c on PI8(SDA) and PI7(SCL)? I'm newbie in linux and not really understand what am I actually doing so I tried to make it with chatgpt but still not working. root@orangepizero2w:/# sudo i2cdetect -y 0 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: -- -- -- -- -- -- -- -- It can't see any device, but there should be one on the 0x21. Could somebody help me out with this? dmesg | grep i2c [ 0.739582] i2c_dev: i2c /dev entries driver [ 0.739878] mv64xxx_i2c 7081400.i2c: can't get pinctrl, bus recovery not supp orted [ 0.740303] i2c 0-0036: Fixed dependency cycle(s) with /soc/pinctrl@300b000 [ 1.340117] sun50i-h616-pinctrl 300b000.pinctrl: unsupported function i2c0 on pin PI8 [ 1.340132] sun50i-h616-pinctrl 300b000.pinctrl: unsupported function i2c0 on pin PI7 [ 1.340141] mv64xxx_i2c 5002000.i2c: there is not valid maps for state defaul t [ 1.340264] sun50i-h616-pinctrl 300b000.pinctrl: unsupported function i2c0 on pin PI8 [ 1.340279] sun50i-h616-pinctrl 300b000.pinctrl: unsupported function i2c0 on pin PI7 [ 1.340287] mv64xxx_i2c 5002000.i2c: there is not valid maps for state defaul t [ 1.341370] axp20x-i2c 0-0036: AXP20x variant AXP313a found [ 1.342890] axp20x-i2c 0-0036: AXP20X driver loaded [ 269.046993] i2c i2c-2: mv64xxx: I2C bus locked, block: 1, time_left: 0 [ 271.094978] i2c i2c-2: mv64xxx: I2C bus locked, block: 1, time_left: 0 Tried to edit device tree via armbian-config (now it is probably kinda messy): Spoiler pinctrl@300b000 { compatible = "allwinner,sun50i-h616-pinctrl"; reg = <0x300b000 0x400>; interrupts = <0x00 0x33 0x04 0x00 0x34 0x04 0x00 0x35 0x04 0x00 0x2b 0x04 0x00 0x36 0x04 0x00 0x37 0x04 0x00 0x38 0x04 0x00 0x39 0x04>; clocks = <0x02 0x1a 0x0f 0x10 0x00>; clock-names = "apb\0hosc\0losc"; gpio-controller; #gpio-cells = <0x03>; interrupt-controller; #interrupt-cells = <0x03>; vcc-pc-supply = <0x11>; vcc-pf-supply = <0x11>; vcc-pg-supply = <0x12>; vcc-ph-supply = <0x11>; vcc-pi-supply = <0x11>; phandle = <0x14>; rgmii-pins { pins = "PI0\0PI1\0PI2\0PI3\0PI4\0PI5\0PI7\0PI8\0PI9\0PI10\0PI11\0PI12\0PI13\0PI14\0PI15\0PI16"; function = "emac0"; drive-strength = <0x28>; phandle = <0x29>; }; i2c0-pins { pins = "PI8\0PI7"; function = "i2c0"; bias-pull-up; phandle = <0x1e>; }; i2c2-ph-pins { pins = "PH2\0PH3"; function = "i2c2"; phandle = <0x4b>; }; i2c3-ph-pins { pins = "PH4\0PH5"; function = "i2c3"; phandle = <0x4c>; }; i2c4-ph-pins { pins = "PH6\0PH7"; function = "i2c4"; phandle = <0x22>; }; i2c3-pg-pins { pins = "PG17\0PG18"; function = "i2c3"; phandle = <0x4d>; }; i2c4-pg-pins { pins = "PG15\0PG16"; function = "i2c4"; phandle = <0x4e>; }; ir-rx-pin { pins = "PH10"; function = "ir_rx"; phandle = <0x38>; }; mmc0-pins { pins = "PF0\0PF1\0PF2\0PF3\0PF4\0PF5"; function = "mmc0"; drive-strength = <0x1e>; bias-pull-up; phandle = <0x13>; }; mmc1-pins { pins = "PG0\0PG1\0PG2\0PG3\0PG4\0PG5"; function = "mmc1"; drive-strength = <0x1e>; bias-pull-up; phandle = <0x15>; }; mmc2-pins { pins = "PC0\0PC1\0PC5\0PC6\0PC8\0PC9\0PC10\0PC11\0PC13\0PC14\0PC15\0PC16"; function = "mmc2"; drive-strength = <0x1e>; bias-pull-up; phandle = <0x19>; }; rmii-pins { pins = "PA0\0PA1\0PA2\0PA3\0PA4\0PA5\0PA6\0PA7\0PA8\0PA9"; function = "emac1"; drive-strength = <0x28>; phandle = <0x4f>; }; spi0-pins { pins = "PC0\0PC2\0PC4"; function = "spi0"; phandle = <0x24>; }; spi0-cs0-pin { pins = "PC3"; function = "spi0"; phandle = <0x25>; }; spi1-pins { pins = "PH6\0PH7\0PH8"; function = "spi1"; phandle = <0x26>; }; spi1-cs0-pin { pins = "PH5"; function = "spi1"; phandle = <0x50>; }; spi1-cs1-pin { pins = "PH9"; function = "spi1"; phandle = <0x27>; }; uart0-ph-pins { pins = "PH0\0PH1"; function = "uart0"; phandle = <0x1a>; }; uart1-pins { pins = "PG6\0PG7"; function = "uart1"; phandle = <0x51>; }; uart1-rts-cts-pins { pins = "PG8\0PG9"; function = "uart1"; phandle = <0x52>; }; uart2-pins { pins = "PI5\0PI6"; function = "uart2"; phandle = <0x53>; }; uart2-rts-cts-pins { pins = "PH7\0PH8"; function = "uart2"; phandle = <0x54>; }; uart5-pins { pins = "PH2\0PH3"; function = "uart5"; phandle = <0x55>; }; i2c1-pi-pins { pins = "PI7\0PI8"; function = "i2c1"; phandle = <0x57>; }; i2c2-pi-pins { pins = "PI9\0PI10"; function = "i2c2"; phandle = <0x58>; }; i2c3-pa-pins { pins = "PA10\0PA11"; function = "i2c3"; bias-pull-up; phandle = <0x1f>; }; uart2-pi-pins { pins = "PI5\0PI6"; function = "uart2"; phandle = <0x1b>; }; uart3-pi-pins { pins = "PI9\0PI10"; function = "uart3"; phandle = <0x1c>; }; uart4-pi-pins { pins = "PI13\0PI14"; function = "uart4"; phandle = <0x1d>; }; pwm5-pin { pins = "PA12"; function = "pwm5"; phandle = <0x3c>; }; }; i2c@5002000 { compatible = "allwinner,sun50i-h616-i2c\0allwinner,sun8i-v536-i2c\0allwinner,sun6i-a31-i2c"; reg = <0x5002000 0x400>; interrupts = <0x00 0x06 0x04>; clocks = <0x02 0x48>; resets = <0x02 0x17>; pinctrl-names = "default"; pinctrl-0 = <0x1e>; status = "okay"; #address-cells = <0x01>; #size-cells = <0x00>; phandle = <0x62>; }; i2c@5002400 { compatible = "allwinner,sun50i-h616-i2c\0allwinner,sun8i-v536-i2c\0allwinner,sun6i-a31-i2c"; reg = <0x5002400 0x400>; interrupts = <0x00 0x07 0x04>; clocks = <0x02 0x49>; resets = <0x02 0x18>; status = "disabled"; #address-cells = <0x01>; #size-cells = <0x00>; phandle = <0x63>; }; i2c@5002800 { compatible = "allwinner,sun50i-h616-i2c\0allwinner,sun8i-v536-i2c\0allwinner,sun6i-a31-i2c"; reg = <0x5002800 0x400>; interrupts = <0x00 0x08 0x04>; clocks = <0x02 0x4a>; resets = <0x02 0x19>; status = "disabled"; #address-cells = <0x01>; #size-cells = <0x00>; phandle = <0x64>; }; i2c@5002c00 { compatible = "allwinner,sun50i-h616-i2c\0allwinner,sun8i-v536-i2c\0allwinner,sun6i-a31-i2c"; reg = <0x5002c00 0x400>; interrupts = <0x00 0x09 0x04>; clocks = <0x02 0x4b>; resets = <0x02 0x1a>; status = "disabled"; #address-cells = <0x01>; #size-cells = <0x00>; pinctrl-names = "default"; pinctrl-0 = <0x1f>; phandle = <0x65>; mfd@10 { compatible = "x-powers,ac200"; reg = <0x10>; clocks = <0x20>; nvmem-cells = <0x21>; nvmem-cell-names = "calibration"; phandle = <0x66>; phy { compatible = "x-powers,ac200-ephy"; status = "okay"; phandle = <0x67>; }; }; }; armbianEnv.txt: verbosity=1 bootlogo=false console=both disp_mode=1920x1080p60 overlay_prefix=sun50i-h618 overlays=i2c0 i2c1 i2c2 i2c3 uart5 param_uart1_rtscts=1 param_uart2_rtscts=2 param_uart2_rtscts=3 param_uart2_rtscts=4 param_uart2_rtscts=5 rootdev=UUID=88b03ed8-436d-4226-bf01-975ceef8cc1b rootfstype=ext4 usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u 0 Quote
going Posted June 18 Posted June 18 4 часа назад, kreestyahn сказал: chatgpt You and I have more brains than this moron! This is the diagram of your device. Please publish the part of the DTS extracted directly from the working device: dtc --sort -I fs -O dts /sys/firmware/devicetree/base > dts-spi-out.txt Only nodes: pio, i2c0_pins And if you can find a complete pinout of the 40pin connector. We will try to make the correct overlay. 0 Quote
going Posted June 18 Posted June 18 4 часа назад, kreestyahn сказал: rgmii-pins { pins = "PI0\0PI1\0PI2\0PI3\0PI4\0PI5\0PI7\0PI8\0PI9\0PI10\0PI11\0PI12\0PI13\0PI14\0PI15\0PI16"; function = "emac0"; drive-strength = <0x28>; phandle = <0x29>; }; i2c0-pins { pins = "PI8\0PI7"; function = "i2c0"; bias-pull-up; phandle = <0x1e>; }; I apologize. I didn't notice the spoiler. It seems that all PI pins (7, 8, 9, 10) are already occupied? 0 Quote
kreestyahn Posted June 19 Author Posted June 19 Well.. there was a little problem so i reinstalled the whole OS. Currently I only modified armbianEnv.txt. I added this line: overlays:i2c0 I also installed armbian-config and found i2c0-pi in System/Hardware so I enabled it. The device tree is currently unmodified so it has default configuration. Quote It seems that all PI pins (7, 8, 9, 10) are already occupied? Should I remove the PI7-8 from rgmii-pins and then change the i2c0-pins to "PI8\0PI7"? It has also a i2c0-pi-pins. Which one should I modify? i2c0-pi-pins { pins = "PI5\0PI6"; function = "i2c0"; phandle = <0x56>; }; i2c0-pins { pins = "PI6\0PI7"; function = "i2c0"; phandle = <0x1e>; }; 0 Quote
going Posted June 19 Posted June 19 (edited) 9 часов назад, kreestyahn сказал: Which one should I modify? I'm at a loss. I have a dataset h616. And this corresponds to the DTS: sun50i-h616.dtsi#L171 Probably nothing needs to be modified. Just enable (apply standard overlay): Write an overlay file sun50i-h616-i2c0.dts: /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-h616-i2c"; fragment@0 { target-path = "/aliases"; __overlay__ { i2c0 = "/soc/i2c@5002000"; }; }; fragment@1 { target = <&i2c0>; __overlay__ { status = "okay"; }; }; }; Compile the overlay: dtc -I dts -O dtb -o sun50i-h616-i2c0.dtso sun50i-h616-i2c0.dts copy sun50i-h616-i2c0.dtso file to /boot/dtb-**-sunxi/overlay/ armbianEnv.txt: overlay_prefix=sun50i-h616 overlays=i2c0 P.S. pins = "PI6", "PI7"; 40-pin: 22, 5 number Please check it out Edited June 19 by going Add P.S. 0 Quote
kreestyahn Posted June 21 Author Posted June 21 Yeah, I just realized that after the reinstall everything worked fine. Maybe I just messed up something before. Thank you for your help! Now I have another issue with SPI. Can I write here or should I open a new topic? 0 Quote
going Posted June 21 Posted June 21 24 минуты назад, kreestyahn сказал: Can I write here or should I open a new topic? Name topik: Orange Pi Zero 2W overlay I2C SPI help Write here 0 Quote
Solution kreestyahn Posted June 24 Author Solution Posted June 24 Thanks, So I have an SD Card module connected to SPI1 (CS0) pins. root@orangepizero2w:~# dmesg | grep -i 'spi' [ 1.336073] sun50i-h616-pinctrl 300b000.pinctrl: pin-64 (5010000.spi) status -517 [ 1.336093] sun6i-spi 5010000.spi: Error applying setting, reverse things back [ 1.336368] sun50i-h616-pinctrl 300b000.pinctrl: pin-230 (5011000.spi) status -517 [ 1.336385] sun6i-spi 5011000.spi: Error applying setting, reverse things back [ 1.349503] spi-nor spi0.0: supply vdd not found, using dummy regulator [ 1.364641] spi-nor spi0.0: spi-nor-generic (16384 Kbytes) [ 234.215538] /dev/spidev1.0: Can't lookup blockdev spidev-test: root@orangepizero2w:/home/kvl/spidev-test# ./spidev_test -D /dev/spidev1.0 -v spi mode: 0x0 bits per word: 8 max speed: 500000 Hz (500 KHz) TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@....▒..................▒. RX | FF FF FF FF FF FF FC 17 FF FF FF FF FF FF FF FF FF FF F0 5F FF FF FF FF FF FF FF FF FF FF FF FF | ......▒...........▒_............ armbian-config> System/Hardware: armbian-config> device tree: Spoiler pinctrl@300b000 { compatible = "allwinner,sun50i-h616-pinctrl"; reg = <0x300b000 0x400>; interrupts = <0x00 0x33 0x04 0x00 0x34 0x04 0x00 0x35 0x04 0x00 0x2b 0x04 0x00 0x36 0x04 0x00 0x37 0x04 0x00 0x38 0x04 0x00 0x39 0x04>; clocks = <0x02 0x1a 0x0f 0x10 0x00>; clock-names = "apb\0hosc\0losc"; gpio-controller; #gpio-cells = <0x03>; interrupt-controller; #interrupt-cells = <0x03>; vcc-pc-supply = <0x11>; vcc-pf-supply = <0x11>; vcc-pg-supply = <0x12>; vcc-ph-supply = <0x11>; vcc-pi-supply = <0x11>; phandle = <0x14>; rgmii-pins { pins = "PI0\0PI1\0PI2\0PI3\0PI4\0PI5\0PI7\0PI8\0PI9\0PI10\0PI11\0PI12\0PI13\0PI14\0PI15\0PI16"; function = "emac0"; drive-strength = <0x28>; phandle = <0x29>; }; i2c0-pins { pins = "PI6\0PI7"; function = "i2c0"; phandle = <0x1e>; }; i2c2-ph-pins { pins = "PH2\0PH3"; function = "i2c2"; phandle = <0x4b>; }; i2c3-pg-pins { pins = "PG17\0PG18"; function = "i2c3"; phandle = <0x4d>; }; i2c4-pg-pins { pins = "PG15\0PG16"; function = "i2c4"; phandle = <0x4e>; }; ir-rx-pin { pins = "PH10"; function = "ir_rx"; phandle = <0x38>; }; mmc0-pins { pins = "PF0\0PF1\0PF2\0PF3\0PF4\0PF5"; function = "mmc0"; drive-strength = <0x1e>; bias-pull-up; phandle = <0x13>; }; mmc1-pins { pins = "PG0\0PG1\0PG2\0PG3\0PG4\0PG5"; function = "mmc1"; drive-strength = <0x1e>; bias-pull-up; phandle = <0x15>; }; mmc2-pins { pins = "PC0\0PC1\0PC5\0PC6\0PC8\0PC9\0PC10\0PC11\0PC13\0PC14\0PC15\0PC16"; function = "mmc2"; drive-strength = <0x1e>; bias-pull-up; phandle = <0x19>; }; rmii-pins { pins = "PA0\0PA1\0PA2\0PA3\0PA4\0PA5\0PA6\0PA7\0PA8\0PA9"; function = "emac1"; drive-strength = <0x28>; phandle = <0x4f>; }; spi0-pins { pins = "PC0\0PC2\0PC4"; function = "spi0"; phandle = <0x24>; }; spi0-cs0-pin { pins = "PC3"; function = "spi0"; phandle = <0x25>; }; spi1-pins { pins = "PH6\0PH7\0PH8"; function = "spi1"; phandle = <0x26>; }; spi1-cs0-pin { pins = "PH5"; function = "spi1"; phandle = <0x50>; }; spi1-cs1-pin { pins = "PH9"; function = "spi1"; phandle = <0x27>; }; uart0-ph-pins { pins = "PH0\0PH1"; function = "uart0"; phandle = <0x1a>; }; uart1-pins { pins = "PG6\0PG7"; function = "uart1"; phandle = <0x51>; }; uart1-rts-cts-pins { pins = "PG8\0PG9"; function = "uart1"; phandle = <0x52>; }; uart5-pins { pins = "PH2\0PH3"; function = "uart5"; phandle = <0x55>; }; i2c0-pi-pins { pins = "PI7\0PI8"; function = "i2c0"; phandle = <0x56>; }; i2c1-pi-pins { pins = "PI7\0PI8"; function = "i2c1"; phandle = <0x57>; }; i2c2-pi-pins { pins = "PI9\0PI10"; function = "i2c2"; phandle = <0x58>; }; i2c3-pa-pins { pins = "PA10\0PA11"; function = "i2c3"; bias-pull-up; phandle = <0x1f>; }; uart2-pi-pins { pins = "PI5\0PI6"; function = "uart2"; phandle = <0x1b>; }; uart3-pi-pins { pins = "PI9\0PI10"; function = "uart3"; phandle = <0x1c>; }; uart4-pi-pins { pins = "PI13\0PI14"; function = "uart4"; phandle = <0x1d>; }; pwm5-pin { pins = "PA12"; function = "pwm5"; phandle = <0x3c>; }; }; spi@5010000 { compatible = "allwinner,sun50i-h616-spi\0allwinner,sun8i-h3-spi"; reg = <0x5010000 0x1000>; interrupts = <0x00 0x0c 0x04>; clocks = <0x02 0x4f 0x02 0x4d>; clock-names = "ahb\0mod"; dmas = <0x23 0x16 0x23 0x16>; dma-names = "rx\0tx"; resets = <0x02 0x1c>; pinctrl-names = "default"; pinctrl-0 = <0x24 0x25>; status = "disabled"; #address-cells = <0x01>; #size-cells = <0x00>; phandle = <0x69>; flash@0 { #address-cells = <0x01>; #size-cells = <0x01>; compatible = "jedec,spi-nor"; reg = <0x00>; spi-max-frequency = <0x2625a00>; }; }; spi@5011000 { compatible = "allwinner,sun50i-h616-spi\0allwinner,sun8i-h3-spi"; reg = <0x5011000 0x1000>; interrupts = <0x00 0x0d 0x04>; clocks = <0x02 0x50 0x02 0x4e>; clock-names = "ahb\0mod"; dmas = <0x23 0x17 0x23 0x17>; dma-names = "rx\0tx"; resets = <0x02 0x1d>; pinctrl-names = "default"; pinctrl-0 = <0x26 0x27 0x50>; status = "okay"; #address-cells = <0x01>; #size-cells = <0x00>; phandle = <0x6a>; spidev@0 { compatible = "rohm,dh2228fv"; status = "okay"; reg = <0x00>; spi-max-frequency = <0xf4240>; }; }; 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.