@海石生风
修改后:
i2c_gpio0: i2c-gpio-0 {
compatible = "i2c-gpio";
sda-gpios = <&pio 2 2 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
scl-gpios = <&pio 2 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
i2c-gpio,delay-us = <5>; //100khz
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
};
在板子上运行查看日志:
root@licheepiw:/#: dmesg | grep i2c
[ 0.036596] i2c-gpio soc:i2c-gpio-0: error trying to get descriptor: -2
[ 1.110930] i2c /dev entries driver
[ 1.274979] i2c-gpio soc:i2c-gpio-0: using lines 66 (SDA) and 67 (SCL)
设备下也出现了该i2c
root@licheepiw:/#: ls /dev/i
i2c-0 i2c-1 input/
使用i2cdetect -y 1命令查看总线上的设备,发现相较于硬件i2c读取的很慢,(不是设置了100khz了吗)
查看日志发现的错误:
i2c-gpio soc:i2c-gpio-0: error trying to get descriptor: -2
是i2c-gpio-0没定义吗,要咋定义呀
源码目录的文档:Documentation/devicetree/bindings/i2c/i2c-gpio.yaml
或在线内核文档:https://www.kernel.org/doc/Documentation/devicetree/bindings/i2c/i2c-gpio.txt
sun8i-v3s.dtsi:516-523
i2c3_gpio: i2c3_gpio{
sda-gpios = <&pioC 2 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
scl-gpios = <&pioC 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
i2c-gpio,delay-us = <2>; //100khz
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
};
我这样配置设备树之后:make dtbs
DTC arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dtb
Error: arch/arm/boot/dts/sun8i-v3s.dtsi:517.26-27 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dtb] 错误 1
make[1]: *** [dtbs] 错误 2
编译显示sda-gpios = <&pioC 2 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;这行配置有错
make: *** [sub-make] 错误 2
按照 https://wiki.sipeed.com/soft/Lichee/zh/Zero-Doc/application/otg2PC.html 的教程,编译了内核并烧录进了tf卡,使用串口进行调试发现没有usb0
网卡,通过usb接入电脑,电脑也未显示任何设备接入(使用的是git clone -b zero-5.2.y --depth 1 https://github.com/Lichee-Pi/linux.git
的内核)
晕晕晕