This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS570LC4357:使以太网 MAC 运行、从环回测试开始

Guru**** 657930 points
Other Parts Discussed in Thread: HALCOGEN, TMS570LC4357, LAUNCHXL2-570LC43, DP83630, TMDX570LC43HDK, TMDSRM48HDK
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1121389/tms570lc4357-getting-ethernet-mac-running-starting-with-loopback-test

器件型号:TMS570LC4357
主题中讨论的其他器件:HALCOGENLAUNCHXL2-570LC43CCStudioDP83630TMDX570LC43HDKTMDSRM48HDK

您好!

我正在尝试使 EMAC 正常工作,并遇到了其他人遇到的同样的问题,就像在这里的线程中一样....

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/872569/ccs-launchxl2-570lc43-ethernet-all-received-frames-are-filtered/3244804?tisearch=e2e-sitesearch&keymatch=xl2-570lc43%20ethernet#3244804

我按照 Halcogen 帮助文档中的步骤执行 EMAC 回送。

我尝试将 MPU 区域设置为 normal_OIWTNOWA_nonshared (直写式)、正如上述海报中的假设那样、但这对我不起作用。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/612990/tms570lc4357-mdiophyregread?tisearch=e2e-sitesearch&keymatch=TMS570LC4357%25252525252520Ethernet%25252525252520loopback%25252525252520MDIO

我尝试拿起此帖子中指示的包裹:

TMS570LC4357_LaunchPad_EMAC_Loopback.zip

但无权检索它。

感谢您为 EMAC 的发展提供的所有帮助。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="521569" URL"~/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1121389/tms570lc4357-getting-ethernet-mac-running - starting-with -loopback -test/4171342#4171342"]如果您的专家认为这个问题可以解决、那么这个问题是否可以解决?  [/报价]

    根据调试其他 MCU 以太网驱动程序时遇到的问题、我认为 hdkif 问题是一个软件"错误"、希望可以在软件中解决。 但是、在确定根本原因之前、无法100%确定。

    鉴于观察到的症状是 MEMP_NUM_PBUF 的增加使器件花费了全部时间来运行以太网 Tx 处理程序(并且未能清除中断源)、下一步是检查管理发送描述符的软件、以查看是否可以识别任何错误/竞争条件。

    我直到周末才会这样做、但 TI 员工可能需要调查足够的信息。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好@Chester Gillon 和@Peter Lu、

    我们可以关闭这个线程吗?

    --

    此致、

    Jagadish。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我不知道关闭线程的标准是什么。  此线程的主题尚未解决、因为没有可提供功能 EMAC 传输层以发送和接收"原始"以太网消息的有效"hdkif"工具。  我希望 Chester 或 TI 员工能够帮助完成这项工作、但非常感谢在运行使用 hdkif 的半功能性 LwIP 封装方面取得了重大进展。

    如果不希望通过此线程中的通信完成 hdkif、那么我想该线程可能会关闭。  但是、如果有任何机会让 EMAC 传输层/驱动程序运行、可能会封装为未来的 TI 演示/示例项目、那么我真的很想看到对话继续进行。

    非常感谢。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="521569" URL"~/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1121389/tms570lc4357-getting-ethernet-mac-running - starting-with -loopback -test/4171342#4171342"]如果您的专家认为该问题可以得到解决,请使用引号[?]

    查看 Hercules 示例 GIT repo、有3 个 hdkif.c 源文件:

    $ find hercules_examples/ -name hdkif.c -ls
     59247830     28 -rw-r--r--   1 mr_halfword mr_halfword    27166 Nov 28  2020 hercules_examples/Application/LwIP/v00.04.00/lwip-1.4.1/ports/hdk/netif/hdkif.c
     53880066     28 -rw-rw-r--   1 mr_halfword mr_halfword    27166 Sep 25  2021 hercules_examples/Application/Hercules_Ethernet_Bootloader/lwip-1.4.1/ports/hdk/netif/hdkif.c
     50341279     28 -rw-r--r--   1 mr_halfword mr_halfword    27817 Nov 28  2020 hercules_examples/Application/ActiveWebserver/1.1.0/third_party/lwip-1.4.1/ports/hdk/netif/hdkif.c
    

    前两个文件(在 Application/LwIP/v00.04.00/lwip-1.4.1和 Application/Hercules 以太网引导加载程序/lwip-1.4.1下) 是相同的。 第三个文件(在 Application/ActiveWebserver/1.1.0/third_party/lwip-1.4.1下)与其他两个文件不同。 比较第1个和第3个文件显示第3个文件在 hdkif_transmit、hdkif_output 和 hdkif_TX_inthandler 函数如何确定是否有自由传输缓冲区描述符方面具有附加代码:

    mr_halfword@Haswell-Ubuntu:~/hercules_examples$ git diff --no-index Application/LwIP/v00.04.00/lwip-1.4.1/ports/hdk/netif/hdkif.c Application/ActiveWebserver/1.1.0/third_party/lwip-1.4.1/ports/hdk/netif/hdkif.c | cat
    diff --git a/Application/LwIP/v00.04.00/lwip-1.4.1/ports/hdk/netif/hdkif.c b/Application/ActiveWebserver/1.1.0/third_party/lwip-1.4.1/ports/hdk/netif/hdkif.c
    index 0f8cd15..9c76dd7 100644
    --- a/Application/LwIP/v00.04.00/lwip-1.4.1/ports/hdk/netif/hdkif.c
    +++ b/Application/ActiveWebserver/1.1.0/third_party/lwip-1.4.1/ports/hdk/netif/hdkif.c
    @@ -43,18 +43,18 @@
      * interface driver for lwIP.
      *
      */
    -#include "src/include/lwip/opt.h"
    -#include "src/include/lwip/def.h"
    -#include "src/include/lwip/mem.h"
    -#include "src/include/lwip/pbuf.h"
    -#include "src/include/lwip/sys.h"
    -#include "src/include/lwip/stats.h"
    -#include "src/include/lwip/snmp.h"
    -#include "src/include/netif/etharp.h"
    -#include "src/include/netif/ppp_oe.h"
    -#include "src/include/lwip/err.h"
    -#include "ports/hdk/include/netif/hdkif.h"
    -#include "ports/hdk/include/arch/cc.h"
    +#include "lwip/opt.h"
    +#include "lwip/def.h"
    +#include "lwip/mem.h"
    +#include "lwip/pbuf.h"
    +#include "lwip/sys.h"
    +#include "lwip/stats.h"
    +#include "lwip/snmp.h"
    +#include "netif/etharp.h"
    +#include "netif/ppp_oe.h"
    +#include "lwip/err.h"
    +#include "netif/hdkif.h"
    +#include "arch/cc.h"
     
     /* HALCoGen DriverLib Header & PHY files required for this interface driver. */
     #if defined(_TMS570LC43x_) || defined(_RM57Lx_)
    @@ -79,7 +79,8 @@
     #endif
     
     #define PBUF_LEN_MAX              MAX_TRANSFER_UNIT
    -
    +#define EMAC_BD_LEN_MASK          0xFFFF
    +#define EMAC_BD_PKTLEN_MASK       0xFFFF
     
     /* Define those to better describe the network interface. */
     #define IFNAME0                  'e'
    @@ -133,6 +134,7 @@ struct txch {
       volatile struct emac_tx_bdp *free_head;
       volatile struct emac_tx_bdp *active_tail;
       volatile struct emac_tx_bdp *next_bd_to_process;
    +  volatile u32_t free_num;
     }txch;
      
     /**
    @@ -279,7 +281,7 @@ hdkif_link_setup(struct hdkif *hdkif) {
      * @param pbuf  the pbuf which is to be sent over EMAC
      * @return None
      */
    -static void
    +static err_t
     hdkif_transmit(struct hdkif *hdkif, struct pbuf *pbuf) {
       struct pbuf *q;
       struct txch *txch;
    @@ -287,6 +289,11 @@ hdkif_transmit(struct hdkif *hdkif, struct pbuf *pbuf) {
     
       txch = &(hdkif->txch);
      
    +   /* Do not send if there are no enough free bd's */
    +  if(pbuf_clen(pbuf) > txch->free_num) {
    +    return ERR_MEM;
    +  }
    +  
       /* Get the buffer descriptor which is free to transmit */
       curr_bd = txch->free_head;
       
    @@ -306,7 +313,8 @@ hdkif_transmit(struct hdkif *hdkif, struct pbuf *pbuf) {
         bd_end = curr_bd;
         curr_bd->pbuf = pbuf;
         curr_bd = hdkif_swizzle_txp(curr_bd->next);
    -    //if (curr_bd) curr_bd->flags_pktlen = 0;
    +	/* Decrement free bds, since one is consumed */ 
    +    txch->free_num--;
       }
     
       /* Indicate the end of the packet */
    @@ -353,7 +361,7 @@ hdkif_transmit(struct hdkif *hdkif, struct pbuf *pbuf) {
     static err_t
     hdkif_output(struct netif *netif, struct pbuf *p) {
       SYS_ARCH_DECL_PROTECT(lev);
    -
    +  struct pbuf *q = p;
       /**
        * This entire function must run within a "critical section" to preserve
        * the integrity of the transmit pbuf queue.
    @@ -362,9 +370,19 @@ hdkif_output(struct netif *netif, struct pbuf *p) {
       SYS_ARCH_PROTECT(lev);
     
       /* adjust the packet length if less than minimum required */
    -  if(p->tot_len < MIN_PKT_LEN) {
    -     p->tot_len = MIN_PKT_LEN;
    -     p->len = MIN_PKT_LEN;
    +  /**
    +   * Adjust the packet length if less than minimum required.
    +   */
    +  if(q->tot_len < MIN_PKT_LEN) {
    +    q->tot_len = MIN_PKT_LEN;
    +
    +    while(q->next != NULL) {
    +      q->next->tot_len = q->tot_len - q->len;
    +      q = q->next;
    +    }
    +
    +    /* Adjust the length of the last pbuf. (contents - don't care) */
    +    q->len = q->tot_len;
       }
     
       /**
    @@ -504,6 +522,7 @@ hdkif_hw_init(struct netif *netif)
      
       /* Set the number of descriptors for the channel */ 
       num_bd = (SIZE_EMAC_CTRL_RAM >> 1) / sizeof(emac_tx_bdp);
    +  txch->free_num = num_bd;
       
       curr_txbd = txch->free_head;
     
    @@ -810,7 +829,7 @@ void
     hdkif_tx_inthandler(struct netif *netif) {
       struct txch *txch;
       struct hdkif *hdkif; 
    -  volatile struct emac_tx_bdp *curr_bd, *next_bd_to_process;
    +  volatile struct emac_tx_bdp *curr_bd, *next_bd_to_process,*processed_bd;
       
       hdkif = netif->state; 
       txch = &(hdkif->txch);
    @@ -818,6 +837,7 @@ hdkif_tx_inthandler(struct netif *netif) {
       next_bd_to_process = txch->next_bd_to_process;
       
       curr_bd = next_bd_to_process;
    +  processed_bd = curr_bd;
       
       /* Check for correct start of packet */
       while(hdkif_swizzle_data(curr_bd->flags_pktlen) & EMAC_BUF_DESC_SOP) {
    @@ -825,10 +845,15 @@ hdkif_tx_inthandler(struct netif *netif) {
         /* Make sure that the transmission is over */
         while((hdkif_swizzle_data(curr_bd->flags_pktlen) & EMAC_BUF_DESC_OWNER)
               == EMAC_BUF_DESC_OWNER);
    -   
    +       /* One buffer descriptor is free now */
    +    txch->free_num++; 
         /* Traverse till the end of packet is reached */ 
         while((hdkif_swizzle_data(curr_bd->flags_pktlen) & EMAC_BUF_DESC_EOP) != EMAC_BUF_DESC_EOP) {
            curr_bd = hdkif_swizzle_txp(curr_bd->next);
    +      txch->free_num++; 
    +	        if(txch->free_num == (SIZE_EMAC_CTRL_RAM >> 1) / sizeof(emac_tx_bdp)) {
    +        break;
    +    }
         }
      
         next_bd_to_process->flags_pktlen &= hdkif_swizzle_data(~(EMAC_BUF_DESC_SOP));
    @@ -846,17 +871,16 @@ hdkif_tx_inthandler(struct netif *netif) {
           txch->next_bd_to_process = hdkif_swizzle_txp(curr_bd->next);
         }
         
    -    /* Acknowledge the EMAC and free the corresponding pbuf */
    -    EMACTxCPWrite(hdkif->emac_base, 0, (uint32)curr_bd);
    -
         pbuf_free((struct pbuf *)curr_bd->pbuf);
     
         LINK_STATS_INC(link.xmit);
        
         next_bd_to_process = txch->next_bd_to_process;
    +    processed_bd = curr_bd;
         curr_bd = next_bd_to_process;
       }
    -
    +  /* Acknowledge the EMAC and free the corresponding pbuf */
    +  EMACTxCPWrite(hdkif->emac_base, 0, (uint32)processed_bd);
       EMACCoreIntAck(hdkif->emac_base, EMAC_INT_CORE0_RX);
       EMACCoreIntAck(hdkif->emac_base, EMAC_INT_CORE0_TX);
     }
    
     Application/LwIP/v00.04.00/LAUNCHXL2-TMS570LC43x/build-LAUNCHXL2-TMS570LC43x 示例显示了问题是使用 Application/LwIP/v00.04.00/lwip-1.4.1/ports/HDK/netif/hdkif.c 文件(上面描述的第一个文件)。

    将 Hercules 示例/应用/ActiveWebserver/1.1.0/third_party/lwip-1.4.1/ports/HDK/netif/hdkif.c 的内容复制到 Hercules 示例/Application/LwIP/v00.04.00/lwip-1.4.1/ports/HDK/netif/hdkif.c 由于这些更改涉及检查自由传输缓冲区、因此认为它可能会解决问题。 仅此更改、Linux PC 仍然无法正确显示网页。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    非常感谢您对此采取后续行动。  我最感兴趣的是、如果最终能够实现一个提供可靠/一致 EMAC 数据包传输的"hdkif"层。  我怀疑很多其他人也会这样做。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    注意到在 Hercules 示例\Application\LwIP\v00.04.00\lwip-1.4.1\ports\HDK\include\arch\cc.h 文件中 、由于调试宏未定义、LWIP_platform_assert 宏为空版本。

    无需启用完整的 LwIP 调试支持、便将空 的 LWIP_platform_assert 宏替换为以下内容:

    /* @todo just spin in a loop on an assertion failure so can investigate in the debugger */
    #define LWIP_PLATFORM_ASSERT(expr) { for (;;){} }

    在 LWIP_platform_assert 宏设置为在断言失败时停止程序的情况下、在 Hercules 示例\Application\LwIP\v00.04.00\lwip-1.4.1\apps\httpserver_rain\httpd.c 中发现以下断言发生故障:

    #if !LWIP_HTTPD_DYNAMIC_HEADERS
        LWIP_ASSERT("HTTP headers not included in file system", hs->handle->http_header_included);
    #endif /* !LWIP_HTTPD_DYNAMIC_HEADERS */

    在调查此问题时、 虽然生成 了 Hercules 示例\Application\LwIP\v00.04.00\lwip-1.4.1\apps\httpserver_raw/makefsdata\makefsdata perl 脚本生成了 Hercules 示例\Application\LwIP\v00.04.00\lwip-1.4.1\makefsdata\makefsdata\makefsdata perl 脚本、但实际上 并未在 http_server_structures 中生成所有的数据头文件中添加到 http_target_apps\lfs.c 文件中。

    修改 了 makefsdata perl 脚本 以设置 http_header_included 标志、并重新生成 了 fsdata.c 源文件。

    这样做之后、在以下情况下不再出现断言故障:

    1. 在网页正确显示时使用 Windows http Web 浏览器。
    2. 在网页不显示正确时使用 Linux Web 浏览器。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    已使用  CG_xml 包中的 call_graph.pl 实用程序生成 LwIP 程序最坏情况下的堆栈使用情况。

    为了帮助实现自动化、向 CCS 工程添加了以下编译后处理步骤:

    "${CG_TOOL_ROOT}/bin/armofd" -x -g -o "${BuildArtifactFileBaseName}.xml" "${BuildArtifactFileName}"
    "${CG_XML_ROOT}/bin/call_graph" "${BuildArtifactFileBaseName}.xml" --i_cfg="${CG_XML_ROOT}/ofd/arm_rts_indirect.txt" --i_cfg="${CG_XML_ROOT}/ofd/ti_rts_indirect.txt" --i_cfg="${PROJECT_LOC}/../../example/lwip_example_indirect.txt" > "${BuildArtifactFileBaseName}_call_graph.txt"

    其中附加 的 lwip_example_indirect.txt 是 call_graph.pl 配置文件、该文件指定 LwIP 代码使用的间接调用(函数指针)。

    随附 的 Build-LAUNCHXL2-TMS570LC43_call_graph.txt 是生成的报告。 最坏情况下的堆栈使用情况报告为:

    -632字节用于 main、来自_c_int00
    -来自 IRQ、来自 EMACCore0RxIsr 的824字节

    在 HALCoGen 配置中:
    a:用户堆栈长度为4096、这是足够的。
    B. IRQ 堆栈长度为256、这可能导致堆栈溢出。

    IRQ 堆栈长度已增加到1024以避免堆栈溢出、但这不会改变使用 Linux http 客户端时处理停止的文件的故障机制。

    e2e.ti.com/.../lwip_5F00_example_5F00_indirect.txt

    e2e.ti.com/.../Build_2D00_LAUNCHXL2_2D00_TMS570LC43_5F00_call_5F00_graph.txt

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    之前对 Hercules 示例\Application\LwIP\v00.04.00代码的分析发现 未调用 sys_check_timeouts()函数,因此意味着未调度 LwIP 计时器。

    HALCoGen 配置已更改、以使 RTI 比较3能够生成10毫秒周期的中断、并且:

    a. rtiNotification()用于调用 sys_check_timeouts()以调度任何 LwIP 计时器。

    b. sys_now ()被修改以返回系统时间(以毫秒为单位)-每个  RTI 比较3中断递增10。

    随着 LwIP 计时器的调度的增加、使用 Linux Web 浏览器时的行为 发生了变化、虽然网页最初仍然明显停止、最初显示的方框图大约是1/3、 在显示几秒钟2/3后、网页将完全 显示出来。

    当使用 Windows Web 浏览器且页面显示"即时"时、lwip_stats.memp[MEMP_NUM_PBUF]中未报告错误:

    lwip_stats	struct stats_	{link={xmit=189,recv=117,fw=0,drop=0,chkerr=0...},etharp={xmit=2,recv=4,fw=0,drop=...,ip=...	0x080109A8	
    	link	struct stats_proto	{xmit=189,recv=117,fw=0,drop=0,chkerr=0...}	0x080109A8	
    	etharp	struct stats_proto	{xmit=2,recv=4,fw=0,drop=0,chkerr=0...}	0x080109C0	
    	ip	struct stats_proto	{xmit=186,recv=113,fw=0,drop=0,chkerr=0...}	0x080109D8	
    	icmp	struct stats_proto	{xmit=1,recv=1,fw=0,drop=0,chkerr=0...}	0x080109F0	
    	udp	struct stats_proto	{xmit=3,recv=2,fw=0,drop=0,chkerr=0...}	0x08010A08	
    	tcp	struct stats_proto	{xmit=179,recv=101,fw=0,drop=0,chkerr=0...}	0x08010A20	
    	mem	struct stats_mem	{avail=30720,used=68,max=456,err=0,illegal=0}	0x08010A38	
    	memp	struct stats_mem[8]	[{avail=4,used=0,max=0,err=0,illegal=0},{avail=4,used=2,max=2,err=0,illegal=0},{avail=...,...	0x08010A42	
    lwip_stats.memp[6]	struct stats_mem	{avail=48,used=0,max=2,err=0,illegal=0}	0x08010A7E	
    localTimeMilliseconds	unsigned int	42460	0x08010D7C	

    而当使用 Linux Web 浏览器并且网页现在在延迟后完成显示时 、lwip_stats.memp[MEMP_NUM_PBUF]中报告了内存不足错误:

    lwip_stats	struct stats_	{link={xmit=219,recv=176,fw=0,drop=0,chkerr=0...},etharp={xmit=3,recv=2,fw=0,drop=...,ip=...	0x080109A8	
    	link	struct stats_proto	{xmit=219,recv=176,fw=0,drop=0,chkerr=0...}	0x080109A8	
    	etharp	struct stats_proto	{xmit=3,recv=2,fw=0,drop=0,chkerr=0...}	0x080109C0	
    	ip	struct stats_proto	{xmit=217,recv=174,fw=0,drop=0,chkerr=0...}	0x080109D8	
    	icmp	struct stats_proto	{xmit=0,recv=0,fw=0,drop=0,chkerr=0...}	0x080109F0	
    	udp	struct stats_proto	{xmit=3,recv=2,fw=0,drop=0,chkerr=0...}	0x08010A08	
    	tcp	struct stats_proto	{xmit=211,recv=171,fw=0,drop=0,chkerr=0...}	0x08010A20	
    	mem	struct stats_mem	{avail=30720,used=68,max=4048,err=0,illegal=0}	0x08010A38	
    	memp	struct stats_mem[8]	[{avail=4,used=0,max=0,err=0,illegal=0},{avail=4,used=2,max=2,err=0,illegal=0},{avail=...,...	0x08010A42	
    lwip_stats.memp[6]	struct stats_mem	{avail=48,used=0,max=48,err=97,illegal=0}	0x08010A7E	
    localTimeMilliseconds	unsigned int	52880	0x08010D7C	

    因此、添加对调度 LwIP 计时器的支持可以解决传输时 pbuf 运行 hdkif 的问题、方法是在超时后导致传输恢复。 仍然需要找到根本原因。

    此外、在项目中针对以下类型的板运行了示例、它们的运行方式相同、在使用 Linux Web 浏览器时出现同样的问题:

    1. LAUNCHXL2-570LC43
    2. TMDX570LC43HDK (在以太网 PHY 中使用与 LAUNCHXL2-570LC43不同的引脚多路复用器
    3. TMDSRM48HDK (使用不带高速缓存的小端 Cortex-R4F、而上述两个使用带高速缓存的大端 Cortex-R5F)