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.

AM2432: Sysconfig Conflicts when combining LWIP and Layer2 example

Part Number: AM2432
Other Parts Discussed in Thread: SYSCONFIG

Hi experts,

My customer is combining the LWIP and Layer2 example for their application. But the following settings in syscfg is different and they can’t find a common config that work for both examples. Any way to solve this issue?



Regards,

Hang

  • Hi Hang,

    Can you give me some background on this issue:

    1. What SDK version is the customer using?

    2. How are they trying to combine the two applications? With this I mean what steps are they following to combine them?

    3. What is the end goal of doing this? What are they trying to achieve, is there a performance criteria as well?

    Regards,

    Nitika

  • Hi Nitika,

    They are using 09_01_00_41.

    For the end goal, they are using the CPSW to run their own EtherCAT master stack based on the layer2 example, and also needs the LWIP to communicate with host machine. Each takes one port in the CPSW.

    For now, they are just trying to match the parameters in the two examples. If there is any recommended way to achieve their goal, please let us know.

    Thanks,

    Hang.

  • Hi,

    I understand the requirement, I have shared this with the dev team as well for more inputs.

    Allow me some time to get back to you with some recommendations.

    Regards,

    Nitika

  • Hi Hang,

    The steps to achieve your above objective would be as follows:

    1. You have to create multiple (say two) Rx flows and two Tx Channels, with each Rx flow is associated to a PSIL thread (host port). Please refer to multichannel (refer here) example to see on how this can be done.

    2. Then, apply appropriate ALE classifier to map ethernet packets to based on different parameters. With this configuration, two different stacks (LwIP and EtherCAT master) can receive only the relevant packets.

    Before I go into more detail can you help me with some more questions:

    1. Is the customer using MAC mode?

    2. How are the packets supposed to be routed? Will it be based on Port or ethtype?

    3. What is the throughput that the customer is looking at? Expected Lwip Tx and Rx throughput and EtherCAT Rx and Tx throughput?

    4. What is the packet size? What is the maximum packet size that they will be handling?

    Regards,

    Nitika

  • Hi Nitika,

    Below are answers to your questions.

    1. Do you mean dual mac vs switch mode? They are using dual mac

    2. It's port based. LWIP and EtherCAT Master uses different ports.

    Customer is confirming with 3 and 4, but we may assume the through put and packet size is similar to the example for now. Maybe we can get this work first then deal with the data rate.

    Could you provide more details on how to do it? (Especially for the ALE classifier)

    Regards,

    Hang.

  • Hi Nitika

    Any update on this issue?

  • Hi Hang,

    Apologies for the delayed response.

    You can do the following to achieve the steps given above:

    Step 1: The multichannel example in MCU+SDK implements the two Rx flows associated to a PSIL thread (host port) and Tx channels. Link: https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/09_02_00_50/exports/docs/api_guide_am243x/EXAMPLES_ENET_LAYER2_MULTI_CHANNEL.html

    Step 2: We have to add a ALE classifier rule to classify the packets based on etherType to a PSIL thread (hence to different Rx Flow).
    Example ALE rule : Map ethernet packets with etherType as 'EtherCAT, tp PSIL thread ID '1' and remaining packets to PSIL thread '1'.
    Then, DMA Interrupt callback function for RxFlow '1' should be set to 'EtherCAT stack' and DMA Interrupt callback function for RxFlow '0' should be set to 'LwIP stack'.

    With this configuration, two different stacks (LwIP and EtherCAT master) will be able to receive only the relevant packets.

    You can refer here for ALE classifier implementation: https://github.com/TexasInstruments/mcupsdk-core/blob/next/examples/networking/tsn/enetapp_cpsw.c#L197

    Regards,

    Nitika

  • Hi Nitika,

    I would also like to ask if there is anything that syscfg needs to change other than adding DMA channels, such as ALE configuration

    Regards,

    Lan

  • Hi,

    Firstly, in the ALE classifier reference code shared above, there are additional checks for "dstMacAddr" and "vlan" which you can ignore. You can just look into the ioctl CPSW_ALE_IOCTL_SET_POLICER usage.

    The reference code above is for gptp_lwip_cpsw example that implements the same approach you are working with, but there are a lot of GPTP related configurations in the example that are not relevant to you so do use it only for reference purpose: https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/09_02_00_50/exports/docs/api_guide_am64x/EXAMPLES_ENET_CPSW_TSN_LWIP_GPTP.html

    For the sysconfig settings, you can keep the default settings of layer2 example for ALE config.

    Regards.

    Nitika

  • Hi,

    There is one more configuration parameter that you should set, that is -  aleCfg->policerGlobalCfg.policingEn = true;

    You can find this if you search for EnetApp_initAleConfig function in the gptp_lwip_cpsw example code.

    Regards,

    Nitika

  • Hi Nitika,

    Apart from the DMA channels and ALE configurations, how should I configure the packet pools? You may see in the first pool that the packet settings of the two examples are different and configuration of one example doesn't work for the other.

    For example, for the "Only enable packet info" check box. If you uncheck this box in LWIP example, although there is no compile error, example won't work properly. 

    Regards,

    Hang.

  • Hi Hang,

    "Only enable packet info" setting is required if you are planning to use lwip in your example.

    For general CPSW related configuration you can refer to the gptp_lwip_cpsw example's sysconfig as I mentioned above.

    Regards,

    Nitika

  • Hi Nitika,

    If that box is required in lwip, then how about checking the box in the layer2 example?  We need the setting of the two examples aligned so that we can merge them. Only after that we can deal with DMA channel and ALE

    Regards,

    Hang.

  • Yes, selecting the "Only enable packet info" setting in the layer2 example is what I suggest to do for the combined example.

    Regards,

    Nitika

  • Enabling "Only enable packet info" setting in the layer2 example also has problem. The example could not work.

    I think is inevitable to change one of the examples in order to combine them. Is it possible to provide a demo on how changing either one of the examples?

    Regards,

    Hang.

  • Hi Hang,

    I will try working on this on my setup and get back to you with the updates.

    Regards,

    Nitika

  • Hi Nitika,

    Is there any update?

    Regards,

    Hang.

  • Hi Hang,

    I am still working on it, will let you know when I have some updates

    Regards,

    Nitika

  • Hi Nitika,

    Is there any timeline to expect?

    Regards,

    Hang

  • Hi Hang,

    Apologies for the delay on this.

    The team has been busy with business travel and personal commitments, please expect an update by end of this week.

    Thank you for your patience.

    Regards,

    Nitika

  • Hi Nitika,

    How is the demo going?

    Regards,

  • Hi,

    I am running into issues with the integration as well, I have send your query over to another expert.

    Allow them some time to look into this and get back to you.

    Regards,

    Nitika

  • Hi Hang,

    Enabling "Only enable packet info" setting in the layer2 example also has problem. The example could not work.

    I would suggest you to start with LwIP example and include changes suggested by Nitika.

    1. You have to create multiple (say two) Rx flows and two Tx Channels, with each Rx flow is associated to a PSIL thread (host port). Please refer to multichannel (refer here) example to see on how this can be done.

    2. Then, apply appropriate ALE classifier to map ethernet packets to based on different parameters. With this configuration, two different stacks (LwIP and EtherCAT master) can receive only the relevant packets.

    Step 1: The multichannel example in MCU+SDK implements the two Rx flows associated to a PSIL thread (host port) and Tx channels. Link: https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/09_02_00_50/exports/docs/api_guide_am243x/EXAMPLES_ENET_LAYER2_MULTI_CHANNEL.html

    Step 2: We have to add a ALE classifier rule to classify the packets based on etherType to a PSIL thread (hence to different Rx Flow).
    Example ALE rule : Map ethernet packets with etherType as 'EtherCAT, tp PSIL thread ID '1' and remaining packets to PSIL thread '1'.
    Then, DMA Interrupt callback function for RxFlow '1' should be set to 'EtherCAT stack' and DMA Interrupt callback function for RxFlow '0' should be set to 'LwIP stack'.

    "Only enable packet info" check box

    This check box should have tick for your usecase.

    how should I configure the packet pools?

    Large Packet Pool Count = 48

    Other settings same as for LwIP

    Regards

    Ashwani

  • For clarity of others, customer has below use case:

    Single R5F_0_0 application need to use CPSW in DUAL MAC mode and forward port specific packet to specific stack.

    Regards

    Ashwani

  • 26-June Meeting Notes 

    • Enabled customer with LwIP SDK example 
    • Added One more DMA channel for L2 layer example

    • Updated packet pool

    • Make sure CPSW is in dual MAC mode

    • Select mode for CPSW as per use case

    With above changes example (enet_lwip_cpsw on R5F_0_0 and FreeRTOS) building successful for (default) RGMII use case.

    Let me know of you have further query.

    Regards

    Ashwani

  • Hi Ashwani,

    Customer is following the guide from the last meeting. They’ve merged the two examples but need to find a common configuration to initialize cpsw, I’ve send you their code, could you please help looking at it?

    Regards,

    Hang 

  • Hi Hang,

    I am not getting the issue customer is facing.

    Can you please provide some details here?

    so that other team members can also read and provide inputs.

    Regards

    Ashwani 

  • Meeting Notes on 02-July

    1. Walk through customer code
      1. Seems customer still not following steps mentioned above.
      2. Added 2 Tasks
        1. LwIP application
        2. L2  application
      3. Not included 2 DMA channels
        1. Channel-0 should be used for LwIP application 
        2. Channel-1 should be used for L2 application
      4. Should not re-initialize enet driver in both application
        1. Just add DMA cahnnel-1 and attach to CPSW instance ==> L2 application

      Use below code as a reference for L2 application integration:

      void EnetL2App_mainTask(void *args)
      {
          Enet_Type enetType;
          uint32_t instId;
      
          EnetApp_GetDmaHandleInArgs     txInArgs;
          EnetApp_GetTxDmaHandleOutArgs  txChInfo;
      
          EnetApp_GetDmaHandleInArgs     rxInArgs;
          EnetApp_GetRxDmaHandleOutArgs  rxChInfo;
      
          /* TX channel handle */
          EnetDma_TxChHandle hTxCh;
          /* TX channel number */
          uint32_t txChNum;
      
          /* RX channel handle */
          EnetDma_RxChHandle hRxCh;
      
          EnetApp_getEnetInstInfo(CONFIG_ENET_CPSW0,
                                  &enetType,
                                  &instId);
      
          Enet_Handle hEnet = Enet_getHandle(enetType, instId);
      
          EnetApp_setCpswAleClassifier(hEnet);
      
          EnetApp_getTxDmaHandle((ENET_DMA_TX_CH1),
                                     &txInArgs,
                                     &txChInfo);
          txChNum = txChInfo.txChNum;
          hTxCh   = txChInfo.hTxCh;
      
          EnetApp_getRxDmaHandle((ENET_DMA_RX_CH1),
                                     &rxInArgs,
                                     &rxChInfo);
          hRxCh   = rxChInfo.hRxCh;
      
          //Change layer-2 code to use above channel handles to Rx and Tx EtherCAT frames
      
      
      
          while(1)
          {
              DebugP_log("==========================\r\n");
              DebugP_log("      L2 channel Test      \r\n");
              DebugP_log("==========================\r\n");
              //Now we will receive EtherCAT frames on channel-1
              
          }
      
      
      }

      Regards

      Ashwani

    2. Hi Hang,

      As per offline discussion on 03-july, here is the complete project file for your reference.

      /cfs-file/__key/communityserver-discussions-components-files/908/enet_5F00_lwip_5F00_cpsw.zip

      Let me know if you need any further help.

      Regards

      Ashwani

    3. Hi Ashwani

      When the project runs to the "EnetApp_setCpswAleClassifier",an error occurs as shown in the following figure.

      Regards

      Lan

    4. an error occurs

      you are getting this after merging into your project file or with my standalone?

      Regards

      Ashwani

    5. Hi Ashwani

      All of the above,Whether your project or merged into mine, there will be errors. What is required for "EnetApp_setCpswAleClassifier" to run successfully?

      Regards

      Lan

    6. Hi Lan,

      At least code I provided is not giving any error for "EnetApp_setCpswAleClassifier" API.

      One thing I can suggest to start L2 example/task only after LwIP application is up and running as in my codebase:

      If still facing problem, please ask your FAE to arrange a debug session with us.

      Regards

      Ashwani

    7. Hi Ashwani

      After merging with my project, the LWIP task can now communicate normally, and the ECAT master can successfully send frames, but it can not receive frames. I found that its RXDMA callback function was not responding and still did not detect RXDMA data coming in.I want to know if I need to make any other adjustments to the RXDMA configuration.

      I also made the following adjustments in your reference project.

      1. When I run LWIP tasks, I don't succeed if the number of NETIF is 2, I succeed if the number is 1, so I've removed one NETIF.

      2. When the "Number of MAC Address" of "ENET R x DMA Channel 1" is 0, the Lay2 task will error and the code needs the Number to be 1, so I changed both DMA 0 and DMA 1 to 1.

      This is the routine I merged with my method./cfs-file/__key/communityserver-discussions-components-files/908/3146.LWIP.zip

      Regards

      Lan

    8. LWIP task can now communicate normally

      Means without adjustments you mentioned, LWIP Rx and Tx working fine. correct ?

      Basically you need to make adjustments to make EtherCAT Rx works. correct ?

      When I run LWIP tasks, I don't succeed if the number of NETIF is 2

      NETIF=0 is by default attached to LwIP.

      Note:

      • Assign Tx and Rx DMA channel as per your use case.
        • On my setup, LwIP application is using ENET_DMA_RX_CH0.

        • Layer-2 application using ENET_DMA_RX_CH1
      • Should not make it default NETIF (untick box)

      2. When the "Number of MAC Address" of "ENET R x DMA Channel 1" is 0, the Lay2 task will error and the code needs the Number to be 1, so I changed both DMA 0 and DMA 1 to 1.
      • It should be fine. On my setup had 2 MAC address assigned for LwIP use case.
      • Does your this change causing any problem on LwIP side?

      ===========================================================

      1. Can you provide CPSW stats after the issue occur ?
        1. you can refer "EnetApp_printStats" in enet_layer2_cpsw example.

      Regards

      Ashwani

    9. Hi Ashwani

      I mean the LWIP task can communicate normally after I have been adjusted above. That is, only one NETIF can be successful. If I add one to EtherCAT, the LWIP task will not succeed.I added the second NETIF without choosing the default, but it still doesn't work.

      The Ethercat task also managed to send frames after I adjusted "Number of MAC Address", but it couldn't receive frames, as I described above.

      I don't know if NETIF would have to add in order for EtherCAT tasks to successfully receive frames. But in my attempts, after adding, LWIP will have problems.

      Regards

      Lan

    10. NETIF would have to add in order for EtherCAT tasks

      NETIF is only related to LwIP.

      it couldn't receive frame

      What you can check is

      1. ALE classifier is working or not ?
        1. Provide CPSW stats after the issue occur ?
        2. It has clasifier count "
          1. /*! ALE policer matched */
            uint64_t alePolicyMatch;" 
        3. you can refer "EnetApp_printStats" in enet_layer2_cpsw example.

      Regards

      Ashwani

    11. Hi Ashwani

      When NETIF is configured as follows, the LWIP task has the following error.

      Regards

      Lan

    12. he LWIP task has the following error.

      This is because you are using single port for LwIP, not DUAL MAC (both ports).

      ALE classifier is working or not ?
      1. Provide CPSW stats after the issue occur ?
      2. It has clasifier count "
        1. /*! ALE policer matched */
          uint64_t alePolicyMatch;" 
      3. you can refer "EnetApp_printStats" in enet_layer2_cpsw example.

      Can you check these and provide update? 

      Regards

      Ashwani 

    13. This is because you are using single port for LwIP, not DUAL MAC (both ports).

      How to set to DUAL Mac?

      Can you check these

      If there are two NETIF,I can't check these, becuase the enet task reports the following error.

      If there are only one NETIF, I get the following information.

      "alePolicyMatch"=0;

      Regards

      Lan

    14. How to set to DUAL Mac?

      But, why you want to set DUAL MAC mode ?
      I think, Your requirement is using single interface for both type of traffic. correct ?

      So, go ahead with single NETIF.

      "alePolicyMatch"=0

      This is main problem. Policy is not getting match in coming frames.
      You need to debug L2 path (the Policy settings for EtherCAT frames).

      Regards

      Ashwani 

    15. I think, Your requirement is using single interface for both type of traffic. correct ?

      No

      Our requirement  are as you mentioned before.That is to use two interfaces for each type of traffic.

      The problem I'm having is that if I configure the SYSCFG as you provided me earlier, the project will run into an error on the LWIP task, and it won't work on Lay2 task.We need your help to make some adjustments to the project so that it can run smoothly.

      Regards

      Lan

    16. That is to use two interfaces for each type of traffic.

      1. NETIF is not required for port having EtherCAT traffic.

      So, single NETIF in sysconfig for LwIP is enough.

      ===============================================

      2. DMA channel-0 for LwIP application.

      DMA channel-1 for EtherCAT

      ===============================================

      3. As per this code, I am assuming EtherCAT frames are coming on CPSW-MAC-Port2. correct ?

      Regards

      Ashwani

    17. As per this code, I am assuming EtherCAT frames are coming on CPSW-MAC-Port2

      Yes, CPSW-MAC-Port1 for LWIP 

      CPSW-MAC-Port2 for EtherCAT

      The EtherCAT task currently can not receive frames, so what adjustments should I make to the code.

      Regards

      Lan

    18. I get the following information

      This HW stats shows that port2 is getting frames (Rx count) correctly. After that it is dropping somewhere.

      "alePolicyMatch"=0;

      It is clearly ALE policy related issue.

      You need to debug L2 path (the Policy settings for EtherCAT frames).

      Some more points you can review:

      EtherCAT port MAC address settings ?

      sysconfig MAC address for EtherCAT port ?

      Frames coming on port2 EtherType ?

       Put the break points in EtherCAT code and get a hit while receiving EtherCAT frame ?

      Regards

      Ashwani

    19. How to set to DUAL Mac?

      you can check sysconfig setting as below for DUAL MAC mode enablement

      Regards

      Ashwani

    20.  Put the break points in EtherCAT code and get a hit while receiving EtherCAT frame ?

      Normally, break points can enter this function, but in my project, breakpoints cannot enter.

      The following is a comparison of the simulation results between the routine and my project. Hope you can help us provide some more specific adjustments.

      Regards

      Lan

    21. routine and my project

      Routine means ?

    22. Routine means ?

      Routine is Layer2 example.

    23. Routine is Layer2 example.

      Okay .

      Normally, break points can enter this function, but in my project, breakpoints cannot enter.

      This breakpoint will hit only if ALE policy is working correctly.

      Can you ask your FAE to share updated project with me over e-mail to debug in parallel with you?

      Regards

      Ashwani