cancel
Showing results for 
Search instead for 
Did you mean: 

Etablish an Ethernet connection with STM32F107

Romano1
Associate III

Hello I wan't to use the ethernet of my MCU (STM32F107VCT6) with using Lwip module. I'm using a dev board (EasyMx Pro V7). For the moment I've connect a etehernet cable between my computer and my ethernet board I've used some example of ethernet example for test the ethernet communication. But I don't arrive to ping my board after settings the differents parameters (GW address, Mask Address, IP Address). All my code has been generated with CubeMx.

I've also debug my program for try to understand why I can't ping my card and all seems to work fine netif is set up. I use wireshark to see the ethernets frame from my ethernet I see only ARP frame but not PING frame (ICMP).

Here is my main loop and it is the part that I modified :

while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
	  /* Read a received packet from the Ethernet buffers and send it
	         to the lwIP for handling */
	  ethernetif_input(&gnetif);
 
	  /* Handle timeouts */
	  sys_check_timeouts();
 
	  HAL_GPIO_TogglePin(LED_PA_10_GPIO_Port, LED_PA_10_Pin);
	  HAL_Delay(500);
  }
  /* USER CODE END 3 */
}

7 REPLIES 7
Romano1
Associate III

Here is the ethernet traffic between my computer and my dev board when I ping it :

0693W00000YAiLEQA1.pngand here the result of the ping command :

0693W00000YAiLiQAL.pngWe can see that the ping is in wireshark but I get any response from my dev board.

Is that half-second delay desirable in every loop?

Can't you toggle the GPIO/LED based on time elapsed rather than blocking on every iteration.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Romano1
Associate III

Yes I think it's possible to toggle the GPIO/LED based on time elapsed, I wanted at the beginning to blink led every seconds. Actualy I remove this code to test only ethernet part.

Pavel A.
Evangelist III

> We can see that the ping is in wireshark 

Where? All packets seen on your wireshark screenshot are ARPs from your computer. It does not get any response to these ARPs so it cannot even send ICMP packets (ping).

Yes I understand, so it's may be a configuration problem in CubeMX but I have tick some options in LWIP Configuration for icmp and arp like:

  • General settings :

0693W00000YAlSmQAL.png 

  • Key Options (IPv4 - ARP Options)

0693W00000YAlTQQA1.png 

  • Key Options (IPv4 - ICMP Options)

0693W00000YAlUJQA1.pngBut the computer need to get the IP and the MAC via ARP before to send a PING, is that right ?

If the ARP table of my computer doesn't have the IP and MAC address of my board I can't ping it. So I need to use etharp_request in my code ?

Romano1
Associate III

I also tried to ping my PC from my dev board using this library (https://github.com/particle-iot/lwip-contrib/tree/master/apps/ping) but ping doesn't work more in that way. It's like ethernet data are block.

Romano1
Associate III

I have add in my main loop the function : ethernetif_set_link(&gnetif);

And when I debugging I go to the else is (which say network cable is disconnected),

but there is a cable connected. So I think it's must be a problem of phy configuration.