我用STM32F407VET按照原子的电路自己画的电路板,LAN8720电路基本一致,程序跑起来后遇到问题,如果我把板子网线接到HUB集线器,是可以dhcp自动拿到IP地址的,用同网段其它PC是可以ping通板子的,可如果我将板子网线接到路由器上,却什么也拿不到了,我打开了DHCP、ARP的调试开关,在接HUB集线器时是可以看到arp包的接收的,但接到路由器上时,arp包都没看到接收了。后按原子哥的方法直连到PC机(设置了PC固定IP同板子在同一网段),同样也看到不到接收arp包,此时可以看到PC端以太网状态灯闪烁亮了差不多1分钟左右,然后状态灯就灭了此后不再显示。同样也是不能ping通的。下面是LAN8720图
连接到HUB集线器时,LWIP自动获取IP信息:
LAN8720初始化成功...
netif: IP address of interface 【2015-12-19 11:20:58(872)收到】 starting new DHCP client
dhcp_start(): allocated dhcpdhcp_start(): starting DHCP configuration
dhcp_discover()
transaction id xid(abcd0001)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs
netif: setting default interface en
etharp_request: sending ARP request.
etharp_raw: sending raw ARP packet.
LWIP Init Success!
DHCP IP configing...
dhcp_st
【2015-12-19 11:20:58(925)收到】art(netif=2001d834) en 0
dhcp_start(): restarting DHCP configuration
dhcp_start(): starting DHCP configuration
dhcp_discover()
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs
正在查找DHCP服务器,请稍等...........
【2015-12-19 11:21:00(919)收到】dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): restarting discovery
dhcp_discover()
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 4000 msecs
ETH_IRQHandler
receive lwip_pkt_handle....
ethernet_input: dest:02:00:00:25:00:27, src:20:f4:1b:90:d2:
【2015-12-19 11:21:00(974)收到】68, type: 800
dhcp_recv(pbuf = 20017c48) from DHCP server 192. 168. 11. 4 port 67
pbuf->len = 300
pbuf->tot_len = 300
skipping option 28 in options
searching DHCP_OPTION_MESSAGE_TYPE
DHCP_OFFER received in DHCP_SELECTING state
dhcp_handle_offer(netif=2001d834) en 0
dhcp_handle_offer(): server 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000040ba8c0
dhcp_handle_offer(): offer for 0x000000000000000000000000000000000000000000000000000000000000000000000000000000005f0ba8c0
dhcp_select(netif=2001d834) en 0
transaction id xid(abc
【2015-12-19 11:21:01(030)收到】d0003)
etharp_send_ip: sending packet 20010ad0
dhcp_select: REQUESTING
dhcp_select(): set request timeout 2000 msecs
receive lwip_pkt_handle....
ethernet_input: dest:02:00:00:25:00:27, src:20:f4:1b:90:d2:68, type: 800
dhcp_recv(pbuf = 20017c48) from DHCP server 192. 168. 11. 4 port 67
pbuf->len = 300
pbuf->tot_len = 300
skipping option 28 in options
searching DHCP_OPTION_MESSAGE_TYPE
DHCP_ACK received
dhcp_check(netif=2001d834) en
etharp_find_entry: found empty entry 0
etharp_find_entry: selecting empty entry 0
etharp_request: sending ARP request.
etharp_raw: s
【2015-12-19 11:21:01(088)收到】ending raw ARP packet.
dhcp_check(): set request timeout 500 msecs
【2015-12-19 11:21:01(529)收到】dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): CHECKING, ARP request timed out
dhcp_check(netif=2001d834) en
etharp_find_entry: found matching entry 0
etharp_request: sending ARP request.
etharp_raw: sending raw ARP packet.
dhcp_check(): set request timeout 500 msecs
【2015-12-19 11:21:01(635)收到】ETH_IRQHandler
receive lwip_pkt_handle....
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:10:48:b1:d7:69:73, type: 800
【2015-12-19 11:21:01(942)收到】ETH_IRQHandler
receive lwip_pkt_handle....
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:a0:a8:cd:20:7c:68, type: 800
【2015-12-19 11:21:02(029)收到】dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): CHECKING, ARP request timed out
dhcp_bind(netif=2001d834) en 0
dhcp_bind(): t1 renewal timer 3600 secs
dhcp_bind(): set request timeout 3600000 msecs
dhcp_bind(): t2 rebind timer 6300 secs
dhcp_bind(): set request timeout 6300000 msecs
dhcp_bind(): IP: 0x000000000000000000000000000000000000000000000000000000000000000000000000000000005f0ba8c0
netif_set_ipaddr: netif address being changed
netif: IP address of interface en set to 192. 168. 11. 95
d
【2015-12-19 11:21:02(085)收到】hcp_bind(): SN: 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff
netif: netmask of interface en set to 255. 255. 255. 0
dhcp_bind(): GW: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000040ba8c0
netif: GW address of interface en set to 192. 168. 11. 4
网卡en的MAC地址为:................2.0.0.37.0.39
通过DHCP获取到IP地址..............192.168.11.95
通过DHCP获取到子网掩码............255.255.255.0
通过DHCP获取到的默认网关..........192.168.11.4
MAC :2.0.0.37.0.39
Static IP:192.168.11.95
Static GW:192
连接到路由器时,LWIP自动获取IP信息:
LAN8720初始化成功...
netif: IP address of interface 【2015-12-19 10:41:30(029)收到】 starting new DHCP client
dhcp_start(): allocated dhcpdhcp_start(): starting DHCP configuration
dhcp_discover()
transaction id xid(abcd0001)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs
netif: setting default interface en
etharp_request: sending ARP request.
etharp_raw: sending raw ARP packet.
LWIP Init Success!
DHCP IP configing...
dhcp_start(neti
【2015-12-19 10:41:30(082)收到】f=2001d834) en 0
dhcp_start(): restarting DHCP configuration
dhcp_start(): starting DHCP configuration
dhcp_discover()
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs
正在查找DHCP服务器,请稍等...........
【2015-12-19 10:41:32(075)收到】dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): restarting discovery
dhcp_discover()
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 4000 msecs
【2015-12-19 10:41:33(306)收到】etharp_timer
【2015-12-19 10:41:36(076)收到】dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): restarting discovery
dhcp_discover()
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 8000 msecs
【2015-12-19 10:41:38(306)收到】etharp_timer
【2015-12-19 10:41:43(307)收到】etharp_timer
【2015-12-19 10:41:44(077)收到】dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): restarting discovery
dhcp_discover()
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 16000 msecs
【2015-12-19 10:41:48(308)收到】etharp_timer
【2015-12-19 10:41:53(308)收到】etharp_timer
【2015-12-19 10:41:58(309)收到】etharp_timer
【2015-12-19 10:42:00(079)收到】dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): restarting discovery
dhcp_discover()
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
etharp_send_ip: sending packet 20010ad0
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 32000 msecs
DHCP服务超时,使用静态IP地址!
网卡en的MAC地址为:................2.0.0.37.0.39
静态IP地址........................192.168.1.210
【2015-12-19 10:42:00(138)收到】子网掩码..........................255.255.255.0
默认网关..........................192.168.1.1
MAC :2.0.0.37.0.39
Static IP:192.168.1.210
Static GW:192.168.1.1
Static IP:255.255.255.0
不知道这是什么原因,请大师指点。谢谢。
一周热门 更多>