Restarting the ethernet + OS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 4:32 AM
Hello everyone.
What is the proper procedure when restarting the entire ethernet?
Im using LWIP and FreeRTOS and im not sure if im restarting everything correctly...
These are the steps im using.
- Terminate TCP Server thread.
netif_set_down(&gnetif);
netif_remove(&gnetif);
netconn_delete(Connection);
osThreadTerminate(ThreadID);
- HAL
HAL_ETH_Stop(&heth);
HAL_ETH_DeInit(&heth);
HAL_ETH_Init(&heth);
HAL_ETH_Start(&heth);
​
- Start TCP server
netif_set_ipaddr(&gnetif, ip);
netif_set_up(&gnetif);
ThreadID = osThreadNew(TCP_Thread, NULL, &TCP_Thread_attributes);​
What steps am i missing?
Thanks for any replies :)
- Labels:
-
Ethernet
-
FreeRTOS
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 7:22 AM
Hello @XD ,
Restarting Lwip and Ethernet are not the same think as Lwip is a software set of function using ethernet to implement the rest of TCP/IP model and Ethernet is a peripheral integrated in the STM32 so doing a Dinit and Init to Ethernet is able to make it restart regarding Lwip it is up to you to know how to handle it and implement proper callback to recover when the Ethernet peripheral is uninitialized .
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-22 6:20 AM
Hi @STea,
De-initializing the ethernet (hardware & PHY) will cause the LWIP to malfunction. I'm using the standard LWIP + OS CubeMX configuration which creates a task for LWIP and one for TCPIP.
void MX_LWIP_Init(void);
There does not seem to be a matching "DeInit" function for the above Init.
What is the recommended approach?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-25 5:20 AM
Hello @XD ,
there is no function to de-initialize Lwip as this should not be normally done because Lwip has tools to recover in case it encounters a problem or when the Link is down
-
Ensure that the TCP server thread is properly terminated.
- delete the ethernet_link_thread
-
Set the Network Interface Down:
netif_set_down(&gnetif); -
Remove the Network Interface:
netif_remove(&gnetif); -
Delete the Network Connection:
netconn_delete(Connection); -
de-initialize Ethernet peripheral
HAL_ETH_Stop(&heth);HAL_ETH_DeInit(&heth); - initialize all using MX_Lwip_Init() again
I think this is the logical order in which you should procced from my point of view as we will need to revert the actions done in lwip init function.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-31 8:06 AM
Hello @XD ,
did manage to try this out?
Regards
