硬汉嵌入式论坛

 找回密码
 立即注册
查看: 474|回复: 3
收起左侧

[LwIP] 求助,H743+CubMx+LWIP+8720,识别到连接但是ping不通

[复制链接]
回帖奖励 25 个金币 回复本帖可获得 5 个金币奖励! 每人限 1 次

1

主题

3

回帖

6

积分

新手上路

积分
6
发表于 2025-3-19 09:40:19 | 显示全部楼层 |阅读模式
本帖最后由 sange666~ 于 2025-3-19 10:01 编辑

已经搞了一天了,情况如下:

1、主芯片是STM32H743VGT6,PHY是LAN8720,用CubMx生成的工程,LWIP版本是2.12;
2、CubMx设置如下:



3、MPU是参照硬汉哥的,没有开Cache,配置如下:

/* USER CODE BEGIN 4 */
void MPU_Config(void)
{
                MPU_Region_InitTypeDef MPU_InitStruct;
        /* 禁止 MPU */
        HAL_MPU_Disable();
         /* 配置 AXI SRAM 的 MPU 属性为 Write back, Read allocate,Write allocate */
        MPU_InitStruct.Enable = MPU_REGION_ENABLE;
        MPU_InitStruct.BaseAddress = 0x24000000;
        MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;
        MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
        MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
        MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
        MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
        MPU_InitStruct.Number = MPU_REGION_NUMBER0;
        MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
        MPU_InitStruct.SubRegionDisable = 0x00;
        MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
        HAL_MPU_ConfigRegion(&MPU_InitStruct);
        /* 配置 SRAM1 的属性为 Write through, read allocate,no write allocate */
         MPU_InitStruct.Enable = MPU_REGION_ENABLE;
         MPU_InitStruct.BaseAddress = 0x30000000;
         MPU_InitStruct.Size = ARM_MPU_REGION_SIZE_128KB;
         MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
         MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
         MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
         MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
         MPU_InitStruct.Number = MPU_REGION_NUMBER1;
         MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
         MPU_InitStruct.SubRegionDisable = 0x00;
         MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
         HAL_MPU_ConfigRegion(&MPU_InitStruct);
         /* 配置 SRAM2 的属性为 Write through, read allocate,no write allocate */
         MPU_InitStruct.Enable = MPU_REGION_ENABLE;
         MPU_InitStruct.BaseAddress = 0x30020000;
         MPU_InitStruct.Size = ARM_MPU_REGION_SIZE_128KB;
         MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
         MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
         MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
         MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
         MPU_InitStruct.Number = MPU_REGION_NUMBER2;
         MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
         MPU_InitStruct.SubRegionDisable = 0x00;
         MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
         HAL_MPU_ConfigRegion(&MPU_InitStruct);
         
                 /* 配置以太网收发描述符部分为Device */
                MPU_InitStruct.Enable = MPU_REGION_ENABLE;
                MPU_InitStruct.BaseAddress = 0x30040000;
                MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
                MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
                MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
                MPU_InitStruct.IsCacheable  = MPU_ACCESS_NOT_CACHEABLE;
                MPU_InitStruct.IsShareable  = MPU_ACCESS_SHAREABLE;
                MPU_InitStruct.Number = MPU_REGION_NUMBER3;
                MPU_InitStruct.SubRegionDisable = 0x0;
                MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
                MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
                HAL_MPU_ConfigRegion(&MPU_InitStruct);
               
         /* 配置 SRAM3 的属性为 Write through, read allocate,no write allocate */
         MPU_InitStruct.Enable = MPU_REGION_ENABLE;
         MPU_InitStruct.BaseAddress = 0x30044000;
         MPU_InitStruct.Size = ARM_MPU_REGION_SIZE_16KB;
         MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
         MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
         MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
         MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
         MPU_InitStruct.Number = MPU_REGION_NUMBER4;
         MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
         MPU_InitStruct.SubRegionDisable = 0x00;
         MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
         HAL_MPU_ConfigRegion(&MPU_InitStruct);
         
        /* 配置 SRAM4 的属性为 Write through, read allocate,no write allocate */
         MPU_InitStruct.Enable = MPU_REGION_ENABLE;
         MPU_InitStruct.BaseAddress = 0x38000000;
         MPU_InitStruct.Size = ARM_MPU_REGION_SIZE_64KB;
         MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
         MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
         MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
         MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
         MPU_InitStruct.Number = MPU_REGION_NUMBER5;
         MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
         MPU_InitStruct.SubRegionDisable = 0x00;
         MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
         HAL_MPU_ConfigRegion(&MPU_InitStruct);
                /*使能 MPU */
                HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}
/* USER CODE END 4 */

4、内存使用,由于生成的工程把所有变量都放在了0x200000000,或者0x24000000,我后来改了sct文件,把描述符和一些mem的都挪到D2,D3了。map文件和sct文件截图如下:


5、串口打印显示连接需要大概1秒多点,100M全双工,电脑直连ping的时候,打印信息显示能收到包,但是不知道为啥不回复,打印信息和抓包如下,MCUip是201,电脑是220:


[2025-03-19 09:32:57.965]# RECV ASCII>
Sys init ...
MX_LWIP_Init.
netif: netmask of interface    set to 255.255.255.0
netif: GW address of interface    set to 192.168.200.1
netif_set_ipaddr: netif address being changed
HAL_ETH_Init ...
ETH_RST

[2025-03-19 09:32:58.059]# RECV ASCII>
netif: added interface st IP addr 192.168.200.201 netmask 255.255.255.0 gw 192.168.200.1
netif: setting default interface st
netif_is_link_down.

[2025-03-19 09:32:58.940]# RECV ASCII>
etharp_timer

[2025-03-19 09:32:59.699]# RECV ASCII>
LinkState = 2,100M,FULLDUPLEX
pbuf_alloced_custom(length=0)
pbuf_alloced_custom(length=0)
pbuf_alloced_custom(length=0)
pbuf_alloced_custom(length=0)
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 30044008
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 30044028 new 3004401a (14)
ethernet_output: sending packet 30044008
pbuf_free(30044008)
pbuf_free: deallocating 30044008

[2025-03-19 09:32:59.840]# RECV ASCII>
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:806
pbuf_remove_header: old 30006c94 new 30006ca2 (14)
etharp_update_arp_entry: 0.0.0.0 - 9c:2d:cd:9d:2e:e2
etharp_update_arp_entry: will not add non-unicast IP address to ARP cache
etharp_input: incoming ARP request
etharp_input: ARP request was not for us.
pbuf_free(30006c74)
pbuf_free: deallocating 30006c74

[2025-03-19 09:32:59.952]# RECV ASCII>
etharp_timer

[2025-03-19 09:33:00.838]# RECV ASCII>
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:806
pbuf_remove_header: old 30006674 new 30006682 (14)
etharp_update_arp_entry: 0.0.0.0 - 9c:2d:cd:9d:2e:e2
etharp_update_arp_entry: will not add non-unicast IP address to ARP cache
etharp_input: incoming ARP request
etharp_input: ARP request was not for us.
pbuf_free(30006654)
pbuf_free: deallocating 30006654

[2025-03-19 09:33:00.931]# RECV ASCII>
etharp_timer

[2025-03-19 09:33:01.846]# RECV ASCII>
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:806
pbuf_remove_header: old 30006054 new 30006062 (14)
etharp_update_arp_entry: 0.0.0.0 - 9c:2d:cd:9d:2e:e2
etharp_update_arp_entry: will not add non-unicast IP address to ARP cache
etharp_input: incoming ARP request
etharp_input: ARP request was not for us.
pbuf_free(30006034)
pbuf_free: deallocating 30006034

[2025-03-19 09:33:01.940]# RECV ASCII>
etharp_timer

[2025-03-19 09:33:02.880]# RECV ASCII>
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:806
pbuf_remove_header: old 30005a34 new 30005a42 (14)
etharp_update_arp_entry: 192.168.200.220 - 9c:2d:cd:9d:2e:e2
etharp_find_entry: found empty entry 0
etharp_find_entry: no empty entry found and not allowed to recycle
etharp_input: incoming ARP request
etharp_input: ARP request was not for us.
pbuf_free(30005a14)
pbuf_free: deallocating 30005a14
pbuf_alloced_c
[2025-03-19 09:33:03.161]# RECV ASCII>
ustom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:800
pbuf_remove_header: old 30005414 new 30005422 (14)
ip_input: iphdr->dest 0xffc8a8c0 netif->ip_addr 0xc9c8a8c0 (0xc8a8c0, 0xc8a8c0, 0xff000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        96     | (v, hl, tos, len)
+-------------------------------+
|     3117      |000|       0   | (id, flags, offset)
+-------------------------------+
|  128  |   17  |    0x1b33     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |  200  |  220  | (src)
+-------------------------------+
|  192  |  168  |  200  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 96 p->tot_len 96
pbuf_remove_header: old 30005422 new 30005436 (20)
udp_input: received datagram of length 76
UDP header:
+-------------------------------+
|       137     |       137     | (src port, dest port)
+-------------------------------+
|        76     |
[2025-03-19 09:33:03.163]# RECV ASCII>
     0x222f    | (len, chksum)
+-------------------------------+
udp (192.168.200.255, 137) <-- (192.168.200.220, 137)
pbuf_free(300053f4)
pbuf_free: deallocating 300053f4
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:800
pbuf_remove_header: old 30006c94 new 30006ca2 (14)
ip_input: iphdr->dest 0xffc8a8c0 netif->ip_addr 0xc9c8a8c0 (0xc8a8c0, 0xc8a8c0, 0xff000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        96     | (v, hl, tos, len)
+-------------------------------+
|     3118      |000|       0   | (id, flags, offset)
+-------------------------------+
|  128  |   17  |    0x1b32     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |  200  |  220  | (src)
+-------------------------------+
|  192  |  168  |  200  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 96 p->tot_len 96
pbuf_remove_header: old 30006ca2 new 30006cb6 (20)
udp_input
[2025-03-19 09:33:03.173]# RECV ASCII>
: received datagram of length 76
UDP header:
+-------------------------------+
|       137     |       137     | (src port, dest port)
+-------------------------------+
|        76     |     0x2230    | (len, chksum)
+-------------------------------+
udp (192.168.200.255, 137) <-- (192.168.200.220, 137)
pbuf_free(30006c74)
pbuf_free: deallocating 30006c74
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:800
pbuf_remove_header: old 30006674 new 30006682 (14)
ip_input: iphdr->dest 0xffc8a8c0 netif->ip_addr 0xc9c8a8c0 (0xc8a8c0, 0xc8a8c0, 0xff000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        96     | (v, hl, tos, len)
+-------------------------------+
|     3119      |000|       0   | (id, flags, offset)
+-------------------------------+
|  128  |   17  |    0x1b31     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |  200  |  220  | (src)
+-----------------
[2025-03-19 09:33:03.220]# RECV ASCII>
--------------+
|  192  |  168  |  200  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 96 p->tot_len 96
pbuf_remove_header: old 30006682 new 30006696 (20)
udp_input: received datagram of length 76
UDP header:
+-------------------------------+
|       137     |       137     | (src port, dest port)
+-------------------------------+
|        76     |     0xba32    | (len, chksum)
+-------------------------------+
udp (192.168.200.255, 137) <-- (192.168.200.220, 137)
pbuf_free(30006654)
pbuf_free: deallocating 30006654
etharp_timer

[2025-03-19 09:33:03.932]# RECV ASCII>
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:800
pbuf_remove_header: old 30006054 new 30006062 (14)
ip_input: iphdr->dest 0xffc8a8c0 netif->ip_addr 0xc9c8a8c0 (0xc8a8c0, 0xc8a8c0, 0xff000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        96     | (v, hl, tos, len)
+-------------------------------+
|     3120      |000|       0   | (id, flags, offset)
+-------------------------------+
|  128  |   17  |    0x1b30     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |  200  |  220  | (src)
+-------------------------------+
|  192  |  168  |  200  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 96 p->tot_len 96
pbuf_remove_header: old 30006062 new 30006076 (20)
udp_input: received datagram of length 76
UDP header:
+-------------------------------+
|       137     |       137     | (src port, dest port)
+-------------------------------+
|  
[2025-03-19 09:33:03.939]# RECV ASCII>
      76     |     0x2230    | (len, chksum)
+-------------------------------+
udp (192.168.200.255, 137) <-- (192.168.200.220, 137)
pbuf_free(30006034)
pbuf_free: deallocating 30006034
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:800
pbuf_remove_header: old 30005a34 new 30005a42 (14)
ip_input: iphdr->dest 0xffc8a8c0 netif->ip_addr 0xc9c8a8c0 (0xc8a8c0, 0xc8a8c0, 0xff000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        96     | (v, hl, tos, len)
+-------------------------------+
|     3121      |000|       0   | (id, flags, offset)
+-------------------------------+
|  128  |   17  |    0x1b2f     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |  200  |  220  | (src)
+-------------------------------+
|  192  |  168  |  200  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 96 p->tot_len 96
pbuf_remove_header: old 30005a42 new 30005a56
[2025-03-19 09:33:03.955]# RECV ASCII>
(20)
udp_input: received datagram of length 76
UDP header:
+-------------------------------+
|       137     |       137     | (src port, dest port)
+-------------------------------+
|        76     |     0x222f    | (len, chksum)
+-------------------------------+
udp (192.168.200.255, 137) <-- (192.168.200.220, 137)
pbuf_free(30005a14)
pbuf_free: deallocating 30005a14
pbuf_alloced_custom(length=0)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:9c:2d:cd:9d:2e:e2, type:800
pbuf_remove_header: old 30005414 new 30005422 (14)
ip_input: iphdr->dest 0xffc8a8c0 netif->ip_addr 0xc9c8a8c0 (0xc8a8c0, 0xc8a8c0, 0xff000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        96     | (v, hl, tos, len)
+-------------------------------+
|     3122      |000|       0   | (id, flags, offset)
+-------------------------------+
|  128  |   17  |    0x1b2e     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |  200  |  220  | (src)
+---
[2025-03-19 09:33:03.987]# RECV ASCII>
----------------------------+
|  192  |  168  |  200  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 96 p->tot_len 96
pbuf_remove_header: old 30005422 new 30005436 (20)
udp_input: received datagram of length 76
UDP header:
+-------------------------------+
|       137     |       137     | (src port, dest port)
+-------------------------------+
|        76     |     0xba32    | (len, chksum)
+-------------------------------+
udp (192.168.200.255, 137) <-- (192.168.200.220, 137)
pbuf_free(300053f4)
pbuf_free: deallocating 300053f4
pbuf_alloced_custom(length=0)
ethernet_input: dest:00:80:e1:00:00:00, src:9c:2d:cd:9d:2e:e2, type:800
pbuf_remove_header: old 30006c94 new 30006ca2 (14)
ip_input: iphdr->dest 0xc9c8a8c0 netif->ip_addr 0xc9c8a8c0 (0xc8a8c0, 0xc8a8c0, 0xc9000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+--------------------------
[2025-03-19 09:33:04.049]# RECV ASCII>
-----+
| 4 | 5 |  0x00 |        60     | (v, hl, tos, len)
+-------------------------------+
|    51828      |000|       0   | (id, flags, offset)
+-------------------------------+
|  128  |    1  |    0x5d55     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |  200  |  220  | (src)
+-------------------------------+
|  192  |  168  |  200  |  201  | (dest)
+-------------------------------+
ip4_input: p->len 60 p->tot_len 60
pbuf_remove_header: old 30006ca2 new 30006cb6 (20)
Unsupported transport protocol 1
pbuf_free(30006c74)
pbuf_free: deallocating 30006c74
etharp_timer

6、工程文件我上传到百度云,求各位大佬帮忙解惑~

通过网盘分享的文件:LWIPdemo.zip
链接: https://pan.baidu.com/s/1k-u_Ra65V--WxC6SkSqsTQ?pwd=5hjq 提取码: 5hjq

回复

使用道具 举报

1

主题

3

回帖

6

积分

新手上路

积分
6
 楼主| 发表于 2025-3-19 10:20:37 | 显示全部楼层
图片挂了,再上传一下
下载 (1).png
下载 (2).png
下载 (3).png
下载 (4).png
下载.png
回复

使用道具 举报

1

主题

3

回帖

6

积分

新手上路

积分
6
 楼主| 发表于 2025-3-19 11:54:14 | 显示全部楼层
朋友们我是傻子,CubMx生成的有问题,我自己查的时候没看清楚。lwipop.h文件里面有一句如下:
回复

使用道具 举报

1

主题

3

回帖

6

积分

新手上路

积分
6
 楼主| 发表于 2025-3-19 11:56:01 | 显示全部楼层
朋友们,我煞笔了,这个CubMx生成出来的东西一定要仔细看,我就是没看清,lwipop.h文件有下面一句
/*----- Default Value for LWIP_ICMP: 1 ---*/
#define LWIP_ICMP 0
一定要把下面这句改成
#define LWIP_ICMP 0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-6-9 21:52 , Processed in 0.410044 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表