网口调试记录

 一,vivado硬件配置

硬件连接

二, 驱动移植

Petalinux项目目录下的project-spec/meta-user/recipes-kernel/linux/linux-xlnx文件夹,打开xlnx-4.14文件夹。找到bsp.cfg文件,并添加以下内容,

CONFIG_B53_PHY=m
CONFIG_B53_PHY_PLATFORM_DRIVER=m
CONFIG_PHY_BCM54XX=m

在bsp.cfg中添加的CONFIG_*_DRIVER=m选项将会使得内核编译时包含相应的驱动作为模块。
上述配置将启用博通BCM54210S所需的驱动。
保存并关闭bsp.cfg文件。

petalinux-build

三,设备树节点移植

/include/ "system-conf.dtsi"


/include/ "zynq-7000.dtsi"

/ {


   chosen {
        bootargs = "console=ttyPS0,115200 earlyprintk";
    };

    aliases {
        ethernet0 =&gem0;
    };

};

     &gem0{
		    compatible = "cdns,zynq-gem";
		    status = "okay";
		    phy-mode = "rgmii";
		    phy-handle = <&phy0>;
		    local-mac-address = [00 0a 35 00 00 00];
		    xlnx,ptp-enet-clock = <0x1>;
		    xlnx,ptp-offset = <0x0>;
		    xlnx,ptp-pins = "0x0";
		    xlnx,ptp-clock-frequency = <0x1c9c380>;
			phy0: ethernet-phy@0 
			{
			    compatible = "ethernet-phy-ieee802.3-c22";
			    reg = <0x0>;
			    device_type = "ethernet-phy";
			    phy-mode = "rgmii-id";
			    max-speed = <1000>;
			    status = "okay";
			};
       };

四,加载博通BCM54210S所需的驱动

hw perfevents: no interrupt-affinity property for /pmu@f8891000, guessing.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
workingset: timestamp_bits=30 max_order=18 bucket_order=0
jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
bounce: pool size: 64 pages
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
io scheduler mq-deadline registered
io scheduler kyber registered
dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dmac:        DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
brd: module loaded
loop: module loaded
libphy: Fixed MDIO Bus: probed
CAN device driver interface
libphy: MACB_mii_bus: probed
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 25 (00:0a:35:00:22:01)
Generic PHY e000b000.ethernet-ffffffff:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=POLL)
e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
usbcore: registered new interface driver usb-storage
i2c /dev entries driver
IR NEC protocol handler initialized
IR RC5(x/sz) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
IR SANYO protocol handler initialized
IR Sharp protocol handler initialized
IR MCE Keyboard/mouse protocol handler initialized
IR XMP protocol handler initialized
cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at f0984000 with timeout 10s
EDAC MC: ECC not enabled
Xilinx Zynq CpuIdle Driver started
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
NET: Registered protocol family 10
Segment Routing with IPv6
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered protocol family 17
can: controller area network core (rev 20170425 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20170425)
can: broadcast manager protocol (rev 20170425 t)
can: netlink gateway (rev 20170425) max_hops=1
Registering SWP/SWPB emulation handler
hctosys: unable to open rtc device (rtc0)
of_cfs_init
of_cfs_init: OK

modprobe b53
modprobe b53_platform
modprobe phy_bcm54xx

五,芯片手册:

能确定的是,必须要匹配IEEE的网口驱动2023-11-17

报错mdio_register: non unique device name 'eth0'
project-spec/meta-user/recipes-kernel/linux/linux-xlnx文件夹,修改xlnx-4.14文件夹bsp.cfg

CONFIG_B53_PHY=m
CONFIG_B53_PHY_PLATFORM_DRIVER=m
CONFIG_PHY_BCM54XX=m
CONFIG_*_DRIVER=m
modprobe b53
modprobe b53_platform
modprobe phy_bcm54xx
/include/ "zynq-7000.dtsi";
/ {
chosen {
bootargs = "console=ttyPS0,115200 earlyprintk";
};

aliases {
ethernet0 = &gem0;
};

soc {
gem0: ethernet@e000b000 {
compatible = "cdns,zynq-gem";
status = "okay";
phy-mode = "rgmii";
phy-handle = <&phy0>;
local-mac-address = [00 0a 35 00 00 00];
xlnx,ptp-enet-clock = <0x1>;
xlnx,ptp-offset = <0x0>;
xlnx,ptp-pins = "0x0";
xlnx,ptp-clock-frequency = <0x1c9c380>;
};

phy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0x0>;
device_type = "ethernet-phy";
phy-mode = "rgmii-id";
max-speed = <1000>;
status = "okay";
};
};
};

找了一阵,没找到在驱动哪个位置hctosys: unable to open rtc device (rtc0)
of_cfs_init
of_cfs_init: OK
六,办法二:说明是自带博通支持的phy驱动
The Ethernet PHY driver is supported by the PHY vendor, and is available in AM57x PSDK linux kernel:

linux-4.14.79/drivers/net/phy/broadcom.c
linux-4.14.79/drivers/net/phy/bcm-phy-lib.c
新增编译:到\kernel\drivers\net\phy
obj-$(CONFIG_BCM63XX_PHY)    += bcm63xx.o
obj-$(CONFIG_BCM7XXX_PHY)    += bcm7xxx.o
obj-$(CONFIG_BCM87XX_PHY)    += bcm87xx.o
obj-$(CONFIG_BCM_CYGNUS_PHY)    += bcm-cygnus.o
obj-$(CONFIG_BCM_NET_PHYLIB)    += bcm-phy-lib.o

obj-$(CONFIG_MDIO_BCM_IPROC)    += mdio-bcm-iproc.o
obj-$(CONFIG_MDIO_BCM_UNIMAC)    += mdio-bcm-unimac.o
obj-$(CONFIG_MDIO_BITBANG)    += mdio-bitbang.o
obj-$(CONFIG_MDIO_BUS_MUX)    += mdio-mux.o
obj-$(CONFIG_MDIO_BUS_MUX_BCM_IPROC)    += mdio-mux-bcm-iproc.o
1,不加设备树不替换的结果只换phy网口不识别

2,加博通设备树和替换的结果:说明设备树写多了

 3,减少设备树内容,只匹配phy 

&gem0{	
		    status = "okay";
		    phy-handle = <&phy0>;
		    local-mac-address = [00 0a 35 00 00 00];
			phy0: ethernet-phy@0 
			{
			    compatible = "ethernet-phy-ieee802.3-c22";
			    reg = <0x0>;
			    device_type = "ethernet-phy";
			    max-speed = <1000>;
			    status = "okay";
			};
       };

 

4,只留常规phy

&gem0 {
    phy-handle = <&ethernet_phy>;
    local-mac-address = [00 0a 35 00 1e 53];
    ethernet_phy: ethernet-phy@1 {        
        reg = <0x1>;
        device_type = "ethernet-phy";
    };
}; 

七,问题分析:
-phy-is-integrated:如果设置,则表示PHY已集成到同一PHY中
物理包作为以太网MAC。如果需要,应配置多路复用器
确保使用集成的PHY。缺少此属性表示
应该配置复用器,以便使用外部PHY。
-reset-gpios:PHY复位信号的GPIO模板和说明符。
-reset-assert-us:复位生效后的延迟,以微秒为单位。
如果缺少此属性,则将跳过延迟。
-reset-deassert-us:复位无效后的延迟,以微秒为单位。
如果缺少此属性,则将跳过延迟。例:
ethernet-phy @ 0 {
兼容=“ ethernet-phy-id0141.0e90”,“ ethernet-phy-ieee802.3-c22”;
中断父母= <&PIC>;
中断= <35 IRQ_TYPE_EDGE_RISING>;
reg = <0>;
reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
reset-assert-us = <1000>;
reset-deassert-us = <2000>;
};
分析:是否缺少中断和复位信号,是必须引出来的

修改设备关于rtc时钟
只是能启动起来,看情况忘记了加入1588网口驱动编译进来。然后新建工程,加入1588驱动额rtc时钟正确设备树节点。结果只是不报错,但是显示驱动并没有加入匹配进来,ping不通。

解决方案:搜索内核配置选项

--- Real Time Clock (在device...目录下)
[*] Set system time from RTC on startup and resume 
(rtc0) RTC used to set the system time 
[ ] RTC debug support 
*** RTC interfaces *** 
[*] /sys/class/rtc/rtcN (sysfs) 
[*] /dev/rtcN (character devices) 
[ ] RTC UIE emulation on dev interface 
*** on-CPU RTC drivers *** 
<*> Samsung S3C series SoC RTC
且对比PPP.c驱动
然而并没有找到什么

八,搜索内核net全篇找不到ieee802154这个匹配节点:
compatible = "ethernet-phy-ieee802.3-c22";
解决思路:从github下载驱动代码编译进去

4.19版本都没有这个驱动,搜索了6.6版本(内核最高版本)才发现有这个驱动。

九,办法五:sdk裸机尝试看一下打印情况
里面没有对应驱动,想调先想着换更高版本的lwip库、支持BCM5421的LWIP库,网上半点影子都搜不出来。emac->type=3,它只有0和2两个适配选项,适配不进去的

 十,办法六:

 添加所有依赖  识别不了eth0

PHY Device support and infrastructure  ---> 

INIT: Entering runlevel: 5
Configuring network interfaces... 111111111111
~~phydev->autoneg~~~~~~~~~~
222222222
Unable to handle kernel NULL pointer dereference at virtual address 00000000
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops - BUG: 80000007 [#1] PREEMPT SMP ARM
Modules linked in: 

 手动操作复位

cd  /sys/class/gpio    MIO14  906+14
echo 920 > /sys/class/gpio/export
root@lwip:/sys/class/gpio# echo out > gpio920/direction
root@lwip:/sys/class/gpio# echo 0>gpio920/value
root@lwip:/sys/class/gpio# echo 1>gpio920/value
root@lwip:/sys/class/gpio# echo 0>gpio920/value
/lib/modules/4.14.0-xilinx/kernel/drivers/net/phy# 
modprobe  broadcom.ko
modprobe  bcm-phy-lib.ko

 中途改错误

十一,记录

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寒听雪落

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值