2025-11-20 5:29 AM
Hello to everyone,
I'm using a custom board based over STM32H743XIH6.
I'm developing a project that need to use TouchGFX, FreeRTOS and LWIP over ethernet.
My first goal it's to be able to PING the card while TouchGFX is running, but i'm having lot of problems (hardfoults)
If I enable only TouchGFX + FreeRTOS all run well
If I enable only LWIP + FreeRTOS I can PING the card
If I enable all (LWIP-FREERTOS-TouchGFX) I have lot of problems (HardFAULTS).
Someone could share a simple project that can use all of them?
I'm using a Custom board but i could try to a NUCLEO H743ZI KIT too.
Best Regards.
Roberto
Solved! Go to Solution.
2025-11-26 7:50 AM
Hello @STackPointer64 ,
If It could help, let me know if you need any files I missed to send you.
Anyway thnx for support
Best Regards
2025-11-28 2:13 AM
Hello @Roberto C,
The compilation errors were not due to missing files but rather linker configuration issues, which caused certain variables to be defined multiple times.
Best regards,
2025-12-02 6:49 AM - edited 2025-12-02 7:24 AM
Hello @Roberto C,
After thoroughly analyzing your project and debugging, I was able to isolate parts of it to test your issue. Here are my observations and recommendations:
The reason your application is not pingable is due to an overlap between the TouchGFX framebuffer and the Ethernet HEAP. In the ethernetif source file, the RX buffer count is set to 12, with each frame being 1536 bytes. This totals 18,432 bytes (approximately 18 KB). However, in your lwipopts.h file, the allocated heap size is only 16,360 bytes, which is insufficient. As a result, the compiler allocated the heap in AXISRAM at 0x2400xxxx. You resolved this by moving the framebuffer to 0x24040000.
To fix this properly, reduce the RX buffer count to 10 so the heap memory can remain at 0x30044000.
Additionally, the declaration for memp_memory_RX_POOL_base[] is missing in ethernetif.c. Although a section is declared, no variable is assigned, which may cause unpredictable behavior when integrating TouchGFX with LWIP.
#endif
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma location = 0x30040200
extern u8_t memp_memory_RX_POOL_base[];
#elif defined ( __CC_ARM ) /* MDK ARM Compiler */
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
#elif defined ( __GNUC__ ) /* GNU */
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
#endif
/* USER CODE BEGIN 2 */
I also noticed that neither the Ethernet memory regions nor TouchGFX memory regions are configured in the MPU. Configuring these is recommended to prevent caching issues with Ethernet buffers and descriptors.
Lastly, you created a 256 KB memory sub-region in AXISRAM starting at 0x24000000 for the framebuffer, but this is larger than necessary. Using the formula:
Width * Height * Pixel Size = 480 * 128 * 2 = 122,880 bytes ≈ 120 KB
Dividing 122,880 by 4 gives the equivalent word size. You can declare the framebuffer as a uint32_t array and place it in the created region.
Finally, I suggest you to increase the minimum size of stack and heap in the loader file to
2025-12-03 8:02 AM
2025-12-03 8:05 AM
You’re welcome, @Roberto C. Please make sure to check and get back to me with your feedback. I’ll be happy to help. Have a great day!
2025-12-05 1:57 AM
Hello,
i checked your suggestions, and, first tests was ok.
So I continued with development and added the ability to open a TCP port and exchange a small amount of data (for now, an echo of received data).
But something strange happens.
Sequence 1:
- program start
- I ping the address 2.1.1.1
- I open the port, send data, close the port.... and so on...
-> everything seems to be OK <--
Sequence 2:
- program start
- I open the port
Error !! I can't open the port and the program goes into assertion as shown in the attached figure.
The only difference from sequence 1 and 2 it's that in the Nr.2 I don't ping the card...
Any other suggestions?
Best ragards.
2025-12-09 1:32 AM
Hello,
Have you tried enabling LwIP debug logs and increasing the verbosity? This will help you identify exactly where the error occurs.
Best regards
2025-12-10 1:06 AM
Hello,
i'm still facing same strange troubles that making my project impossible to release
I enabled lwip logs as you suggests, redirecting prints over a serial com:
my lwipopts.h
/*-----------------------------------------------------------------------------*/
/* Current version of LwIP supported by CubeMx: 2.1.2 -*/
/*-----------------------------------------------------------------------------*/
/* Within 'USER CODE' section, code will be kept by default at each generation */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
#ifdef __cplusplus
extern "C" {
#endif
/* STM32CubeMX Specific Parameters (not defined in opt.h) ---------------------*/
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
/*----- WITH_RTOS enabled (Since FREERTOS is set) -----*/
#define WITH_RTOS 1
//#define LWIP_ARP 1 // eliminare
//#define LWIP_ICMP 1 // eliminare
/* Temporary workaround to avoid conflict on errno defined in STM32CubeIDE and lwip sys_arch.c errno */
#undef LWIP_PROVIDE_ERRNO
/*----- 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 16360
#define MEM_SIZE 12*1024 - SIZEOF_STRUCT_MEM
/*----- Default Value for H7 devices: 0x30044000 -----*/
#define LWIP_RAM_HEAP_POINTER 0x30044000
/*----- 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
/*----- 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 5
#define TCPIP_THREAD_PRIO 24
/*----- 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
/*-----------------------------------------------------------------------------*/
/* USER CODE BEGIN 1 */
#define MEMP_MEM_MALLOC 0
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON | LWIP_DBG_TRACE | LWIP_DBG_STATE)
#define LWIP_DEBUG 0
#define NETIF_DEBUG LWIP_DBG_ON
#define DHCP_DEBUG LWIP_DBG_ON
#define UDP_DEBUG LWIP_DBG_ON
#define MEMP_DEBUG LWIP_DBG_ON
#define MEM_DEBUG LWIP_DBG_ON
#define ICMP_DEBUG LWIP_DBG_ON
#define TCPIP_DEBUG LWIP_DBG_ON
#define TCP_DEBUG LWIP_DBG_ON
#define MEMP_OVERFLOW_CHECK 1
#define MEMP_SANITY_CHECK 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 1
#define MEM_OVERFLOW_CHECK 1
#define MEM_SANITY_CHECK 1
Following some screenshots capturated from logger terminal
Screenshot1:
Starting program and init lwip done (no any attempt to access to ip address)
Screenshot 2: Sending ping (with success !!)
Comment: as you can see there's some warning checking mempool, but i'm not able to understand how to avoid them..i tried to increase stacks, mem_buf etc.. but no any success
All seems to be ok, i can ping, connect, disconnect from port 502 (IP address 2.1.1.1)...but logs continue to show that warnings
Then I have restarted my program, returning to a condiction like in screenshot 1...
Then I tried to simply connect to port 502. Then my program stuck and go in assert (screenshot3)
Screenshot 3
In screenshots 4 and 5 you can see the variables related to line that cause the assert:
As you can see, the code fall in assert becouse the variable xqueue->uxItemSize = 0x2400d224.
That memory position is part of allocated memory in heap_4.o module (part of freertos)
Here part of .map file
0x0000000024001afc 0x4 ./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.o
.bss.ucHeap 0x0000000024001b00 0xbb80 ./Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.o
.bss.xStart 0x000000002400d680 0x8 ./Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.o
.bss.pxEnd 0x000000002400d688 0x4 ./Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.o
The strange is that if I ping 2.1.1.1 then I connect to port the program don't fall on assert... (but I still see warning as in screenshot 2..)
Instead, if I connect to port without ping before, I always fall on asserts.
Pls. help me...my project 's blocked couse of that's strange things !!
Thare are some knew configurations for a minimal lwip+freertos+touchfgx that run well?...(i need just to access to a port for now)
Best regards !!
2025-12-10 3:08 AM
A short upgrade:
warnings in screenshot 2 of previous message disappeared if I set in lwipopts.h:
//#define ETH_RX_BUFFER_SIZE 1536
#define ETH_RX_BUFFER_SIZE 1568But, I'm still having assert like explained in previous message (see screenshots 3...to 5)
Best regards.
2025-12-10 3:46 AM
Hello @Roberto C,
First of all, I see that you reduced the memory size in lwipopts to 12 KB. Have you adjusted the number of Rx buffers in ethernetif? It is crucial that the number of descriptors aligns with the space allocated, or your descriptors will be allocated in the AXISRAM. As for the assert issue, could you run both use cases, export the lwIP logs, and send them to me?
Best regards,