cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4DIS-BB + ETH + CubeMX

jarno
Associate III
Posted on April 25, 2014 at 12:56

Created a project targeting STM32F4DISCOVERY + STM32F4DIS-BB from a scratch with CubeMX. Managed to blink LEDs and send bytes over UART but now struggling with Ethernet and LwIP. I have referenced STM32F4DIS-BB example and have added PHY reset into generated ETH GPIO function and both LEDs at ETH connector is set on, but when pinging from pc no input interrupts are triggered nor low_level_input() being called. Any ideas or experience is this HW or LwIP configuration problems. Attached is my *.ioc file. Thanks.

#stm32f4dis-bb #stm32f4-bb+cubemx
11 REPLIES 11
remi
Associate II
Posted on April 25, 2014 at 15:34

Hello 

there are two things to make Ethernet running on STM32F4DIS-BB

First, PHY address of  STM32F4DIS-BB is 0, Mx by default MX set an address 1

Second, declare PE2 as Output and before the call to HAL_ETH_Init, do 

// reset du PHY on the STM32F4DIS-BB  board

 HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET);

 HAL_Delay(50);

 HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET);

 HAL_Delay(50);

After that, the Ethernet interface is functionnal. 

After, the configuration of Lwip, is not completly done by MX. AT your charge,  => you do make a DHCP client, a real server ( not a demo echo as exemple source in the HAL) on TCP or UDP. 

Rémi

jarno
Associate III
Posted on April 25, 2014 at 20:00

Thanks Rèmi. Changing a PHY address to 0 helped. I was so stuck with the STM32F4DIS-BB example where PHY is registered with address 1 that never doubt that might be the reason. However, i think the reset pin should be set as output mode if one should reset the PHY by GPIO. Added PHY reset as follows into main.c:

  /* USER CODE BEGIN 2 */

    

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET);    

    for (i = 0; i < 100; i++);

    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET);    

    for (i = 0; i < 100; i++);

    

  /* USER CODE END 2 */

had to use for-loop as HAL_Delay() didn't work.

remi
Associate II
Posted on April 25, 2014 at 22:32

HAL_Delay works before the launch of FreeRTOS. In a thread, I use osDelay(50). ( 50 ms)

Also, the PHY on BB, has no interrupt pin to signal a lost link. So, there are a thread for the link state, that in BB is not necessary. 

If you want I can send you the code for DHCP, and my lwipots for have the full IP connectivity.

Actually I work with the native Lwip API. I am writting C++ class to make server and client UDP and TCP in 32K of memory.

Rémi

jarno
Associate III
Posted on April 26, 2014 at 12:51

Rèmi, sure would, thanks.

borrosjim
Associate
Posted on July 01, 2014 at 11:33

Hello Remi, 

I'm trying to make stm32f4discovery-BB expansion work through CubeMX as well so I could try some functions in it. 

I am doing a project with the same ethernet schematic as STM32F4-BB has so this will be very useful.

Whould you mind sending the STM32F4-BB configuration file and the code for DHCP?

Thanks in advance

Borja

New.Fish
Associate III
Posted on February 12, 2015 at 08:18

I generate one IAR project by Cube, it doesn't work.

The function __ETH_CLK_ENABLE() in ethernetif.c (Line 102) is nothing, I suspect this causing problem, how to fix it?

AvaTar
Lead
Posted on February 12, 2015 at 14:33

This thread is almost one year old, so I guess it's mere existence has dropped off that poster's minds.

And honestly, I'm not very impressed by Cube, nor would I recommend it for non-ST hardware.

There is a working ethernet example (amongst others) for STM32F4DIS-BB around at the

http://www.element14.com/community/docs/DOC-51670/l/stm32f4dis-bb-discover-more-software-examples

. It is for the StdPeriph-Library, but would much better serve as a starting point.

3FTI
Associate II
Posted on April 22, 2016 at 13:03

Man, glad I found this thread. The PHY address is what fixed it for me! If anyone is interested I can share my STM32CubeMX .IOC file  so you can generate your own project. Right now I just have it configured for standalone lwip operation (no FreeRTOS) but it successfully connects to the network with a static IP.

akosodry
Associate II
Posted on June 08, 2016 at 18:26

Hello3ftins!

I would be interested in your cubemx file. Can you please share it?

Here is my post about the things ive already done, however i could not manage to make the ethernet work on my stm32f407:

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Ethernet%20lwip%20on%20STM32F407%20board%20with%20HAL%20lib&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E...

Thank you in advance.

Best regards,

�?kos