My fix in ChibiOS to make LWIP work
Posted: Fri Jan 05, 2018 11:48 am
Hi
I was testing LWIP with ChibiOS (latest, 17.6.3) on a STM32F107 (Olimex STM32-P107 board, rev. B), and noticed that it didn't work quite well (couldn't ping the IP). After some random trials, I found that I needed to insert a delay right after the call to macStart (in lwipthread.c). After further investigation I came with the following fix at the beginning of the lwip_thread function:
It takes approximately 1.9 seconds to complete, which matches the delay I was using previously, and after that LWIP works perfectly.
The only problem is that I don't really understand what's going on, and I don't even know if this is really a fix. Can someone who understands LWIP and the ETH driver help me figure out a clean solution (or explain what happens, in case I already have the proper one)?
Thanks
I was testing LWIP with ChibiOS (latest, 17.6.3) on a STM32F107 (Olimex STM32-P107 board, rev. B), and noticed that it didn't work quite well (couldn't ping the IP). After some random trials, I found that I needed to insert a delay right after the call to macStart (in lwipthread.c). After further investigation I came with the following fix at the beginning of the lwip_thread function:
Code: Select all
...
macStart(ÐD1, &mac_config);
/* begin fix */
while (!ETHD1.link_up)
{
macPollLinkStatus(ÐD1);
chThdSleepMilliseconds(100);
}
/* end fix */
netif_add(&thisif, &ip, &netmask, &gateway, NULL, ethernetif_init, tcpip_input);
...
It takes approximately 1.9 seconds to complete, which matches the delay I was using previously, and after that LWIP works perfectly.
The only problem is that I don't really understand what's going on, and I don't even know if this is really a fix. Can someone who understands LWIP and the ETH driver help me figure out a clean solution (or explain what happens, in case I already have the proper one)?
Thanks