2018-03-23 06:19 PM
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+tcp2018-03-24 04:43 PM
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.
2018-03-26 12:15 AM
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).
2018-03-26 01:31 AM
Are you using the latest CubeMX 4.25 with FW_F7_V1.11.0 ?
2018-03-26 01:34 AM
Yes, I've installed this setup 3 days ago, and now checked in menu Help.
2018-03-26 01:55 AM
Basically it was an issue with PB12 and PB11 for STM32H743 in HAL 1.1.0 and less.
Are you sure you selected the board Nucleo-F767ZI for your project?
It tried to reproduce your problem, but CubeMX generates the right 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 PB13 ------> ETH_TXD1 PG11 ------> ETH_TX_EN PG13 ------> ETH_TXD0 */ GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin; 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 = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin;
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 = RMII_TXD1_Pin;
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(RMII_TXD1_GPIO_Port, &GPIO_InitStruct);GPIO_InitStruct.Pin = RMII_TX_EN_Pin|RMII_TXD0_Pin;
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(GPIOG, &GPIO_InitStruct);/* USER CODE BEGIN ETH_MspInit 1 */
/* USER CODE END ETH_MspInit 1 */
}}2018-03-26 02:10 AM
Yes, few lines from ioc file:
Mcu.Name=STM32F767ZITx
Mcu.Package=LQFP144PCC.MCU=STM32F767ZITx
PCC.PartNumber=STM32F767ZITxProjectManager.DeviceId=STM32F767ZITx
ProjectManager.FirmwarePackage=STM32Cube FW_F7 V1.11.0There's also the file STM32F767ZITx_FLASH.ld. I generate SW4STM32 project.
2018-03-26 03:41 AM
I've recalled something. Before selecting RMII mode for ETH, I've selected MII and generated code.
2018-03-26 01:19 PM
,
,
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.
I'm having a problem – step-over while debugging doesn't go onward through:
s = lwip_socket( AF_INET, , SOCK_RAW, IP_PROTO_ICMP ),
I was suspecting too low heap size (but is socket that large?), so I've increased heap size of task from 512 to 1024. Now debugger doesn't reach the main thread function. 768 still works, but 1024 doesn't, nor does 2048. In FreeRTOSConfig.h there is:
♯ define configMINIMAL_STACK_SIZE , , , , , , , , , , , , , , , , ((uint16_t)128)
,
♯ define configTOTAL_HEAP_SIZE , , , , , , , , , , , , , , , , , , , ((size_t)15360)I might need more heap also for other reasons, for processing, like you wrote. What can be wrong?
2018-03-26 02:56 PM
Increase configTOTAL_HEAP_SIZE up to i.e. 32768.
In CubeMX you can check the free space for just a quick overview:
>Configuration>FreeRTOS>FreeRTOS Heap Usage
But not every task is shown and included in the calculation.
To get an exact information of the left space, use a FreeRTOS function call while your app is running.
A good starting point to learn a little bit about the RTOS functions.