2024-01-29 01:57 PM - edited 2024-01-29 02:14 PM
Hello Folks,
[Re-posting this question since I believe I had it in the from Board. I would delete the original one if I could.]
I use the H723ZG Nucleo board without FreeRTOS. I had configured Ethernet for the H723ZG in the past. But I am unable to configure it again now, even when following the same steps. When I first got it working, my configuration was based on this Youtube video STM32 ETHERNET #1. Hardware Configuration || PART 1.
In addition, I spent countless days trying to configure the Ethernet without FreeRTOS based on this post How to create project for STM32H7 with Ethernet and LwIP stack working from @Adam BERLINGER . I was able to get it working WITH FreeRTOS, but not WITHOUT it. And I am here to kindly ask for your help.
Here are some screenshots from my `.ioc` file.
I am testing it with the ping example.
/* USER CODE BEGIN 0 */
extern struct netif gnetif;
/* USER CODE END 0 */
[...]
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/** PING Example */
ethernetif_input(&gnetif);
sys_check_timeouts();
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
=== EDIT START
I noticed that in the MPU I was requestion 16 KBytes starting from 0x30000200 and I had the LWIP MEM_SIZE as 8 KBytes. I decided to change both, and I got a HardFault.
=== EDIT END
I would appreciate any feedback on this matter from anyone.
Many thanks,
Eduardo.
Solved! Go to Solution.
2024-02-16 02:45 PM - edited 2024-02-16 02:49 PM
This issue was solved with the solution for this other related question.
Also, MX_LWIP_Process() inside the while(1) can simply be used instead of all these other changes, since MX_LWIP_Process does exactly that.
@eduardo_reis wrote:I am testing it with the ping example.
/* USER CODE BEGIN 0 */
extern struct netif gnetif;
/* USER CODE END 0 */
[...]
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/** PING Example */
ethernetif_input(&gnetif);
sys_check_timeouts();
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
2024-02-13 07:20 AM
Hello @eduardo_reis ,
At first glance it seems like you are missing this call in the while(1);
Ethernet_Link_Periodic_Handle(&gnetif);
The MPU configuration should be as follows following the example found in the cube firmware :
static void MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_InitStruct;
/* Disable the MPU */
HAL_MPU_Disable();
/* Configure the MPU attributes as Device not cacheable
for ETH DMA descriptors */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x30000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_1KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/* Configure the MPU attributes as Normal Non Cacheable
for LwIP RAM heap which contains the Tx buffers */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x30004000;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER2;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
HAL_MPU_ConfigRegion(&MPU_InitStruct);
}
The GPIO configuration should be as follows :
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
/* Ethernett MSP init: RMII Mode */
/* Ethernet pins configuration */
/*
RMII_REF_CLK ----------------------> PA1
RMII_MDIO -------------------------> PA2
RMII_MDC --------------------------> PC1
RMII_MII_CRS_DV -------------------> PA7
RMII_MII_RXD0 ---------------------> PC4
RMII_MII_RXD1 ---------------------> PC5
RMII_MII_RXER ---------------------> PB10
RMII_MII_TX_EN --------------------> PB11
RMII_MII_TXD0 ---------------------> PB12
RMII_MII_TXD1 ---------------------> PB13
*/
/* Enable GPIOs clocks */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/* Configure PA1, PA2 , PA7 */
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.Pull = GPIO_NOPULL ;
GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure PB10, PB11, PB12 and PB13 */
GPIO_InitStructure.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Configure PC1, PC4 and PC5 */
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
/* Enable Ethernet clocks */
__HAL_RCC_ETH1MAC_CLK_ENABLE();
__HAL_RCC_ETH1TX_CLK_ENABLE();
__HAL_RCC_ETH1RX_CLK_ENABLE();
}
you can base your configuration on the STM32Cube_FW_H7_V1.11.1\Projects\STM32H735G-DK\Applications\LwIP\LwIP_TCP_Echo_Server example .
BR
2024-02-14 12:36 PM - edited 2024-02-14 12:36 PM
Hello @STea,
Thank you for your feedback. I am a bit resistant to pasting C code that will be overwritten when regenerating the .ioc file since my project is constantly evolving and changes made from time to time.
Also, the schematics I have for my board (below)
points to a different pin assignment than the ones you gave in
/* Ethernet pins configuration */
/*
RMII_REF_CLK ----------------------> PA1
RMII_MDIO -------------------------> PA2
RMII_MDC --------------------------> PC1
RMII_MII_CRS_DV -------------------> PA7
RMII_MII_RXD0 ---------------------> PC4
RMII_MII_RXD1 ---------------------> PC5
RMII_MII_RXER ---------------------> PB10
RMII_MII_TX_EN --------------------> PB11
RMII_MII_TXD0 ---------------------> PB12
RMII_MII_TXD1 ---------------------> PB13
*/
----
Thank you for the MPU configuration and point this
Ethernet_Link_Periodic_Handle(&gnetif);
I got ping to work, however it stops working after sequence 10.
eduardoj@ThunderBit:~$ ping 192.168.1.11
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_seq=1 ttl=255 time=0.749 ms
64 bytes from 192.168.1.11: icmp_seq=2 ttl=255 time=0.465 ms
64 bytes from 192.168.1.11: icmp_seq=3 ttl=255 time=0.503 ms
64 bytes from 192.168.1.11: icmp_seq=4 ttl=255 time=0.426 ms
64 bytes from 192.168.1.11: icmp_seq=5 ttl=255 time=0.180 ms
64 bytes from 192.168.1.11: icmp_seq=6 ttl=255 time=0.474 ms
64 bytes from 192.168.1.11: icmp_seq=7 ttl=255 time=0.416 ms
64 bytes from 192.168.1.11: icmp_seq=8 ttl=255 time=0.526 ms
64 bytes from 192.168.1.11: icmp_seq=9 ttl=255 time=0.478 ms
64 bytes from 192.168.1.11: icmp_seq=10 ttl=255 time=0.189 ms
From 192.168.1.10 icmp_seq=48 Destination Host Unreachable
From 192.168.1.10 icmp_seq=49 Destination Host Unreachable
From 192.168.1.10 icmp_seq=50 Destination Host Unreachable
From 192.168.1.10 icmp_seq=51 Destination Host Unreachable
From 192.168.1.10 icmp_seq=52 Destination Host Unreachable
From 192.168.1.10 icmp_seq=53 Destination Host Unreachable
2024-02-15 05:52 AM
Hello @eduardo_reis ,
i suggest that you close this thread and open another thread to address the ping getting out of reach after some sequences .
2024-02-16 09:05 AM
Hello @STea
How would I close it? I looked around and couldn't find that option.
2024-02-16 09:10 AM
Hello @eduardo_reis ,
by marking the comment that answered your request as accepted solution .
BR
2024-02-16 02:45 PM - edited 2024-02-16 02:49 PM
This issue was solved with the solution for this other related question.
Also, MX_LWIP_Process() inside the while(1) can simply be used instead of all these other changes, since MX_LWIP_Process does exactly that.
@eduardo_reis wrote:I am testing it with the ping example.
/* USER CODE BEGIN 0 */
extern struct netif gnetif;
/* USER CODE END 0 */
[...]
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/** PING Example */
ethernetif_input(&gnetif);
sys_check_timeouts();
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */