为了方便排查,应用Digi的开发套件或单板机来进行,以防止自焊板子的一些硬件问题。首先要仔细阅读CC6UL HRM和DEY对应版本的BSP中串口部分。了解设备接口复用情况,以及板子上的硬件是否有复用开关等。中文版也有少量的SBC PRO HRM说明(从HRM中翻译),以方便阅读。

根据HRM,uart3的RTS和CAN口复用,所以我们不能同时使用uart 4线和can口。为了方便调查,一般选择阅读github上的源码,再回到项目上去修改。注意一般板级设备树会include板级的设备树共同索引,所以我们在指定ID的板级设备树上找不到的,可以从imx6ul-ccimx6ulsbc.dtsi中去找。

第一步,首先测试一下两线的uart3

在板级dtsi中,有

/* UART3 */
&uart3 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart3_2wires>;
	status = "disabled";
};

如果只测两线,只需在dts中,用status = “okay”; 来启动它即可,在id135设备树上已经是这样操作了。

接口在J29的6,7,10 ,分别是TX,RX,GND,232电平。可以用电脑串口调试助手测试。 实测中发现,如果用cat /etc/ttymxc2来读它,会导至发送测试方回显发送数据,而无法用cat读到值。改用串口例程测试,就没有问题了。

对于uart3使用gpio1 2作为方向脚,这个在单板机上没有,设备树改为:

&uart3 {
pinctrl-0 = <&pinctrl_uart3_2wires>;
linux,rs485-enabled-at-boot-time;
cts-gpios = <&gpio1 2>;
rts-gpios;
rs485-rts-active-high;
rs485-rx-during-tx;
rs485-rts-delay = <1 1>;
status = "okay";
}; 

有待测试,可能要调整的包括cts-gpios和rts-gpios互换,在该命令上使用ZGPIO_ACTIVE_HIGH作为极性等。

单板机上的PHY芯片是采用LAN8720Ai,先找一下该片子的资料:http://ww1.microchip.com/downloads/en/DeviceDoc/00002165B.pdf

.

.

开发板的原理图:

发现一个问题,就是新版的PHY地址箝位线没接,两个phy地址不能区分?待硬件修正之前,先做些测试

先试试加减项,去掉smsc专有的,在https://github.com/digi-embedded/linux/blob/v4.14/dey-2.6/maint/Documentation/devicetree/bindings/net/fsl-fec.txt 挑些要用的参数 第一次测试,改在:

ethphy0: ethernet-phy@0 {
			compatible = "ti,dp83848","ethernet-phy-ieee802.3-c22";
//			smsc,disable-energy-detect;
			reg = <1>;
		};

		ethphy1: ethernet-phy@1 {
			compatible ="ti,dp83848", "ethernet-phy-ieee802.3-c22";
//			smsc,disable-energy-detect;
			reg = <3>;
		};

上电后的dmesg|grep phy

从错误来看,phy@0挂上,而phy@1没挂上,有点像这个@后面是地址,而reg倒不像是物理地址的意思。 查查reg是什么东西。 https://github.com/digi-embedded/linux/blob/v4.14/dey-2.6/maint/Documentation/devicetree/bindings/net/phy.txt 中有相关的定义:

Required properties:

 - interrupts : interrupt specifier for the sole interrupt.
 - interrupt-parent : the phandle for the interrupt controller that
   services interrupts for this device.
 - reg : The ID number for the phy, usually a small integer

这个reg并不是phy identifier,而应该是指网卡的index,所以说是small integer,因此我们先试一版把reg改为0和1。 结果两个网卡找不到,可见地址是对的,在驱动里查dp83848并没有什么描述符,可以删除ti dp83848字段。