Hi All,
We are working on KSDK example demo project lwip-tcpecho demo.
Added our own additional threads for tcp ip communication for ports 4442(web application) and 80(web server).
Our implementations are depending more on heap memory rather than stack( Ensured proper freeing and deallocation after heap use).
Our problem is that when the board is connected to ethernet continuously it got hangs after 1, 2 days. Then we need to restart again . It makes our product application a unusable one.
We tried out different cases for debugging the issue.
-We tried by stopping all other threads except web application but the problem exist.
-Ensured that different MAC ids are assigned for different boards.
-When disconnecting from ethernet, this problem is not seen.
We are suspecting the issue is with the lwip tcp ip stack porting. Not sure about this.
Can anybody suggest a better and needed solution for this.
Now we have got the assert while hanging "pbuf_free: p->re..."
Thanks,
Rahul
Solved! Go to Solution.
Hi Rahul,
Thank you for the patience.
Please check below KSDK team feedback about this issue:
There's a patch in KSDK1.3GA which might resolve this issue.
[KPSDK-7362][LWIP]Fix the lwip rtos ping block issue
diff --git a/middleware/tcpip/lwip/port/ethernetif.c b/middleware/tcpip/lwip/port/ethernetif.c
index 6e63cd0..044b5bd 100644
--- a/middleware/tcpip/lwip/port/ethernetif.c
+++ b/middleware/tcpip/lwip/port/ethernetif.c
@@ -688,14 +688,13 @@ ethernetif_init(struct netif *netif)
#if defined(FSL_RTOS_MQX)
OSA_InstallIntHandler(ENET_Transmit_IRQn, MQX_ENET_Transmit_IRQHandler);
OSA_InstallIntHandler(ENET_Receive_IRQn, MQX_ENET_Receive_IRQHandler);
-#if defined(FSL_RTOS_MQX)
OSA_InstallIntHandler(ENET_1588_Timer_IRQn, MQX_ENET_1588_Timer_IRQHandler);
#endif
/* Set priority for ISRs */
NVIC_SetPriority(ENET_1588_Timer_IRQn, 4U);
- NVIC_SetPriority(ENET_Transmit_IRQn, 4U);
- NVIC_SetPriority(ENET_Receive_IRQn, 4U);
-#endif
+ NVIC_SetPriority(ENET_Transmit_IRQn, 5U);
+ NVIC_SetPriority(ENET_Receive_IRQn, 5U);
+
/* initialize the hardware */
result = low_level_init(netif);
diff --git a/middleware/tcpip/lwip/port/lwipopts.h b/middleware/tcpip/lwip/port/lwipopts.h
index 199d0f0..dde8b8a 100644
--- a/middleware/tcpip/lwip/port/lwipopts.h
+++ b/middleware/tcpip/lwip/port/lwipopts.h
@@ -37,14 +37,14 @@
#define __LWIPOPTS_H__
/*include fsl os abstraction header file to judge whether OS is used*/
#include "fsl_os_abstraction.h"
+
+#if USE_RTOS
/**
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
* critical regions during buffer allocation, deallocation and memory
* allocation and deallocation.
*/
-#define SYS_LIGHTWEIGHT_PROT 0
-#if USE_RTOS
-
+#define SYS_LIGHTWEIGHT_PROT 1
/**
* NO_SYS==0: Use RTOS
*/
In KSDK1.2GA, the SYS_LIGHTWEIGHT_PROT macro is not enabled when RTOS is used, which may lead to crash for global variable is not protected.
I would recommend customer to update software to latest KSDK software.
You could find the latest KDSK software from below link:
Welcome to Kinetis Expert | Kinetis Expert
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Rahul,
Please provide the KSDK software version you are using. Thanks.
best regards,
Ma Hui
We are using Ksdk 1.2.0 and KDS 3.0.0.
Using the example project lwip tcpecho example for mqx in frdmk64f
Now we are getting the lwip assert as "tcpip_thread: invalid message:" on crash.
thanks
Rahul
Hi Rahul,
Thank you for the patience.
Please check below KSDK team feedback about this issue:
There's a patch in KSDK1.3GA which might resolve this issue.
[KPSDK-7362][LWIP]Fix the lwip rtos ping block issue
diff --git a/middleware/tcpip/lwip/port/ethernetif.c b/middleware/tcpip/lwip/port/ethernetif.c
index 6e63cd0..044b5bd 100644
--- a/middleware/tcpip/lwip/port/ethernetif.c
+++ b/middleware/tcpip/lwip/port/ethernetif.c
@@ -688,14 +688,13 @@ ethernetif_init(struct netif *netif)
#if defined(FSL_RTOS_MQX)
OSA_InstallIntHandler(ENET_Transmit_IRQn, MQX_ENET_Transmit_IRQHandler);
OSA_InstallIntHandler(ENET_Receive_IRQn, MQX_ENET_Receive_IRQHandler);
-#if defined(FSL_RTOS_MQX)
OSA_InstallIntHandler(ENET_1588_Timer_IRQn, MQX_ENET_1588_Timer_IRQHandler);
#endif
/* Set priority for ISRs */
NVIC_SetPriority(ENET_1588_Timer_IRQn, 4U);
- NVIC_SetPriority(ENET_Transmit_IRQn, 4U);
- NVIC_SetPriority(ENET_Receive_IRQn, 4U);
-#endif
+ NVIC_SetPriority(ENET_Transmit_IRQn, 5U);
+ NVIC_SetPriority(ENET_Receive_IRQn, 5U);
+
/* initialize the hardware */
result = low_level_init(netif);
diff --git a/middleware/tcpip/lwip/port/lwipopts.h b/middleware/tcpip/lwip/port/lwipopts.h
index 199d0f0..dde8b8a 100644
--- a/middleware/tcpip/lwip/port/lwipopts.h
+++ b/middleware/tcpip/lwip/port/lwipopts.h
@@ -37,14 +37,14 @@
#define __LWIPOPTS_H__
/*include fsl os abstraction header file to judge whether OS is used*/
#include "fsl_os_abstraction.h"
+
+#if USE_RTOS
/**
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
* critical regions during buffer allocation, deallocation and memory
* allocation and deallocation.
*/
-#define SYS_LIGHTWEIGHT_PROT 0
-#if USE_RTOS
-
+#define SYS_LIGHTWEIGHT_PROT 1
/**
* NO_SYS==0: Use RTOS
*/
In KSDK1.2GA, the SYS_LIGHTWEIGHT_PROT macro is not enabled when RTOS is used, which may lead to crash for global variable is not protected.
I would recommend customer to update software to latest KSDK software.
You could find the latest KDSK software from below link:
Welcome to Kinetis Expert | Kinetis Expert
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks Ma Hui and KSDK team for the support.
The issue solved by defining SYS_LIGHTWEIGHT_PROT to 1
Hi Rahul,
I am checking with Kinetis application team about this issue.
I will let you know when there with any feedback. Thank you for the patience.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------