cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4-Discovery + STM32F4-DIS-BB - Cube lwIP port

znj0721
Associate
Posted on April 08, 2015 at 20:54

Hi, i'm trying to port hte STM32F4xG_EVAL example to STM32F4-Discovery along with STM32-DIS-BB. I have referenced the Embest's example for discovery and the 4xG example and i'm stuck.

I've copied the project:

C:...\STM32Cube_FW_F4_V1.5.0\Projects\STM324xG_EVAL\Applications\LwIP\LwIP_HTTP_Server_Socket_RTOS\Src

and made minor changes to main.c about the LEDs present on the board. Then I changed the ethernetif.c. Basically what i've done is changed the GPIO mapping, media control to RMII and the phy address to LAN8720 (i'm not sure what does this address in the EthInit structure mean). The lwIP reports netif link is up (via LED) and RTOS is scheduling it's task normally, but I cannot find it in my router's DHCP clients (nor access it for that matter). I've checked all the preprocessor defines, and they're ok. Router is also fine, the Embest's project works fine and i can access the webpage. Something's missing and for the past few days I have not figured out what. I'm new to ethernet and this driver library. Ethernetif is the only meaningful change i've made with regards to the provided 4xG example. If anyone can help, I would appreciate it very much. I have attached the ethernetif.c and here's a pastebin link also. http://pastebin.com/JenTubHQ Thank you. #dis-bb #cube #discovery #lwip
2 REPLIES 2
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 (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 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!

Hello Broekman,

at first thank you for your project. It is my first time to work with Ethernet and working with LwIP.

I am able to see my STM32F4Discovery + STM32F4DIS-BB in my settings of the router. ( MAC Adress and IP).

But now I would like to communicate with my PC over UDP. Have you an advice, for my first steps? What kind of socket should I take? I am a bit confused...