STM32F427VI - HardFault_Handler because of ethernet configuration
Hi all, I moved a code that was working on STM32F427VI and somehow I am facing a new issue that I have never see before.
My code works in debug and release when the unit is compiled from Visual Studio and the Ethernet cable is connected or disconnected. But, after I reset the unit (power off/power on) the unit is working when the ethernet cable is connected. If the cable is disconnected go over the while true inside HardFault_Handler. I think that the problem is on that function:
bool configureNetwork(network_config& netconfig)
{
struct ip4_addr ipaddr;
struct ip4_addr netmask;
struct ip4_addr gw;
struct ip4_addr dns;
network_config::setIPAddr(&ipaddr, netconfig.ip);
network_config::setIPAddr(&netmask, netconfig.mask);
network_config::setIPAddr(&gw, netconfig.gateway);
network_config::setIPAddr(&dns, netconfig.dns);
if (gnetStarted) {
handleDHCP(netconfig.isDynamic());
if (curDynamic == false) {
netif_set_addr(&gnetif, &ipaddr, &netmask, &gw);
dns_setserver(0, &dns);
}
}
else {
STARTUP_TRACE.Write("before: netif_add\r\n", 1000);
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input);
STARTUP_TRACE.Write("after: netif_add\r\n", 1000);
/* Registers the default network interface */
netif_set_default(&gnetif);
netif_set_status_callback(&gnetif, netstatus_callback);
if (netif_is_link_up(&gnetif))
{
/* When the netif is fully configured this function must be called */
netif_set_up(&gnetif);
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}
handleDHCP(netconfig.isDynamic());
if (curDynamic == false) {
dns_setserver(0, &dns);
}
netif_set_link_callback(&gnetif, ethernetif_update_config);
gnetStarted = true;
sys_timeout(LINK_CHECK_INTERVAL, second_timeout, NULL);
}
return true;
}I have this conclusion becasue when I remark this function, the hardFaultHandler is called even when the unit is in debug on visual studio. So the result is the same.
I don't understand what is the difference when the mcu is conencted to the debugger and why the handler is called when the cable is disconnected. I have this issues on the Ethernet for the first time.
Any idea?
