嵌入式技术论坛
直播中

kasdlak

8年用户 1225经验值
擅长:光电显示
私信 关注
[问答]

stm32h743添加lwip2.02报发送错误ping失败怎么办?

说明:

开发板:硬石YS-H7Pro, 芯片stm32h743iit6
开发工具:win10系统,ip固定为192.168.2.201; IDE为rt-thread studio 2.0
项目配置:按芯片型号添加RT-Thread v4.02项目;board.h取消eth部分相应注释,启动lan8720驱动;stm32h7xx_hal_conf中取消HAL_ETH_MODULE_ENABLED注释;board.c中添加eth_msp初始化及phy_reset函数;rt-thread设置添加LWIP,取消DHCP,固定ip为192.168.2.100
其他:默认drvers下面的drv_eth驱动报错,从art-pi的sdk中拷贝drv_eth.c及drv_eth.h,并修改phy_reset部分;
问题:
编译下载后,网络连接状态正常,不过报DMA发送失败,双向ping不通。

\ | /

RT - Thread Operating System
/ | \ 4.0.2 build Feb 2 2021
2006 - 2019 Copyright by rt-thread team
lwIP-2.0.2 initialized!
[I/sal.skt] Socket Abstraction Layer initialize success.
[W/drv.emac] eth transmit frame faild: 8
msh >
RT-Thread shell commands:
ifconfig - list the information of all network interfaces
ping - ping network host
dns - list and set the information of dns
netstat - list the information of TCP / IP
version - show RT-Thread version information
list_thread - list thread
list_sem - list semaphore in system
list_event - list event in system
list_mutex - list mutex in system
list_mailbox - list mail box in system
list_msgqueue - list message queue in system
list_mempool - list memory pool in system
list_timer - list timer in system
list_device - list device in system
exit - return to RT-Thread shell mode.
help - RT-Thread shell help.
ps - List threads in the system.
free - Show the memory usage in the system.
reboot - Reboot System
msh >ifconfig
network interface device: e0 (Default)
MTU: 1500
MAC: 00 80 e1 17 3d 22
FLAGS: UP LINK_UP INTERNET_DOWN DHCP_DISABLE ETHARP BROADCAST IGMP
ip address: 192.168.2.100
gw address: 0.0.0.0
net mask : 255.255.255.0
dns server #0: 0.0.0.0
dns server #1: 0.0.0.0
msh >ping 192.168.2.201
[W/drv.emac] eth transmit frame faild: 24
[W/drv.emac] eth transmit frame faild: 24
[W/drv.emac] eth transmit frame faild: 24
ping: from 192.168.2.201 icmp_seq=0 timeout
[W/drv.emac] eth transmit frame faild: 18
[W/drv.emac] eth transmit frame faild: 18
ping: from 192.168.2.201 icmp_seq=1 timeout
ping: from 192.168.2.201 icmp_seq=2 timeout
[W/drv.emac] eth transmit frame faild: 18
[W/drv.emac] eth transmit frame faild: 18
[W/drv.emac] eth transmit frame faild: 18
ping: from 192.168.2.201 icmp_seq=3 timeout
msh >[W/drv.emac] eth transmit frame faild: 18
[W/drv.emac] eth transmit frame faild: 18
[W/drv.emac] eth transmit frame faild: 18

2.jpg

3.jpg

回帖(4)

CDCNKA

2023-2-21 10:26:53
RTT Studio 使用的编译器是 GCC 所以在drv_eth.c 中使用到
#elif defined ( __GNUC__ ) /* GNU Compiler */
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection")));   /* Ethernet Tx DMA Descriptors */
uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_MAX_PACKET_SIZE] __attribute__((section(".RxArraySection"))); /* Ethernet Receive Buffers */
#endif
这里的以太网描述符指定了固定的地址,所以需要修改联检文件,这个可以参考 ART-Pi
另外一下几点也请注意:
内存堆的选择
MPU 的配置
如果还有疑问请追问,如果帮助到你请采纳。
举报

kasdlak

2023-2-21 10:27:13
按你说的都去设置了,还是不行。
2.jpg
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date           Author       Notes
* 2019-04-14     whj4674672   first version
*/
#include
#include "stm32h7xx.h"
#include "board.h"
int mpu_init(void)
{
    MPU_Region_InitTypeDef MPU_InitStruct;
    /* Disable the MPU */
    HAL_MPU_Disable();
    /* Configure the MPU attributes as WT for AXI SRAM */
    MPU_InitStruct.Enable            = MPU_REGION_ENABLE;
    MPU_InitStruct.BaseAddress       = 0x20000000;
    MPU_InitStruct.Size              = 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_NUMBER0;
    MPU_InitStruct.TypeExtField      = MPU_TEX_LEVEL0;
    MPU_InitStruct.SubRegionDisable  = 0X00;
    MPU_InitStruct.DisableExec       = MPU_INSTRUCTION_ACCESS_ENABLE;
    HAL_MPU_ConfigRegion(&MPU_InitStruct);
#ifdef BSP_USING_SDRAM
    /* Configure the MPU attributes as WT for SDRAM */
    MPU_InitStruct.Enable            = MPU_REGION_ENABLE;
    MPU_InitStruct.BaseAddress       = 0xC0000000;
    MPU_InitStruct.Size              = MPU_REGION_SIZE_32MB;
    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);
#endif
#ifdef BSP_USING_ETH
    /* Configure the MPU attributes as Device not cacheable
       for ETH DMA descriptors and RX Buffers*/
    MPU_InitStruct.Enable = MPU_REGION_ENABLE;
    MPU_InitStruct.BaseAddress = 0x30040000;
    MPU_InitStruct.Size = MPU_REGION_SIZE_32KB;
    MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
    MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
    MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
    MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
    MPU_InitStruct.Number = MPU_REGION_NUMBER2;
    MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
    MPU_InitStruct.SubRegionDisable = 0x00;
    MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
    HAL_MPU_ConfigRegion(&MPU_InitStruct);
#endif
//    /* Configure the MPU attributes as WT for QSPI */
//    MPU_InitStruct.Enable            = MPU_REGION_ENABLE;
//    MPU_InitStruct.BaseAddress       = 0x90000000;
//    MPU_InitStruct.Size              = MPU_REGION_SIZE_8MB;
//    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_NUMBER3;
//    MPU_InitStruct.TypeExtField      = MPU_TEX_LEVEL0;
//    MPU_InitStruct.SubRegionDisable  = 0X00;
//    MPU_InitStruct.DisableExec       = MPU_INSTRUCTION_ACCESS_ENABLE;
//
//    HAL_MPU_ConfigRegion(&MPU_InitStruct);
    /* Enable the MPU */
    HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
    /* Enable CACHE */
    SCB_EnableICache();
    SCB_EnableDCache();
    return RT_EOK;
}
INIT_BOARD_EXPORT(mpu_init)
3.jpg
举报

CDCNKA

2023-2-21 10:27:47
我说的几点注意,你并没有检查:
内存堆的选择。请选择 axi sram.
MPU 的配置. 抄ART-Pi
另外关于 STM32H7 上使用 LWIP 可以参考我的 blog 了解一下 必备的知识。
举报

kasdlak

2023-2-21 10:27:59
谢谢,已解决。
修改ram地址段(之前也使用过0x24000000,不过报cpu错误,怀疑是地址问题才改回0x20000000,现在发现是cache被我重复使能造成),不报dma发送错误了,不过还是ping不通;
拷贝的原来keil工程的eth_msp初始化里面缺少中断使能,加上就可以ping通了;
举报

更多回帖

发帖
×
20
完善资料,
赚取积分