XRT1050evk : Lwip in FreeRTOS, Mutex Problem with MCU Config Tools

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

XRT1050evk : Lwip in FreeRTOS, Mutex Problem with MCU Config Tools

701 Views
fabien251
Contributor I

Hello,

I am working on a program using LwIP generated by the configuration tools in FreeRTOS mode.

Here is what I have done so far:

  1. I opened an empty program project in the SDK.
  2. I added the middleware LwIP with the MCU Config Tool and FreeRTOS.
  3. I added vTaskStartScheduler to my main function, and my program ran without any problems with the tcip_thread task.

However, after that, I decided to add a network interface in LwIP using the MCU Config Tools. I included all the missing SDK components. After doing this, I encountered a FreeRTOS assert (Mutex Problem between tcip_thread and lwip_rx Tasks) without making any changes to my code.

FreeRTOS_Assert.png

Can anyone help me understand why this is happening and how to resolve it?

0 Kudos
Reply
5 Replies

601 Views
Sam_Gao
NXP Employee
NXP Employee

Hi @fabien251 

 

I tried with your attched projects to reproduce and understand what the question is, but I was confused now. Let me clarify more about them.

1. I download and opened them with MCUXpresso, then remove the lwip/doc folder, the project can be compiled sucessfuly.

2. I flash the bianry into EVK1050 board, it seems workable, no any issues.

3. I trie to find what the meanings and where are the key codes, "However, after that, I decided to add a network interface in LwIP using the MCU Config Tools. I included all the missing SDK components. After doing this, I encountered a FreeRTOS assert (Mutex Problem between tcip_thread and lwip_rx Tasks) without making any changes to my code." But Only I can see was as below,  would you please double check where is the user custom code as you descripted above.

 

 

int main(void)
{

    /* Init board hardware. */
    BOARD_ConfigMPU();
    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitBootPeripherals();

    BOARD_ENET_PHY_RESET;
    /* Update the core clock */
    SystemCoreClockUpdate();
    vTaskStartScheduler();
    /* Add user custom codes below */
    while (1)
    {
    }
}

 

 

 

And would you please give me more details about the backgroud of your project, mostly there are some useful examples about lwip/tcpip in our SDK, I will give appropriate advice to you.

 

B.R, Sam

0 Kudos
Reply

589 Views
fabien251
Contributor I

Hi @Sam_Gao,

Thank you for taking the time to look into my projects. Let me provide some additional details to help clarify the issue:

  1. Initial Project Setup:

    • I initially created a project with four FreeRTOS tasks using MCUXpresso.
    • At this stage, everything worked correctly.
  2. Adding LwIP:

    • I then added LwIP in FreeRTOS mode using the MCU Config Tools, initially without a network interface.
    • I relaunched my project in debug mode, paused it to verify each task, and confirmed that everything was functioning as expected.
  3. Adding Network Interface:

    • Afterward, I decided to add a network interface in LwIP using the MCU Config Tools.
    • I routed all the necessary pins and included all the missing SDK components.
    • After doing this, I encountered a FreeRTOS assert (mutex problem between tcip_thread and lwip_rx tasks) when I paused my program, without making any changes to my main code.
  4. Issue Encountered:

    • After adding the network interface, the project compiles and flashes correctly.
    • However, during execution, my other FreeRTOS tasks do not run, and the code gets stuck in the assert related to the mutex problem mentioned above when I pause the program.
  5. Steps Taken:

    • I created a blank project with only LwIP configured using the MCU Config Tools to isolate the issue.
    • Even in this minimal configuration, I encountered the same assertion problem.
    • I have tried the SDK examples for LwIP/TCPIP, and they work completely. However, I want to continue using the MCU Config Tool system to configure LwIP for my project.
  6. Current Main Code:

    • The main code in the LwIP blank project looks like this:

      int main(void)
      {
      
          /* Init board hardware. */
          BOARD_ConfigMPU();
          BOARD_InitBootPins();
          BOARD_InitBootClocks();
          BOARD_InitBootPeripherals();
      
          BOARD_ENET_PHY_RESET;
          /* Update the core clock */
          SystemCoreClockUpdate();
          vTaskStartScheduler();
          /* Add user custom codes below */
          while (1)
          {
          }
      }
       
    • This main function is essentially the default initialization code with FreeRTOS starting, and I have not added any custom user code yet.

 

Thank you for your assistance.

 

Fabien GALICIER

0 Kudos
Reply

447 Views
Sam_Gao
NXP Employee
NXP Employee

Hi @fabien251 

Currently there are some issues about MCU Config Tools, I would like to recommend you to use workable SDK instead. And the issue of MCU config tools will be fixed in the following new version, but it may take long time.

Then for other feature, please continue using the MCU Config Tool if need, but please consider SDK if you still meet similar issues from MCU Config Tool.

 

B.R,

Sam

0 Kudos
Reply

655 Views
fabien251
Contributor I

Hi @Sam_Gao ,

To fix this issue you need to exclude /lwip/doc folder of the project (another bug in MCUExpresso)

Best regards,

 

Fabien

0 Kudos
Reply

659 Views
Sam_Gao
NXP Employee
NXP Employee

Hi @fabien251 

It seems something wrong with Mutex problem, the project build failed as below.

Would you please give me workable one so that I can support to reproduce it?

Thanks in advance.

 

./lwip/doc/NO_SYS_SampleCode.c:96:37: error: 'queue' undeclared (first use in this function)
   96 |     struct pbuf* p = queue_try_get(&queue);
      |                                     ^~~~~
../lwip/doc/NO_SYS_SampleCode.c:100:22: error: 'link' undeclared (first use in this function)
  100 |       LINK_STATS_INC(link.recv);
      |                      ^~~~
../lwip/doc/NO_SYS_SampleCode.c:103:35: error: 'ifinoctets' undeclared (first use in this function)
  103 |       MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
      |                                   ^~~~~~~~~~
../lwip/doc/NO_SYS_SampleCode.c:103:48: error: invalid use of undefined type 'struct pbuf'
  103 |       MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
      |                                                ^~
../lwip/doc/NO_SYS_SampleCode.c:104:24: error: invalid use of undefined type 'struct pbuf'
  104 |       int unicast = ((p->payload[0] & 0x01) == 0);
      |                        ^~
../lwip/doc/NO_SYS_SampleCode.c:106:37: error: 'ifinucastpkts' undeclared (first use in this function)
  106 |         MIB2_STATS_NETIF_INC(netif, ifinucastpkts);
      |                                     ^~~~~~~~~~~~~
../lwip/doc/NO_SYS_SampleCode.c:108:37: error: 'ifinnucastpkts' undeclared (first use in this function)
  108 |         MIB2_STATS_NETIF_INC(netif, ifinnucastpkts);
      |                                     ^~~~~~~~~~~~~~
../lwip/doc/NO_SYS_SampleCode.c:111:36: error: 'ERR_OK' undeclared (first use in this function)
  111 |       if(netif.input(p, &netif) != ERR_OK) {
      |                                    ^~~~~~
../lwip/doc/NO_SYS_SampleCode.c:117:5: warning: implicit declaration of function 'sys_check_timeouts' [-Wimplicit-function-declaration]
  117 |     sys_check_timeouts();
      |     ^~~~~~~~~~~~~~~~~~
make[1]: *** [lwip/doc/subdir.mk:23: lwip/doc/ZeroCopyRx.o] Error 1
Building file: ../freertos/freertos-kernel/queue.c
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [lwip/doc/subdir.mk:23: lwip/doc/NO_SYS_SampleCode.o] Error 1

 

 

B.R,

Sam

 

 

 

0 Kudos
Reply