lwIP on STM32F407 work only with debugger w/STMCubeMX and Keil

Thread Starter

ElecAlt

Joined Dec 8, 2021
1
Hello everybody

As announced in the title of the post, I am working on STM32 which I want to connect thanks to the Ethernet and LWIP config. Right now, I just want to ping my card.

I followed several tutorials on websites and youtube. My setup is good. I can ping my card at the address configured in lwip.c
BUT I can only ping with the debugger and I need to force the run 4 times to be able to ping and to call my main.c

For a simply soft to blink led, your build, your flash and the system run.
In my case, i need to run 4 times and i can do that only with debugger.
That's happened just if MX_Lwip_init() or/and MX_LWIP_process() are called
I think something happened when i build but i don't know what.

Thanks if someone have response

Have a good day !

-EleAlt
 

pbaudrate

Joined Oct 29, 2024
1
Chiming into a dead thread because I just had a similar issue with an STM32F429zi and IAR EWARM 8.32

Pinging the device through ethernet only worked if I flashed it through the debugger interface in the IDE.

What ended up making it work for me was adding delays between clock config and LWIP init and also manually calling the functions to bring up the ethernet interface after the init.

I'm not sure why this worked, but for any future people who come across this thread, I hope it helps.

Here is the relevant selection from my main.c


main.c selection:
  SystemClock_Config();
  HAL_Delay(2000);
  MX_GPIO_Init();
  HAL_Delay(100);
  MX_LWIP_Init();

  extern struct netif gnetif;
  // manually call peripheral interface setup
  netif_set_up(&gnetif);    // Bring the interface up
  netif_set_link_up(&gnetif);  // Set link state up

  while (1)
  {
    // Optional, set indicator LED
    if (netif_is_link_up(&gnetif)) {
      HAL_GPIO_WritePin(GPIOB, LD1_Pin, GPIO_PIN_SET);  // Light up an LED if link is up
    } else {
      HAL_GPIO_WritePin(GPIOB, LD1_Pin, GPIO_PIN_RESET); // Turn off LED if not up
    }

    // Required lines for responding to ping
    ethernetif_input(&gnetif);
    sys_check_timeouts();

  }
 
Top