当前位置:   article > 正文

【迅为iMX6Q】开发板 u-boot 2020.04 RTL8211E 以太网驱动适配_rtl8211e-vl速度驱动函数

rtl8211e-vl速度驱动函数

相关参考

【迅为iMX6Q】开发板 u-boot 2015.04 SD卡 启动

【迅为iMX6Q】开发板 u-boot 2020.04 SD卡 启动

【迅为iMX6Q】开发板 u-boot 2022.04 SD卡 启动

开发环境

  • win10 64位

  • VMware Workstation Pro 16

  • ubuntu 22.04

  • 【迅为imx6q】开发板, 2G DDR

目标

  • 调通 u-boot 下的 以太网驱动,通过迅为imx6q 开发板原理图,发现以太网 PHY 使用的是:RTL8211E

在这里插入图片描述

适配方法

  • u-boot 2020.04 board 适配,源自 board/freescale/mx6sabresd/,默认以太网 PHY 不是 RTL8211E,而是 ATHEROSAR8031

  • 所以开机后, u-boot 打印提示找不到 PHY, 信息如:Net: Could not get PHY for FEC0: addr 0

U-Boot 2020.04-00020-ga68db489ce (Jan 08 2023 - 21:44:16 +0800)

CPU:   i.MX6Q rev1.3 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 32C
Reset cause: POR
Model: i.MX6 Quad Topeet Smart Device Board
Board: MX6-topeet
DRAM:  2 GiB
MMC:   FSL_SDHC: 1, FSL_SDHC: 2, FSL_SDHC: 3
Loading Environment from MMC... OK
No panel detected: default to Hannstar-XGA
Display: Hannstar-XGA (1024x768)
In:    serial
Out:   serial
Err:   serial
flash target is MMC:1
Net:   Could not get PHY for FEC0: addr 0
Could not get PHY for FEC0: addr 0
No ethernet found.

Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 更改 PHY 的型号,可以通过 menuconfig 配置,当前直接在 头文件 include/configs/mx6sabre_common.h 中定义了 #define CONFIG_PHY_ATHEROS

修改一、增加 mx6q_topeet_common.h

  • 复制一份 include/configs/mx6sabre_common.hinclude/configs/mx6q_topeet_common.h

修改二、mx6q_topeet.h

  • include/configs/mx6q_topeet.h,更改包含的头文件:#include "mx6sabre_common.h" 改为 #include "mx6q_topeet_common.h"

在这里插入图片描述

在这里插入图片描述

修改三、增加RTL8211E 驱动宏定义

  • 修改 include/configs/mx6q_topeet_common.h

#define CONFIG_PHY_ATHEROS 改为 #define CONFIG_PHY_REALTEK

  • 新增 #define CONFIG_FEC_MXC_PHYADDR 0

在这里插入图片描述

修改四、 增加PHY 复位的 delay

  • 经过测试,发现以上修改 PHY 型号后,以太网驱动依旧提示找不到 PHY,需要修改设备树文件,增加 phy 复位的 delay

  • 修改 arch/arm/dts/imx6qdl-topeet.dtsi,如下

&fec {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_enet>;
	phy-mode = "rgmii";
	phy-reset-gpios = <&gpio1 25 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <10>;
	phy-reset-post-delay = <100>;
	fsl,magic-packet;
	status = "okay";
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 也就是在 @fec 设备树节点,增加
   phy-reset-duration = <10>;
   phy-reset-post-delay = <100>;
  • 1
  • 2

在这里插入图片描述

重新配置并编译

  • 重新配置并编译 u-boot,烧写到 sd 卡中验证

  • make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- mx6q_topeet_defconfig

  • make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- -j4

  • 通过 ubuntu 烧写到 sd 卡中

  • sudo dd if=u-boot-dtb.imx of=/dev/sdc bs=512 seek=2 && sync,注意 /dev/sdc 是 sd 卡在 ubuntu 下识别的设备,可能不一样,不要搞错

启动信息

  • 第一次启动 u-boot 后,需要设置一些 env 网络相关的参数,开发板需要通过网线,连接到【路由器】,或者通过交叉网线,直接连接到【电脑】。电脑与开发板,应该在同一个网段

  • 开机进入 u-boot 命令行,输入如下命令

  • 设置 ethaddr setenv ethaddr '0e:b4:00:52:24:0e'

  • 设置 serverip setenv serverip '192.168.1.100'

  • 设置 ipaddr setenv ipaddr '192.168.1.110'

  • 设置 netmask setenv netmask '255.255.255.0'

  • 设置 gatewayip setenv gatewayip '192.168.1.1'

  • 最后 saveenv 保存 env 设置,并 reset 重启

=> setenv ethaddr '0e:b4:00:52:24:0e'
=> setenv serverip '192.168.1.100'
=> setenv ipaddr '192.168.1.110'
=> setenv netmask '255.255.255.0'
=> setenv gatewayip '192.168.1.1'

=> saveenv
Saving Environment to MMC... Writing to MMC(1)... OK

=> reset
resetting ...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

验证u-boot 下网络

  • 通过 ping 命令验证

  • ping 路由器网关地址,如

=> ping 192.168.1.1
Using ethernet@02188000 device
host 192.168.1.1 is alive
  • 1
  • 2
  • 3
  • ping 电脑的 ip 地址
=> ping 192.168.1.100
Using ethernet@02188000 device
host 192.168.1.100 is alive
  • 1
  • 2
  • 3
  • 说明【迅为iMX6Q】开发板 u-boot 2020.04 下的 以太网驱动,适配成功

u-boot 启动信息

U-Boot 2020.04-00021-g5802f0b622 (Jan 08 2023 - 21:48:15 +0800)

CPU:   i.MX6Q rev1.3 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 41C
Reset cause: POR
Model: i.MX6 Quad Topeet Smart Device Board
Board: MX6-topeet
DRAM:  2 GiB
MMC:   FSL_SDHC: 1, FSL_SDHC: 2, FSL_SDHC: 3
Loading Environment from MMC... OK
No panel detected: default to Hannstar-XGA
Display: Hannstar-XGA (1024x768)
In:    serial
Out:   serial
Err:   serial
flash target is MMC:1
Net:   eth0: ethernet@02188000 [PRIME]
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
=>
=>
=> printenv
baudrate=115200
board_name=TOPEET
board_rev=MX6Q
boot_fdt=try
bootargs=console=ttymxc0,115200 root=/dev/mmcblk1p3 rootwait rw
bootcmd=ext4load mmc 1:1 0x18000000 imx6q-topeet.dtb; ext4load mmc 1:1  0x12000000 zImage; bootz 0x12000000 - 0x18000000
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else bootz ${loadaddr} ${initrd_addr} ${fdt_addr}; fi; else echo "Run fastboot ..."; fastboot 0; fi;
bootdelay=3
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
dfu_alt_info=spl raw 0x400
dfu_alt_info_img=u-boot raw 0x10000
dfu_alt_info_spl=spl raw 0x400
dfuspi=dfu 0 sf 0:0:10000000:0
emmc_dev=3
emmcdev=2
epdc_waveform=epdc_splash.bin
ethact=ethernet@02188000
ethaddr=0e:b4:00:52:24:0e
ethprime=eth0
fastboot_dev=mmc1
fdt_addr=0x18000000
fdt_file=imx6q-topeet.dtb
fdt_high=0xffffffff
fdtcontroladdr=8df5f1a8
fileaddr=18000000
filesize=cedc
findfdt=if test $fdt_file = undefined; then if test $board_name = SABREAUTO && test $board_rev = MX6QP; then setenv fdt_file imx6qp-sabreauto.dtb; fi; if test $board_name = SABREAUTO && test $board_rev = MX6Q; then setenv fdt_file imx6q-sabreauto.dtb; fi; if test $board_name = SABREAUTO && test $board_rev = MX6DL; then setenv fdt_file imx6dl-sabreauto.dtb; fi; if test $board_name = SABRESD && test $board_rev = MX6QP; then setenv fdt_file imx6qp-sabresd.dtb; fi; if test $board_name = SABRESD && test $board_rev = MX6Q; then setenv fdt_file imx6q-sabresd.dtb; fi; if test $board_name = SABRESD && test $board_rev = MX6DL; then setenv fdt_file imx6dl-sabresd.dtb; fi; if test $fdt_file = undefined; then echo WARNING: Could not determine dtb to use; fi; fi;
findtee=if test $tee_file = undefined; then if test $board_name = SABREAUTO && test $board_rev = MX6QP; then setenv tee_file uTee-6qpauto; fi; if test $board_name = SABREAUTO && test $board_rev = MX6Q; then setenv tee_file uTee-6qauto; fi; if test $board_name = SABREAUTO && test $board_rev = MX6DL; then setenv tee_file uTee-6dlauto; fi; if test $board_name = SABRESD && test $board_rev = MX6QP; then setenv tee_file uTee-6qpsdb; fi; if test $board_name = SABRESD && test $board_rev = MX6Q; then setenv tee_file uTee-6qsdb; fi; if test $board_name = SABRESD && test $board_rev = MX6DL; then setenv tee_file uTee-6dlsdb; fi; if test $tee_file = undefined; then echo WARNING: Could not determine tee to use; fi; fi;
finduuid=part uuid mmc ${mmcdev}:2 uuid
gatewayip=192.168.1.1
get_cmd=dhcp
image=zImage
initrd_addr=0x12C00000
initrd_high=0xffffffff
ip_dyn=yes
ipaddr=192.168.1.110
kboot=bootz
loadaddr=0x12000000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
loadtee=fatload mmc ${mmcdev}:${mmcpart} ${tee_addr} ${tee_file}
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc clk_ignore_unused
mmcargs=setenv bootargs console=${console},${baudrate} ${smp} root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${tee} = yes; then run loadfdt; run loadtee; bootm ${tee_addr} - ${fdt_addr}; else if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;fi;
mmcdev=1
mmcpart=1
mmcroot=/dev/mmcblk1p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} ${smp} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${tee} = yes; then ${get_cmd} ${tee_addr} ${tee_file}; ${get_cmd} ${fdt_addr} ${fdt_file}; bootm ${tee_addr} - ${fdt_addr}; else if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi; fi;
netmask=255.255.255.0
script=boot.scr
sd_dev=2
serial#=170da1d4ee695b4c
serverip=192.168.1.100
soc_type=imx6q
spi_bus=0
spi_uboot=0x400
splashimage=0x28000000
tee=no
tee_addr=0x20000000
tee_file=undefined
update_emmc_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if ${get_cmd} ${update_sd_firmware_filename}; then if mmc dev ${emmcdev} 1; then setexpr fw_sz ${filesize} / 0x200; setexpr fw_sz ${fw_sz} + 1; mmc write ${loadaddr} 0x2 ${fw_sz}; fi; fi
update_sd_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if mmc dev ${mmcdev}; then if ${get_cmd} ${update_sd_firmware_filename}; then setexpr fw_sz ${filesize} / 0x200; setexpr fw_sz ${fw_sz} + 1; mmc write ${loadaddr} 0x2 ${fw_sz}; fi; fi
weim_base=0x08000000
weim_uboot=0x08001000

Environment size: 4962/8188 bytes
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93

小结

  • 适配 u-boot 下的以太网驱动,除了对照原理图,确认以太网驱动PHY 的 引脚配置,还需确认 u-boot 下配置的 PHY 型号是否一致,如【迅为imx6q】开发板,以太网 PHY 是 REALTEKRTL8211E

  • 以太网驱动 PHY,一般都需要 复位操作,增加delay 操作,新版本的u-boot,需要在设备树文件中增加。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/292733
推荐阅读
相关标签
  

闽ICP备14008679号