STM32F407VET6 + IP101GRI网络移植后ping不成功

发布于 2019-08-16 23:31:14    浏览:1397
硬件:
主控:SMT32F407VET6
PHY: IP101GRI

软件:
系统:已经参考教程移植系统成功
网络:已经根据教程修改了寄存器的地址,使用静态IP调试

目前的现象:

1.接上路由器后,路由器的RJ45灯亮,但闪烁较慢
2.使用wireshark抓不到任何终端发送出来的数据包
3.网络驱动的调试日志如下:会出现receive frame faild的错误

\ | /
- RT - Thread Operating System
/ | \ 4.0.2 build Aug 16 2019
2006 - 2019 Copyright by rt-thread team
lwIP-2.0.2 initialized!
[53] D/drv.emac: eth hardware init success
[60] D/drv.emac: emac hardware start
[64] D/drv.emac: emac device init success
[68] I/sal.skt: Socket Abstraction Layer initialize success.
[75] D/main: start
msh />[78] D/drv.emac: PHY ID1:0x0243
[1081] D/drv.emac: Found a phy, address:0x01
[1085] D/drv.emac: RESET PHY!
[3088] D/drv.emac: PHY BASIC STATUS REG:0x7849
[4092] D/drv.emac: PHY BASIC STATUS REG:0x7849
[5096] D/drv.emac: PHY BASIC STATUS REG:0x7849
[6100] D/drv.emac: PHY BASIC STATUS REG:0x7849
[7104] D/drv.emac: PHY BASIC STATUS REG:0x7849
[8108] D/drv.emac: PHY BASIC STATUS REG:0x7849
[9112] D/drv.emac: PHY BASIC STATUS REG:0x786D
[9116] D/drv.emac: PHY Control/Status REG:0x0105
[9121] D/drv.emac: link up
[9124] D/drv.emac: 10Mbps
[9127] D/drv.emac: full-duplex
00000000: FF FF FF FF FF FF 00 80 E1 08 34 54 08 06 00 01 ..........4T....
00000010: 08 00 06 04 00 01 00 80 E1 08 34 54 C0 A8 1F FD ..........4T....
00000020: 00 00 00 00 00 00 C0 A8 1F FD ..........
[9152] D/drv.emac: transmit frame lenth :42
[9156] D/drv.emac: receive frame faild
[10160] D/drv.emac: PHY BASIC STATUS REG:0x786D
[10164] D/drv.emac: PHY Control/Status REG:0x0105

4.LWIP的调试日志如下:
 \ | /
- RT - Thread Operating System
/ | \ 4.0.2 build Aug 16 2019
2006 - 2019 Copyright by rt-thread team
igmp_init: initializing
dns_init: initializing
lwIP-2.0.2 initialized!
netif: netmask of interface e0 set to 255.255.255.0
netif: GW address of interface e0 set to 192.168.31.1
netif_set_ipaddr: netif address being changed
netif: IP address of interface e0 set to 192.168.31.253
netif: setting default interface e0
igmp_start: starting IGMP processing on if 2000fab4
igmp_lookup_group: allocated a new group with address 224.0.0.1 on if 2000fab4
netif: added interface e0 IP addr 192.168.31.253 netmask 255.255.255.0 gw 192.168.31.1
[106] I/sal.skt: Socket Abstraction Layer initialize success.
[113] D/main: start
msh />etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_timer
dns_tmr: dns_check_entries
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 200114a4
etharp_raw: sending raw ARP packet.
pbuf_header: old 200114c4 new 200114b6 (14)
ethernet_output: sending packet 200114a4
pbuf_free(200114a4)
pbuf_free: deallocating 200114a4
igmp_report_groups: sending IGMP reports on if 2000fab4
etharp_timer
dns_tmr: dns_check_entries
tcpip_thread: CALLBACK 20002f94
lwip_gethostbyname(link.rt-thread.org) failed, err=-6
etharp_timer
dns_tmr: dns_check_entries
etharp_timer

5.使用list_thread查看,接收和发送线程有运行
msh />list_thread
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
tshell 20 running 0x00000200 0x00000800 25% 0x0000000a 000
sys_work 23 suspend 0x0000005c 0x00000800 21% 0x0000000a 000
phy 30 suspend 0x00000088 0x00000400 18% 0x00000002 000
tcpip 10 suspend 0x000000c4 0x00000400 19% 0x00000014 000
etx 12 suspend 0x00000094 0x00000400 14% 0x00000010 000
erx 12 suspend 0x00000094 0x00000400 42% 0x00000010 000
tidle0 31 ready 0x00000048 0x00000400 08% 0x00000008 000
main 10 suspend 0x0000008c 0x00000400 53% 0x00000005 000

6.使用ifconfig查看,因为使用静态IP所以可以显示预设的IP和网关及子掩码

7.Ping路由器的话会全部超时

自我分析:
1.网口灯会亮且能协商速率成功,PHY芯片应该配置成功了。
2.但无法发送和接收数据是否LWIP有问题?

问题需求:
1. 已经排查一天,因对RT-Thread不是很了解,暂时不知道从哪些方面去排查问题。
2. 麻烦大家给我指明可能存在的问题

查看更多

5 个回答
aozima
aozima 2019-08-16
拒绝白嫖,拒绝键盘侠!
日志只看到发包没看到收包,速度识别为10M,感觉硬件有问题,一般都是100M全双工的。
suhuangjian
suhuangjian 2019-08-20
This guy hasn't written anything yet
aozima 发表于 2019-8-17 00:31
日志只看到发包没看到收包,速度识别为10M,感觉硬件有问题,一般都是100M全双工的。 ...

我修改了drv_eth.c中的rt_stm32_eth_init(rt_device_t dev)函数的中的EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;

现在ping能够ping通,但会丢包,调试日志发现很多接收失败的报文
[140734] D/drv.emac: PHY Control/Status REG:0x0105
[141209] D/drv.emac: receive frame len : 74
[141214] D/drv.emac: receive frame faild
[141218] D/drv.emac: transmit frame lenth :74
[141740] D/drv.emac: PHY BASIC STATUS REG:0x786D
[141744] D/drv.emac: PHY Control/Status REG:0x0105
[142216] D/drv.emac: receive frame len : 74
[142220] D/drv.emac: receive frame faild
[142224] D/drv.emac: transmit frame lenth :74
[142750] D/drv.emac: PHY BASIC STATUS REG:0x786D
[142754] D/drv.emac: PHY Control/Status REG:0x0105
[143223] D/drv.emac: receive frame len : 74
[143227] D/drv.emac: receive frame faild
[143231] D/drv.emac: transmit frame lenth :74
[143760] D/drv.emac: PHY BASIC STATUS REG:0x786D
[143764] D/drv.emac: PHY Control/Status REG:0x0105
[144230] D/drv.emac: receive frame len : 74
[144234] D/drv.emac: receive frame faild
[144238] D/drv.emac: transmit frame lenth :74
[144770] D/drv.emac: PHY BASIC STATUS REG:0x786D
[144774] D/drv.emac: PHY Control/Status REG:0x0105
[145236] D/drv.emac: receive frame len : 74
[145241] D/drv.emac: receive frame faild
[145245] D/drv.emac: transmit frame lenth :74
[145780] D/drv.emac: PHY BASIC STATUS REG:0x786D
[145784] D/drv.emac: PHY Control/Status REG:0x0105
[146243] D/drv.emac: receive frame len : 74
[146247] D/drv.emac: receive frame faild
[146251] D/drv.emac: transmit frame lenth :74
[146790] D/drv.emac: PHY BASIC STATUS REG:0x786D
[146794] D/drv.emac: PHY Control/Status REG:0x0105
summerxyh
summerxyh 2019-08-20
This guy hasn't written anything yet
有同样的问题,ping的时候,对方计算机上可以抓到接收的包,但板子收不到对方发过来的数据包
suhuangjian
suhuangjian 2019-08-22
This guy hasn't written anything yet
已解决,MCO1的时钟使用了HSI,设置成PLLCLK后网络就稳定了。
aozima
aozima 2019-08-22
拒绝白嫖,拒绝键盘侠!
suhuangjian 发表于 2019-8-22 15:56
已解决,MCO1的时钟使用了HSI,设置成PLLCLK后网络就稳定了。


哈哈,HSI竟然还通了,也是神奇。
肯定是协商为10Mbps了,100Mbps时要求时钟好像是50ppm,必须石英晶振。

撰写答案

请登录后再发布答案,点击登录
关注者
0
被浏览
1.4k

发布
问题

分享
好友

手机
浏览

扫码手机浏览