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
kandinsky
Associate
Posted on August 11, 2016 at 16:08

Hello

Could you please share your results? Software examples are out-dated (uses old SPL) and I with my colleagues use new HAL

Longin

Broekman
Associate II

Posted my working STM32F4Discovery + STM32F4DIS-BB (lwIP v2.0.3) CubeMX (HAL) Atollic TrueStudio project on:

https://github.com/Broekman/STM32F4Discovery_DIS_BB_CubeMX

For all purposes sake, the things required to make it work (already included in the project above):

In CubeMX:

  1. Disable auto negotiation and set to 100MBits/s - full duplex (auto negotiation doesn't work for some reason).
  2. Set the PHY Address to 0 (instead of 1).
  3. Set the PHY Reset delay a bit higher (otherwise the PHY won't start): 0x000008FF
  4. Set the PHY Read Timeout to: 0x0004FFFF
  5. Set the PHY Write Timeout to: 0x0004FFFF
  6. Set the PHY special control/status register offset to: 0x31
  7. Set pin PE2 to GPIO_Output (ETH_RST_PIN) - (we configure this in the code, see below).

In the code:

  1. Src/ethernetif.c - in function: void HAL_ETH_MspInit(ETH_HandleTypeDef* ethHandle) - within the USER CODE section (bottom of the function), add the following code snippet:
//PHY reset for the STM32F4DIS-BB board.
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
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); 

And of course not to forget in the main loop: MX_LWIP_Process();

Hope this helps, good luck!