U-boot 内的网络无法使用

基本信息

U-Boot 2022.04-rc2-VisionFive-SDK_v2.3.3 (Jun 20 2022 - 07:25:30 +0000)StarFive

CPU:   rv64imafdc
Model: StarFive VisionFive V1
DRAM:  8 GiB
Core:  13 devices, 9 uclasses, devicetree: separate
MMC:   mmc@10000000: 0, mmc@10010000: 1
Loading Environment from SPIFlash... cadence_spi spi@11860000: Can't get reset: -524
SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
StarFive EEPROM format v1

--------EEPROM INFO--------
Vendor : StarFive Technology Co., Ltd. 
Product full SN: VF7100A1-2220-D008E000-00000731
data version: 0x1
PCB revision: 0x1
BOM revision: A 
Ethernet MAC address: 6c:cf:39:00:07:30
--------EEPROM INFO--------

环境

ethaddr=6c:cf:39:00:07:30
ipaddr=192.168.199.217
netmask=255.255.255.0
serverip=192.168.199.30

问题描述

ping 不通主机,输出信息如下:

VisionFive #ping 192.168.199.30
Speed: 100, full duplex
Using dwmac.10020000 device

ARP Retry count exceeded; starting again
ping failed; host 192.168.199.30 is not alive

你可以将uboot更新到下面这个链接版本吗?同一个环境分析问题可以排除环境因素。

我的测试环境,Server: win10,路由器:HUAWEI AX3Pro, 路由器跟server和开发板均是有线连接。

bootloader version:211102-0b86f96
ddr 0x00000000, 1M test
ddr 0x00100000, 2M test
DDR clk 2133M,Version: 211102-d086aee
0 crc flash: 7816e82f, crc ddr: 7816e82f
crc check PASSED

bootloader.

OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

fdt_reset_driver_init: gpio-restart init failed, -1001
Platform Name             : StarFive VisionFive V1
Platform Features         : medeleg
Platform HART Count       : 2
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 6250000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : ---
Platform Shutdown Device  : ---
Firmware Base             : 0x80000000
Firmware Size             : 300 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 0*,1*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 1
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsux
Boot HART Features        : scounteren,mcounteren
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4096
Boot HART PMP Address Bits: 36
Boot HART MHPM Count      : 2
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2022.04-rc2-VisionFive (Mar 07 2022 - 21:12:22 +0800)StarFive

CPU:   rv64imafdc
Model: StarFive VisionFive V1
DRAM:  8 GiB
Core:  13 devices, 9 uclasses, devicetree: separate
MMC:   mmc@10000000: 0, mmc@10010000: 1
Loading Environment from SPIFlash... cadence_spi spi@11860000: Can't get reset: -524
SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

StarFive EEPROM format v1

--------EEPROM INFO--------
Vendor : StarFive Technology Co., Ltd.
Product full SN: VF7100A1-2206-D008E000-00000262
data version: 0x1
PCB revision: 0x1
BOM revision: A
Ethernet MAC address: 6c:cf:39:00:02:61
--------EEPROM INFO--------

In:    serial@12440000
Out:   serial@12440000
Err:   serial@12440000
Net:   dwmac.10020000
MMC CD is 0x1, force to True.
MMC CD is 0x1, force to True.
Card did not respond to voltage select! : -110
MMC CD is 0x1, force to True.
MMC CD is 0x1, force to True.
Card did not respond to voltage select! : -110
VisionFive #setenv ipaddr 192.168.3.199;setenv serverip 192.168.3.99
VisionFive #ping 192.168.3.99
Speed: 1000, full duplex
Using dwmac.10020000 device
host 192.168.3.99 is alive
VisionFive #
Speed: 1000, full duplex
Using dwmac.10020000 device
host 192.168.3.99 is alive
VisionFive #
Speed: 1000, full duplex
Using dwmac.10020000 device
host 192.168.3.99 is alive
VisionFive #

您好,感谢回复。

试了这一版 u-boot 依旧无法 ping 通主机。

ps:我测试过了网络环境肯定没问题。

你有没有在板子上测试过Fedora系统,在系统下能联网吗?

没有,目前正在 u-boot 环境测试。

建议您可以在TF卡上刷个Fedora系统,看下fedora系统下是否能联网,这样可以排查下网络硬件方面的问题。

谢谢帮助,在 Fedora 系统下,网络是正常。

再次进入 u-boot 使用 ping 命令的报错和之前不一样了:

dwmac.10020000 Waiting for PHY auto negotiation to complete......... TIMEOUT !

我当前的需求是在 u-boot 下面使用网络,请问我还能做点什么帮助排查问题。

你的server是什么环境?是win还是ubuntu或是其它?
server的防火墙关了吗?
开发板跟server是网线直连还是通过路由器?

Sever 是 Ubuntu 无防火墙。

板子和 Server 之间通过路由器连接的。

我可以再试一试直连。

我试了下直连,结果如下:

server 网口是千兆,板子和 server 直连后协商为千兆连接,网络可以通。

VisionFive #ping 192.168.199.30
Speed: 1000, full duplex
Using dwmac.10020000 device
host 192.168.199.30 is alive

但是通过路由器连接,路由器上的网口是百兆,虽然 u-boot 上显示协商成了百兆但是网络是不通的。

在 Fedora 系统里面,板子连接到路由器上也协商成了百兆,网络却是通的。

我之前用家里的tplink路由器也碰到过这个情况,ping不同,后来改成网线直连了 :sweat_smile:,是不是路由器上需要设置啥

有可能是 u-boot 里面的驱动对百兆网络的支持不好。

我们会看看能不能复现,查一下这个问题,您可以先用网线直连的方式。

你好,帮忙把uboot下所有的环境变量打出来看看

arch=riscv
baudrate=115200
board=jh7100
board_name=jh7100
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootriscv64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=dhcp mmc0 
bootcmd_dhcp=devtype=dhcp; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00027:UNDI:003000;setenv bootp_arch 0x1b;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_mmc0=devnum=0; run mmc_boot
bootdelay=2
bootdir=/boot
bootenv=uEnv.txt
bootpart=0:3
cpu=fu740
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethact=dwmac.10020000
ethaddr=6c:cf:39:00:07:30
ext4bootenv=ext4load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootenv}
fatenv=fatload mmc ${testpart} ${loadaddr} ${testenv};env import -t ${loadaddr} ${filesize}
fdtcontroladdr=ff6ea560
fdtfile=starfive/jh7100-visionfive.dtb
fdtsetup=fdt addr ${fdtcontroladdr}
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
ipaddr=192.168.199.217
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0xa0000000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
mmcbootenv=setenv bootpart ${mmcdev}:${mmcpart}; mmc dev ${mmcdev}; if mmc rescan; then run loadbootenv && run importbootenv; run ext4bootenv && run importbootenv; if test -n $uenvcmd; then echo Running uenvcmd ...; run uenvcmd; fi; fi
mmcdev=0
mmcpart=3
mmcsetup=mmc part
netmask=255.255.255.0
preboot=run mmcbootenv
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootriscv64.efi; then echo Found EFI removable media binary efi/boot/bootriscv64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scan_sf_for_scripts=${devtype} read ${scriptaddr} ${script_offset_f} ${script_size_f}; source ${scriptaddr}; echo SCRIPT FAILED: continuing...
serial#=VF7100A1-2220-D008E000-00000731
serverip=192.168.199.30
sf_boot=if sf probe ${busnum}; then devtype=sf; run scan_sf_for_scripts; fi
soc=jh7100
stderr=serial@12440000
stdin=serial@12440000
stdout=serial@12440000
testenv=u74_uEnv.txt
testpart=0:1
vendor=starfive
ver=U-Boot 2022.04-rc2-VisionFive-SDK_v2.3.3 (Jun 20 2022 - 07:25:30 +0000)StarFive

Environment size: 4435/126972 bytes
VisionFive #