Skip to main content
Sebastian Gniazdowski
Associate III
March 24, 2018
Question

CubeMX what are expected steps for F767ZIT for FreeRTOS+LwIP+ETH ?

  • March 24, 2018
  • 1 reply
  • 1999 views
Posted on March 24, 2018 at 02:19

I enable Ethernet in RMII mode, tried PHY address 0 and 1, Ienable FreeRTOS, automatically configure clock, etc. I set breakpoints (SW4STM32) and program waits in lwip's 'accept' function, the one that waits for connection. So it looks like some problem with ETH configuration, as I should see the board under local IP, I point browser to port 80, etc. (I'm using simple http server code from here:

https://www.carminenoviello.com/2016/01/22/getting-started-stm32-nucleo-f746zg/

).

I just want few basic directions on this. Otherwise I doubt if I receive answer. I'm sure my actions are close to correct, I just need to catch some wrong action, probably on ETH hardware.

Best regards,

Sebastian

#freertos+tcp
This topic has been closed for replies.

1 reply

Joerg Wagner
Senior III
March 24, 2018
Posted on March 25, 2018 at 00:43

Use more heap space (the example uses 128 only, it's not enough).

I would recommend at least the size like you find in ST example code in file

~/STM32Cube/Repository/STM32Cube_FW_F7_V1.11.0/Projects/STM32F767ZI-Nucleo/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS/Src/main.c:

#if defined(__GNUC__)

  osThreadDef(Start, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 5);

#else

...

I would recommend 1024 at least when you want to do more in the thread.

Do not forget to verify the total heap space in FreeRTOS settings.

Sebastian Gniazdowski
Associate III
March 26, 2018
Posted on March 26, 2018 at 07:15

Thanks for pointers about heap size. It wasn't the direct cause, however, I managed to catch minimal changes needed to CubeMX generated project in order to make the board respond to ping and serve on port 80. It's GPIO initialization! Original CubeMX code:

void HAL_ETH_MspInit(ETH_HandleTypeDef* ethHandle)

{

  GPIO_InitTypeDef GPIO_InitStruct;

  if(ethHandle->Instance==ETH)

  {

  /* USER CODE BEGIN ETH_MspInit 0 */

  /* USER CODE END ETH_MspInit 0 */

    /* Enable Peripheral clock */

    __HAL_RCC_ETH_CLK_ENABLE();

 

    /**ETH GPIO Configuration    

    PC1     ------> ETH_MDC

    PA1     ------> ETH_REF_CLK

    PA2     ------> ETH_MDIO

    PA7     ------> ETH_CRS_DV

    PC4     ------> ETH_RXD0

    PC5     ------> ETH_RXD1

    PB11     ------> ETH_TX_EN

    PB12     ------> ETH_TXD0

    PB13     ------> ETH_TXD1

    */

    GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF11_ETH;

    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF11_ETH;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF11_ETH;

    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

    /* Peripheral interrupt init */

    HAL_NVIC_SetPriority(ETH_IRQn, 5, 0);

    HAL_NVIC_EnableIRQ(ETH_IRQn);

  /* USER CODE BEGIN ETH_MspInit 1 */

    __HAL_RCC_ETH_CLK_ENABLE();

    /* Output HSE clock (25MHz) on MCO pin (PA8) to clock the PHY */

    HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_PLLCLK, RCC_MCODIV_4);

  /* USER CODE END ETH_MspInit 1 */

  }

}

First change:

    GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13;

into:

    GPIO_InitStruct.Pin = GPIO_PIN_13;

Second change: add GPIOG configuration:

    /* Configure PG2, PG11, PG13 and PG14 */

    GPIO_InitStruct.Pin =  GPIO_PIN_2 | GPIO_PIN_11 | GPIO_PIN_13;

    HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

Then also add __HAL_RCC_GPIOG_CLK_ENABLE() into MX_GPIO_Init().

Could someone explain those changes? The comment on GPIO config in `Applications/...` example matches the one generated by CubeMX, but the code differs, as it is shown (above changes makes CubeMX code match the `Applications/...` one).

Joerg Wagner
Senior III
March 26, 2018
Posted on March 26, 2018 at 08:31

Are you using the latest CubeMX 4.25 with FW_F7_V1.11.0 ?