FreeRTOS crash in a Wi-Fi setup example

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FreeRTOS crash in a Wi-Fi setup example

891 次查看
azarubkin
Contributor II

I'm getting FreeRTOS crash in the "wifi_setup" example imported from SDK.

Here's a tail of the debugging session output:

[New Thread 3]
[New Thread 9]
[New Thread 1610631818]
[New Thread 5]
[New Thread 6]
[New Thread 4]
[New Thread 8]
[New Thread 7]
[New Thread 10]

Thread 
2 received signal SIGSTOP, Stopped (signal).
[Switching to Thread 3]
Reset_Handler () at C:/tmp/mcux_sdk_release_25_06_00/mcuxsdk/devices/RT/RT1060/MIMXRT1062/gcc\startup_MIMXRT1062.S:446
446	    b DefaultISR

The debugger shows the state of the threads. The top of the current thread call stack is:

"Tmr Svc": Stopped
Reset_Handler@0x60002524
<signal handler called>@0xfffffffd

If I look at pxReadyTasksLists array in the debugger, it shows that its 2nd element has uxNumberOfItems == 1 but pxIndex points to xListEnd. At the same time, xListEnd->pxNext and pxPrevious point to "tcp/ip" task. I've attached a screenshot.

azarubkin_0-1752673050909.png

My setup:

  • MIMXRT1060-EVKB board
  • MAYA-W161 M.2 Wi-Fi card
  • I have the resistors resoldered on the board to enable M.2 connector.
  • I'm using Visual Studio Code with MCUXpresso for VS Code extension
  • I've imported MCUXpresso SDK Repository version 25.03.00 (I've checked version 25.06.00 but it made no difference)
  • I've imported the following example from Repository: wifi_examples/wifi_setup, as a Freestanding application.
  • I've also made a wrapper for tcpip_input function to print something to the debug console.

As my Wi-Fi card isn't readily available in the choice of cards, I've made the following changes to the SDK sources:

(.venv) c:\tmp\mcux_sdk_release_25_06_00\mcuxsdk>west diff
=== diff for mcu-sdk-examples (mcuxsdk/examples):
diff --git mcuxsdk/examples/_boards/evkbmimxrt1060/wifi_examples/wifi_setup/prj.conf mcuxsdk/examples/_boards/evkbmimxrt1060/wifi_examples/wifi_setup/prj.conf
index 8892a39d6..8060d7118 100644
--- mcuxsdk/examples/_boards/evkbmimxrt1060/wifi_examples/wifi_setup/prj.conf
+++ mcuxsdk/examples/_boards/evkbmimxrt1060/wifi_examples/wifi_setup/prj.conf
@@ -7,4 +7,4 @@ CONFIG_MCUX_COMPONENT_middleware.sdmmc.host.usdhc.non_blocking=y
 CONFIG_MCUX_COMPONENT_utility.assert_lite=n
 CONFIG_MCUX_COMPONENT_utility.debug_console_lite=n
 CONFIG_MCUX_COMPONENT_component.wifi_bt_module.IW416=y
-CONFIG_MCUX_COMPONENT_component.wifi_bt_module.board_murata_1xk_usd=y
\ No newline at end of file
+CONFIG_MCUX_COMPONENT_component.wifi_bt_module.board_ubx_maya_w1_m2=y


=== diff for mcu-sdk-components (mcuxsdk/components):
diff --git mcuxsdk/components/wifi_bt_module/CMakeLists.txt mcuxsdk/components/wifi_bt_module/CMakeLists.txt
index d06643b..6e7c777 100644
--- mcuxsdk/components/wifi_bt_module/CMakeLists.txt
+++ mcuxsdk/components/wifi_bt_module/CMakeLists.txt
@@ -154,6 +154,12 @@ if (CONFIG_MCUX_COMPONENT_component.wifi_bt_module.board_ubx_maya_w1_usd)
     )
 endif()

+if (CONFIG_MCUX_COMPONENT_component.wifi_bt_module.board_ubx_maya_w1_m2)
+     mcux_add_macro(
+        "-DWIFI_IW416_BOARD_UBX_MAYA_W1_M2"
+    )
+endif()
+
 if (CONFIG_MCUX_COMPONENT_component.wifi_bt_module.board_murata_2dl_m2)
      mcux_add_macro(
         "-DWIFI_IW611_BOARD_MURATA_2DL_M2"
diff --git mcuxsdk/components/wifi_bt_module/Kconfig mcuxsdk/components/wifi_bt_module/Kconfig
index ee38df8..0d37f8f 100644
--- mcuxsdk/components/wifi_bt_module/Kconfig
+++ mcuxsdk/components/wifi_bt_module/Kconfig
@@ -246,6 +246,20 @@ menu "wifi_bt_module"
                         Detailed information about Type MAYA W1 module you can find on
                         https://www.u-blox.com/en/product/maya-w1-series

+                config MCUX_COMPONENT_component.wifi_bt_module.board_ubx_maya_w1_m2
+                    bool "NXP UBX-MAYA-W1-M2"
+                    help
+                        The MAYA-W1 series are host-based Wi-Fi 4 and Bluetooth 5.2 multiradio
+                        modules designed for a wide range of industrial applications, such as
+                        industrial automation and smart manufacturing, EV charging infrastructures,
+                        professional appliances, tracking and telematics, point-of-sale and
+                        ticketing machines, building automation, and healthcare. The modules
+                        are designed and built to meet the high reliability and quality requirements
+                        of such applications.
+
+                        Detailed information about Type MAYA W1 module you can find on
+                        https://www.u-blox.com/en/product/maya-w1-series
+
             endchoice
         endif

diff --git mcuxsdk/components/wifi_bt_module/incl/wifi_bt_module_config.h mcuxsdk/components/wifi_bt_module/incl/wifi_bt_module_config.h
index b59457d..84316a5 100644
--- mcuxsdk/components/wifi_bt_module/incl/wifi_bt_module_config.h
+++ mcuxsdk/components/wifi_bt_module/incl/wifi_bt_module_config.h
@@ -286,6 +286,17 @@
         .ed_ctrl_2g = 0x1, .ed_offset_2g = 0x9, .ed_ctrl_5g = 0x1, .ed_offset_5g = 0xC \
     }

+/* u-blox EVK-MAYA-W1-M2 */
+#elif defined(WIFI_IW416_BOARD_UBX_MAYA_W1_M2)
+#define WIFI_BT_TX_PWR_LIMITS "wlan_txpwrlimit_cfg_WW.h"
+#define SD8978
+#define SDMMCHOST_OPERATION_VOLTAGE_1V8
+#define WIFI_BT_USE_M2_INTERFACE
+#define WLAN_ED_MAC_CTRL                                                               \
+    {                                                                                  \
+        .ed_ctrl_2g = 0x1, .ed_offset_2g = 0x9, .ed_ctrl_5g = 0x1, .ed_offset_5g = 0xC \
+    }
+
 /* Redfinch RW61X */
 #elif defined(WIFI_BOARD_RW610)
 #define WIFI_BT_TX_PWR_LIMITS "wlan_txpwrlimit_cfg_WW_rw610.h"


=== diff for wifi_nxp (mcuxsdk/middleware/wifi_nxp):
diff --git mcuxsdk/middleware/wifi_nxp/port/net/net.c mcuxsdk/middleware/wifi_nxp/port/net/net.c
index 5b830d24..6a4a48d2 100644
--- mcuxsdk/middleware/wifi_nxp/port/net/net.c
+++ mcuxsdk/middleware/wifi_nxp/port/net/net.c
@@ -318,8 +318,10 @@ int net_wlan_init(void)
         (void)wifi_register_wrapper_net_is_ip_or_ipv6_callback(&wrapper_net_is_ip_or_ipv6);
 #endif
         ip_2_ip4(&g_mlan.ipaddr)->addr = INADDR_ANY;
+// HACK: This is a hack to allow the wifi_tcpip_input_wrapper to be used as the input function for the wifi interface
+err_t wifi_tcpip_input_wrapper(struct pbuf *p, struct netif *netif);
         ret = netifapi_netif_add(&g_mlan.netif, ip_2_ip4(&g_mlan.ipaddr), ip_2_ip4(&g_mlan.ipaddr),
-                                 ip_2_ip4(&g_mlan.ipaddr), NULL, lwip_netif_init, tcpip_input);
+                                 ip_2_ip4(&g_mlan.ipaddr), NULL, lwip_netif_init, wifi_tcpip_input_wrapper);
         if (ret != WM_SUCCESS)
         {
             net_e("MLAN interface add failed");
@@ -331,7 +333,7 @@ int net_wlan_init(void)

 #if UAP_SUPPORT
         ret = netifapi_netif_add(&g_uap.netif, ip_2_ip4(&g_uap.ipaddr), ip_2_ip4(&g_uap.ipaddr),
-                                 ip_2_ip4(&g_uap.ipaddr), NULL, lwip_netif_uap_init, tcpip_input);
+                                 ip_2_ip4(&g_uap.ipaddr), NULL, lwip_netif_uap_init, wifi_tcpip_input_wrapper);
         if (ret != WM_SUCCESS)
         {
             net_e("UAP interface add failed");


Empty diff in 91 projects.

My wrapper function looks as:

err_t wifi_tcpip_input_wrapper(struct pbuf *p, struct netif *netif)
{
    PRINTF("In wrapper\r\n");
    const err_t result = tcpip_input(p, netif);
    return result;
}

So there's nothing criminal there, just calling the original function. The crash happens after "In wrapper" is printed to the console, when the software should switch to "tcp/ip" task.

There's a similar post on FreeRTOS forum: https://forums.freertos.org/t/incorrect-pxreadytaskslists-state-causes-fault/17791, only in my case pxCurrentTCB is correct, pointing to "Tmr Svc" task.

The solution to that topic was an incorrect interrupt priority. I tried setting all NVIC->IPRn registers to 0xF0 at the beginning of the program to set all priorities to the lowest possible level but that didn't help. I also checked the stacks -- they are fine. I can attach my project or upload it anywhere if that helps.

If I don't use wrapper function, so that the SDK code calls tcpip_input directly, the example works but sometimes I get delays in ping responses of like 1600 ms which is strange because I ping my local router. So I suspect the bug is still there but adding a PRINTF makes it more apparent.

0 项奖励
回复
8 回复数

857 次查看
azarubkin
Contributor II

xPSR register value is 0x81000004.

0 项奖励
回复

857 次查看
azarubkin
Contributor II

If I run the project in MCUXpresso IDE with SDK 25.6.0, the execution hits MemManage_Handler, if that helps. In MCUXpresso for VS Code, it's DefaultISR instead of MemManage_Handler.

0 项奖励
回复

876 次查看
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hi,

 

Let me check this.

 

Regards,

Daniel.

0 项奖励
回复

848 次查看
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hi,

 

I tested wifi_setup on an RT1060-EVKB with a 1XK (IW416) M.2 module, and it is working on my side. I selected the correct module by using the Kconfig GUI.

1. Right click on the project > Configure > Open Kconfig GUI Configuration

2. Component configuration > wifi_bt_module > config > Select NXP IW416 module (NXP IW416-MURATA-1XK-M2)

 

There is no option for MAYA-W161. Nevertheless, both modules use the same SoC. Could you please try with the same option as me "NXP IW416-MURATA-1XK-M2"?

 

Regards,

Daniel.

0 项奖励
回复

842 次查看
azarubkin
Contributor II

Have you tried building it in debug mode? I've found that the crash happens only in debug build. Also, setting

#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)
 
fixes it in debug mode as well.
 
It appears stack overflow happens in timer task in debug mode. How do I calculate the amount of stack needed for the task?
 
0 项奖励
回复

817 次查看
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hi,

I'm not sure why it crashes on your side. Are you using the example as is with the recommendation I gave you?

I tested in on 25.03 in debug mode and it is working on my side.

Regards,
Daniel.

0 项奖励
回复

712 次查看
azarubkin
Contributor II
For some reason, replacing tcpip_input with a simple wrapper leads to stack requirements growth in Tmr Svc thread.
0 项奖励
回复

813 次查看
azarubkin
Contributor II

Yes I am sure. I've imported the example from scratch, reverted most of my modifications to the SDK and selected MURATA-1XK-M2 board in the Kconfig GUI tool.

The only modification to the SDK is to call my wrapper function instead of tcpip_input:

=== diff for wifi_nxp (mcuxsdk/middleware/wifi_nxp):
diff --git mcuxsdk/middleware/wifi_nxp/port/net/net.c mcuxsdk/middleware/wifi_nxp/port/net/net.c
index 5b830d24..6a4a48d2 100644
--- mcuxsdk/middleware/wifi_nxp/port/net/net.c
+++ mcuxsdk/middleware/wifi_nxp/port/net/net.c
@@ -318,8 +318,10 @@ int net_wlan_init(void)
         (void)wifi_register_wrapper_net_is_ip_or_ipv6_callback(&wrapper_net_is_ip_or_ipv6);
 #endif
         ip_2_ip4(&g_mlan.ipaddr)->addr = INADDR_ANY;
+// HACK: This is a hack to allow the wifi_tcpip_input_wrapper to be used as the input function for the wifi interface
+err_t wifi_tcpip_input_wrapper(struct pbuf *p, struct netif *netif);
         ret = netifapi_netif_add(&g_mlan.netif, ip_2_ip4(&g_mlan.ipaddr), ip_2_ip4(&g_mlan.ipaddr),
-                                 ip_2_ip4(&g_mlan.ipaddr), NULL, lwip_netif_init, tcpip_input);
+                                 ip_2_ip4(&g_mlan.ipaddr), NULL, lwip_netif_init, wifi_tcpip_input_wrapper);
         if (ret != WM_SUCCESS)
         {
             net_e("MLAN interface add failed");
@@ -331,7 +333,7 @@ int net_wlan_init(void)

 #if UAP_SUPPORT
         ret = netifapi_netif_add(&g_uap.netif, ip_2_ip4(&g_uap.ipaddr), ip_2_ip4(&g_uap.ipaddr),
-                                 ip_2_ip4(&g_uap.ipaddr), NULL, lwip_netif_uap_init, tcpip_input);
+                                 ip_2_ip4(&g_uap.ipaddr), NULL, lwip_netif_uap_init, wifi_tcpip_input_wrapper);
         if (ret != WM_SUCCESS)
         {
             net_e("UAP interface add failed");

And the wrapper function itself is:

err_t wifi_tcpip_input_wrapper(struct pbuf *p, struct netif *netif)
{
    PRINTF("In wrapper\r\n");
    const err_t result = tcpip_input(p, netif);
    return result;
}

 

0 项奖励
回复