2025-06-23 8:07 PM - last edited on 2025-06-24 1:11 AM by mƎALLEm
hello,everyone,I used STM32CUBEMX+freertos+lwip to generate a project. Pinging 100 bytes was normal. Setting it to 1000 bytes would cause the program to freeze without any lwip error. The LWIP configuration file uses the default parameters. Has anyone encountered this problem before? Can you provide me with a solution?
STM32CUBEM V6.14
STM32 firmware package V1.12.1
LWIP V2.1.2
/*----- WITH_RTOS enabled (Since FREERTOS is set) -----*/
#define WITH_RTOS 1
/*----- CHECKSUM_BY_HARDWARE enabled -----*/
#define CHECKSUM_BY_HARDWARE 1
/*-----------------------------------------------------------------------------*/
/* LwIP Stack Parameters (modified compared to initialization value in opt.h) -*/
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
/*----- Default value in ETH configuration GUI in CubeMx: 1524 -----*/
#define ETH_RX_BUFFER_SIZE 1536
/*----- Value in opt.h for MEM_ALIGNMENT: 1 -----*/
#define MEM_ALIGNMENT 4
/*----- Default Value for MEM_SIZE: 1600 ---*/
#define MEM_SIZE 14336
/*----- Default Value for H7 devices: 0x30004000 -----*/
#define LWIP_RAM_HEAP_POINTER 0x30004000
/*----- Value supported for H7 devices: 1 -----*/
#define LWIP_SUPPORT_CUSTOM_PBUF 1
/*----- Value in opt.h for LWIP_ETHERNET: LWIP_ARP || PPPOE_SUPPORT -*/
#define LWIP_ETHERNET 1
/*----- Value in opt.h for LWIP_DNS_SECURE: (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -*/
#define LWIP_DNS_SECURE 7
/*----- Value in opt.h for TCP_SND_QUEUELEN: (4*TCP_SND_BUF + (TCP_MSS - 1))/TCP_MSS -----*/
//#define TCP_SND_QUEUELEN 9
/*----- Value in opt.h for TCP_SNDLOWAT: LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) -*/
#define TCP_SNDLOWAT 1071
/*----- Value in opt.h for TCP_SNDQUEUELOWAT: LWIP_MAX(TCP_SND_QUEUELEN)/2, 5) -*/
#define TCP_SNDQUEUELOWAT 5
/*----- Value in opt.h for TCP_WND_UPDATE_THRESHOLD: LWIP_MIN(TCP_WND/4, TCP_MSS*4) -----*/
#define TCP_WND_UPDATE_THRESHOLD 536
/*----- Default Value for LWIP_NETIF_STATUS_CALLBACK: 0 ---*/
#define LWIP_NETIF_STATUS_CALLBACK 1
/*----- Value in opt.h for LWIP_NETIF_LINK_CALLBACK: 0 -----*/
#define LWIP_NETIF_LINK_CALLBACK 1
/*----- Value in opt.h for TCPIP_THREAD_STACKSIZE: 0 -----*/
#define TCPIP_THREAD_STACKSIZE 1024
/*----- Value in opt.h for TCPIP_THREAD_PRIO: 1 -----*/
#define TCPIP_THREAD_PRIO osPriorityNormal
/*----- Value in opt.h for TCPIP_MBOX_SIZE: 0 -----*/
#define TCPIP_MBOX_SIZE 6
/*----- Value in opt.h for SLIPIF_THREAD_STACKSIZE: 0 -----*/
#define SLIPIF_THREAD_STACKSIZE 1024
/*----- Value in opt.h for SLIPIF_THREAD_PRIO: 1 -----*/
#define SLIPIF_THREAD_PRIO 3
/*----- Value in opt.h for DEFAULT_THREAD_STACKSIZE: 0 -----*/
#define DEFAULT_THREAD_STACKSIZE 1024
/*----- Value in opt.h for DEFAULT_THREAD_PRIO: 1 -----*/
#define DEFAULT_THREAD_PRIO 3
/*----- Value in opt.h for DEFAULT_UDP_RECVMBOX_SIZE: 0 -----*/
#define DEFAULT_UDP_RECVMBOX_SIZE 6
/*----- Value in opt.h for DEFAULT_TCP_RECVMBOX_SIZE: 0 -----*/
#define DEFAULT_TCP_RECVMBOX_SIZE 6
/*----- Value in opt.h for DEFAULT_ACCEPTMBOX_SIZE: 0 -----*/
#define DEFAULT_ACCEPTMBOX_SIZE 6
/*----- Value in opt.h for RECV_BUFSIZE_DEFAULT: INT_MAX -----*/
#define RECV_BUFSIZE_DEFAULT 2000000000
/*----- Value in opt.h for LWIP_STATS: 1 -----*/
#define LWIP_STATS 0
/*----- Value in opt.h for CHECKSUM_GEN_IP: 1 -----*/
#define CHECKSUM_GEN_IP 0
/*----- Value in opt.h for CHECKSUM_GEN_UDP: 1 -----*/
#define CHECKSUM_GEN_UDP 0
/*----- Value in opt.h for CHECKSUM_GEN_TCP: 1 -----*/
#define CHECKSUM_GEN_TCP 0
/*----- Value in opt.h for CHECKSUM_GEN_ICMP6: 1 -----*/
#define CHECKSUM_GEN_ICMP6 0
/*----- Value in opt.h for CHECKSUM_CHECK_IP: 1 -----*/
#define CHECKSUM_CHECK_IP 0
/*----- Value in opt.h for CHECKSUM_CHECK_UDP: 1 -----*/
#define CHECKSUM_CHECK_UDP 0
/*----- Value in opt.h for CHECKSUM_CHECK_TCP: 1 -----*/
#define CHECKSUM_CHECK_TCP 0
/*----- Value in opt.h for CHECKSUM_CHECK_ICMP6: 1 -----*/
#define CHECKSUM_CHECK_ICMP6 0
/*-----------------------------------------------------------------------------*/
Solved! Go to Solution.
2025-06-24 1:14 AM
Hello @lan1
Please refer to the article below:
How to create a project for STM32H7 with Ethernet ... - STMicroelectronics Community
2025-06-24 1:14 AM
Hello @lan1
Please refer to the article below:
How to create a project for STM32H7 with Ethernet ... - STMicroelectronics Community
2025-06-24 3:05 AM
Hello @Saket_Om
I'm glad for your answer,and I used the latest software to configure according to the information you provided, but the following problems still occurred:
1. When the LAN8720A network communication is mounted on the STM32H723, it can be realized. When the data is less than 100 bytes, the function can be realized smoothly, but when the sent bytes are increased, the problem still exists.
2. I tried to modify the parameters in the link file and changed 0x30000200 to 0x30002FFF. The amount of data sent in the actual test can be increased a little, but when using the MTU maximum byte to ping the network, the request timeout will still occur.
3. Because the latest version of STM32CUBEMX and the latest firmware package (V1.12.1) are used, whether there are some problems due to the new version is still unknown.
Looking forward to your reply, thank you,can anyone help me to figure it out? I will be thankful.
2025-06-24 8:52 AM - edited 2025-06-24 8:54 AM
@lan1 wrote:
Hello @Saket_Om
3. Because the latest version of STM32CUBEMX and the latest firmware package (V1.12.1) are used, whether there are some problems due to the new version is still unknown.
You mean the issue appears when using these versions ?
2025-06-24 7:21 PM
I'm not sure, but I used the link you gave me: https://github.com/stm32-hotspot/STM32H7-LwIP-Examples and checked the lwip example project of the STM32H723 chip. The example project code in the link you gave me is inconsistent with the example project code in the STM32Cube_FW_H7_V1.12.0 I downloaded. I used the code in your link to test and found that lwip could not run normally. I'm not sure which one I should believe is the latest demo project.
2025-06-24 11:55 PM
Use Wireshark to check what's really going on.
Check your Windows settings, MTU might be too low.
From my notes:
This might be limited by Windows settings and can only be changed via the registry, by changing the MTU (maximum transfer unit) to 1500 Bytes (0x5DC), see method 3 in:
--> his can be checked via Wireshark showing the packet / data size
Get to know some LWIP settings, look for its MTU setting in some *opt.h file.
2025-06-25 3:17 AM
I have a new discovery,According to the instructions in the data sheet, I set the storage address of Rx_PoolSection to the RAM address, which occupies a total of about 18~19KB. In this case, the maximum MTU of ping is 1472 bytes, and a timeout occurs once in a million packets of data. The situation is still good, but it stands to reason that there are enough addresses in the RAM_D2 memory segment to store Rx_PoolSection. However, as long as Rx_PoolSection is placed in the RAM_D2 segment memory, there will be problems with ping.
1、Able to ping the network at 1472 bytes
.lwip_rx_pollsection(NOLOAD):
{
. = ABSOLUTE(0x24000000);
. = ALIGN(32);
*(.Rx_PoolSection)
}>RAM AT>FLASH
.lwip_sec (NOLOAD) :
{
. = ABSOLUTE(0x30000000);
. = ALIGN(32);
*(.RxDecripSection)
. = ABSOLUTE(0x30000080);
. = ALIGN(32);
*(.TxDecripSection)
/* . = ABSOLUTE(0x30000100);*/
/* . = ALIGN(32);*/
/* *(.Rx_PoolSection)*/
} >RAM_D2 AT>FLASH
2025-06-25 3:49 AM
> but it stands to reason that there are enough addresses in the RAM_D2 memory segment to store Rx_PoolSection.
You mean memory, not addresses. Anyway, this is something can be calculated and checked...
D2 SRAM (called "SRAM1" and "SRAM2" in the RM) must be used for the RX / TX descriptors.
But you can use any remaining space for RX / TX buffers.
I put all LWIP heap and pool memory into D1 AXI SRAM, works like a charm.
2025-06-25 5:26 AM
@LCE Bro, You are correct.
The RAM_D2 memory in the chip STM32H723ZGT6 I use is 32KB in total (32KB memory starting from address 0x30000000). I use the first 256B to define the RX/TX descriptor of ETH, and I have calculated that the given memory is sufficient. Please see my link script definition, so I can use the remaining space of RAM_D2 for RX/TX buffer. In fact, I also defined it in the link script like this, but in fact, if it is used in this way, it will cause the program to freeze when pinging the network with 1472 bytes, and it will definitely happen. Based on the above, I modified the RX/TX buffer to RAM (128KB memory starting from address 0x24000000), and this way I can run the 1472-byte long-term ping program.
.lwip_rx_pollsection(NOLOAD):
{
. = ABSOLUTE(0x24000000);
. = ALIGN(32);
*(.Rx_PoolSection)
}>RAM AT>FLASH
.lwip_sec (NOLOAD) :
{
. = ABSOLUTE(0x30000000);
*(.RxDecripSection)
. = ABSOLUTE(0x30000080);
*(.TxDecripSection)
} >RAM_D2 AT>FLASH
Because I modified the RX/TX buffer to RAM, do I not need to open the CACHE?
And I determined that the RX/TX buffer occupies about 19KB of space, so does the space defined in my MPU function need to be larger than 19KB? I'm suddenly not sure why the demo needs to set the 16KB after the starting address 0x30004000.
/* Disables the MPU */
HAL_MPU_Disable();
/** Initializes and configures the Region and the memory to be protected
*/
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.BaseAddress = 0x30000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/** Initializes and configures the Region and the memory to be protected
*/
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.BaseAddress = 0x30004000;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
MPU_InitStruct.SubRegionDisable = 0x0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/* Enables the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
Bro,I'm not sure where the setting went wrong. Can you provide your configuration for reference?
2025-06-25 5:56 AM
No idea about cache, never used it.