why the mainLoopTask gone while run the lwip_FreeRTOS_s32k396 project for half an hour

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

why the mainLoopTask gone while run the lwip_FreeRTOS_s32k396 project for half an hour

534 Views
zhangzhixing
Contributor III

why the mainLoopTask gone while run the lwip_FreeRTOS_s32k396 project for half an hour ,i import the profinet master control code and run the program ,got the below:the #1 task which is mainLoopTask  is missing.

zhangzhixing_0-1754126647621.png

 

static void mainLoopTask(void* pvParameters)
{
(void)pvParameters;

/* initialize lwIP stack, network interfaces and applications */
#if !NO_SYS
err_t err;
sys_sem_t init_sem;

#if defined (CPU_MPC5777C)|| defined (CPU_MPC5746R)
#ifdef PIT_0
#define PIT PIT_0
#endif
PIT->MCR &= (uint32_t)(~PIT_MCR_FRZ_MASK);/* stop the timer in debug workaround for compability on MPC5777C PIT timer*/
#endif

err = sys_sem_new(&init_sem, 0);
LWIP_ASSERT("failed to create init_sem", err == (err_t)ERR_OK);
LWIP_UNUSED_ARG(err);
tcpip_init(test_init, (void*)&init_sem);
/* we have to wait for initialization to finish before
* calling update_adapter()! */
(void)sys_sem_wait(&init_sem);
sys_sem_free(&init_sem);
#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
netconn_thread_init();
#endif
#else /* !NO_SYS */
sys_init();
lwip_init();
test_init(NULL);
#endif /* !NO_SYS */


#if LWIP_INIT_COMPLETE_CALLBACK
tcpip_init_complete_callback();
#endif /* LWIP_INIT_COMPLETE_CALLBACK */
// vJYBus_SetCyclicDataSize(4,4);
/* MAIN LOOP for driver update (and timers if NO_SYS) */
while (1) {
#if NO_SYS
/* handle timers (already done in tcpip.c when NO_SYS=0) */
sys_check_timeouts();
#else /* NO_SYS */
// sys_msleep(500);
// ucTestOut[0]++;
// ucTestOut[1]++;
// ucTestOut[2]++;
// ucTestOut[3]++;
// JYBus_WriteCylicData(ucTestOut, 4);

#endif /* NO_SYS */

#if defined(USING_RTD)
uint32 time_now = OsIf_GetMilliseconds();
#else /* USING_RTD */
uint32_t time_now = OSIF_GetMilliseconds();
#endif /* USING_RTD */
time_now = time_now / (double)1000;

/* If more than expected time passed during tests execution, shut down the stack */
if (time_now - start_time >= tests_timeout)
{
for(int i = 0 ; i < ETHIF_NUMBER ; i++)
{
ETHIF_SHUTDOWN(&network_interfaces[i]);
}

end_tcpip_execution(NULL);
}

}

#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
netconn_thread_cleanup();
#endif
/* release the network interfaces... */
for(int i = 0 ; i < ETHIF_NUMBER ; i++)
{
ETHIF_SHUTDOWN(&network_interfaces[i]);
}
}

Tags (1)
0 Kudos
Reply
1 Reply

506 Views
PavelL
NXP Employee
NXP Employee

Hello @zhangzhixing ,

Please comment out the entire timeout section in the code, as I typically do when bringing up lwIP examples on various boards:

PavelL_0-1754295798109.png

The variable tests_timeout is set to 1200, which corresponds to 20 minutes. After this period, the code explicitly shuts down the Ethernet interfaces and calls end_tcpip_execution(NULL), which may internally terminate the mainLoopTask.

Best regards,

Pavel

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2145654%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ewhy%20the%20mainLoopTask%20gone%20while%20run%20the%20lwip_FreeRTOS_s32k396%20project%20for%20half%20an%20hour%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2145654%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ewhy%20the%20mainLoopTask%20gone%20while%20run%20the%20lwip_FreeRTOS_s32k396%20project%20for%20half%20an%20hour%20%EF%BC%8Ci%20import%20the%20profinet%20master%20control%20code%20and%20run%20the%20program%20%EF%BC%8Cgot%20the%20below%EF%BC%9Athe%20%231%20task%20which%20is%26nbsp%3BmainLoopTask%26nbsp%3B%20is%20missing.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22zhangzhixing_0-1754126647621.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22zhangzhixing_0-1754126647621.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F350689i73B7C85307341CD5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22zhangzhixing_0-1754126647621.png%22%20alt%3D%22zhangzhixing_0-1754126647621.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Estatic%20void%20mainLoopTask(void*%20pvParameters)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E(void)pvParameters%3B%3C%2FP%3E%3CP%3E%2F*%20initialize%20lwIP%20stack%2C%20network%20interfaces%20and%20applications%20*%2F%3CBR%20%2F%3E%23if%20!NO_SYS%3CBR%20%2F%3Eerr_t%20err%3B%3CBR%20%2F%3Esys_sem_t%20init_sem%3B%3C%2FP%3E%3CP%3E%23if%20defined%20(CPU_MPC5777C)%7C%7C%20defined%20(CPU_MPC5746R)%3CBR%20%2F%3E%23ifdef%20PIT_0%3CBR%20%2F%3E%23define%20PIT%20PIT_0%3CBR%20%2F%3E%23endif%3CBR%20%2F%3EPIT-%26gt%3BMCR%20%26amp%3B%3D%20(uint32_t)(~PIT_MCR_FRZ_MASK)%3B%2F*%20stop%20the%20timer%20in%20debug%20workaround%20for%20compability%20on%20MPC5777C%20PIT%20timer*%2F%3CBR%20%2F%3E%23endif%3C%2FP%3E%3CP%3Eerr%20%3D%20sys_sem_new(%26amp%3Binit_sem%2C%200)%3B%3CBR%20%2F%3ELWIP_ASSERT(%22failed%20to%20create%20init_sem%22%2C%20err%20%3D%3D%20(err_t)ERR_OK)%3B%3CBR%20%2F%3ELWIP_UNUSED_ARG(err)%3B%3CBR%20%2F%3Etcpip_init(test_init%2C%20(void*)%26amp%3Binit_sem)%3B%3CBR%20%2F%3E%2F*%20we%20have%20to%20wait%20for%20initialization%20to%20finish%20before%3CBR%20%2F%3E*%20calling%20update_adapter()!%20*%2F%3CBR%20%2F%3E(void)sys_sem_wait(%26amp%3Binit_sem)%3B%3CBR%20%2F%3Esys_sem_free(%26amp%3Binit_sem)%3B%3CBR%20%2F%3E%23if%20(LWIP_SOCKET%20%7C%7C%20LWIP_NETCONN)%20%26amp%3B%26amp%3B%20LWIP_NETCONN_SEM_PER_THREAD%3CBR%20%2F%3Enetconn_thread_init()%3B%3CBR%20%2F%3E%23endif%3CBR%20%2F%3E%23else%20%2F*%20!NO_SYS%20*%2F%3CBR%20%2F%3Esys_init()%3B%3CBR%20%2F%3Elwip_init()%3B%3CBR%20%2F%3Etest_init(NULL)%3B%3CBR%20%2F%3E%23endif%20%2F*%20!NO_SYS%20*%2F%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%23if%20LWIP_INIT_COMPLETE_CALLBACK%3CBR%20%2F%3Etcpip_init_complete_callback()%3B%3CBR%20%2F%3E%23endif%20%2F*%20LWIP_INIT_COMPLETE_CALLBACK%20*%2F%3CBR%20%2F%3E%2F%2F%20vJYBus_SetCyclicDataSize(4%2C4)%3B%3CBR%20%2F%3E%2F*%20MAIN%20LOOP%20for%20driver%20update%20(and%20timers%20if%20NO_SYS)%20*%2F%3CBR%20%2F%3Ewhile%20(1)%20%7B%3CBR%20%2F%3E%23if%20NO_SYS%3CBR%20%2F%3E%2F*%20handle%20timers%20(already%20done%20in%20tcpip.c%20when%20NO_SYS%3D0)%20*%2F%3CBR%20%2F%3Esys_check_timeouts()%3B%3CBR%20%2F%3E%23else%20%2F*%20NO_SYS%20*%2F%3CBR%20%2F%3E%2F%2F%20sys_msleep(500)%3B%3CBR%20%2F%3E%2F%2F%20ucTestOut%5B0%5D%2B%2B%3B%3CBR%20%2F%3E%2F%2F%20ucTestOut%5B1%5D%2B%2B%3B%3CBR%20%2F%3E%2F%2F%20ucTestOut%5B2%5D%2B%2B%3B%3CBR%20%2F%3E%2F%2F%20ucTestOut%5B3%5D%2B%2B%3B%3CBR%20%2F%3E%2F%2F%20JYBus_WriteCylicData(ucTestOut%2C%204)%3B%3C%2FP%3E%3CP%3E%23endif%20%2F*%20NO_SYS%20*%2F%3C%2FP%3E%3CP%3E%23if%20defined(USING_RTD)%3CBR%20%2F%3Euint32%20time_now%20%3D%20OsIf_GetMilliseconds()%3B%3CBR%20%2F%3E%23else%20%2F*%20USING_RTD%20*%2F%3CBR%20%2F%3Euint32_t%20time_now%20%3D%20OSIF_GetMilliseconds()%3B%3CBR%20%2F%3E%23endif%20%2F*%20USING_RTD%20*%2F%3CBR%20%2F%3Etime_now%20%3D%20time_now%20%2F%20(double)1000%3B%3C%2FP%3E%3CP%3E%2F*%20If%20more%20than%20expected%20time%20passed%20during%20tests%20execution%2C%20shut%20down%20the%20stack%20*%2F%3CBR%20%2F%3Eif%20(time_now%20-%20start_time%20%26gt%3B%3D%20tests_timeout)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Efor(int%20i%20%3D%200%20%3B%20i%20%26lt%3B%20ETHIF_NUMBER%20%3B%20i%2B%2B)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EETHIF_SHUTDOWN(%26amp%3Bnetwork_interfaces%5Bi%5D)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Eend_tcpip_execution(NULL)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3E%23if%20(LWIP_SOCKET%20%7C%7C%20LWIP_NETCONN)%20%26amp%3B%26amp%3B%20LWIP_NETCONN_SEM_PER_THREAD%3CBR%20%2F%3Enetconn_thread_cleanup()%3B%3CBR%20%2F%3E%23endif%3CBR%20%2F%3E%2F*%20release%20the%20network%20interfaces...%20*%2F%3CBR%20%2F%3Efor(int%20i%20%3D%200%20%3B%20i%20%26lt%3B%20ETHIF_NUMBER%20%3B%20i%2B%2B)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EETHIF_SHUTDOWN(%26amp%3Bnetwork_interfaces%5Bi%5D)%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2146043%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20why%20the%20mainLoopTask%20gone%20while%20run%20the%20lwip_FreeRTOS_s32k396%20project%20for%20half%20an%20hour%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2146043%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F245816%22%20target%3D%22_blank%22%3E%40zhangzhixing%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EPlease%20comment%20out%20the%20entire%20timeout%20section%20in%20the%20code%2C%20as%20I%20typically%20do%20when%20bringing%20up%20lwIP%20examples%20on%20various%20boards%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3C!--ScriptorStartFragment--%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20class%3D%22scriptor-paragraph%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22PavelL_0-1754295798109.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22PavelL_0-1754295798109.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F350779iFBF5D73F42D3C624%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22PavelL_0-1754295798109.png%22%20alt%3D%22PavelL_0-1754295798109.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%0A%3CP%3E%3CSPAN%3ET%3C%2FSPAN%3E%3CSPAN%3Ehe%20variable%20%3C%2FSPAN%3E%3CSPAN%3Etests_timeout%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eis%20set%20to%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E1200%3C%2FSPAN%3E%3CSPAN%3E%2C%20which%20corresponds%20to%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E20%20minutes%3C%2FSPAN%3E%3CSPAN%3E.%20After%20this%20period%2C%20the%20code%20explicitly%20shuts%20down%20the%20Ethernet%20interfaces%20and%20calls%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eend_tcpip_execution(NULL)%3C%2FSPAN%3E%3CSPAN%3E%2C%20which%20may%20internally%20terminate%20the%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EmainLoopTask%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3EPavel%3C%2FP%3E%3C%2FLINGO-BODY%3E