cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7S3L8 Nucleo Ethernet+LwIP+FreeRTOS Issues

rbtmkr42
Associate II

I am having issues with Ethernet+LwIP+FreeRTOS on the NUCLEO-H7S3L8.  I was able to get Ethernet+LwIP to work on baremetal, but adding the RTOS and threading is having issues. I have attempted to follow the process here, but am still having issues.  I pulled the reference projects here, and attempted to merge the `ETH_CODE` code blocks over.  Still, the NUCLEO-H7S3L8 doesn't respond to my pings.  However, I am able to run the reference projects on a NUCLEO-H753 without an issue.  Note that I have disabled the MPU and Data cache for the time being.

My IOC and STM32CubeIDE project are attached.  Does anyone have similar issues with the latest CubeMX/CubeIDE?

1 ACCEPTED SOLUTION

Accepted Solutions
rbtmkr42
Associate II

FYI, ST Micro made aware of this project on Github, which does work, and I plan to use as a reference going forward:

https://github.com/STMicroelectronics/STM32CubeH7RS/tree/main

Thank you all!

View solution in original post

5 REPLIES 5
BGeor.1
Associate III

I haven't specifically worked with this NUCLEO board or this version of CubeMX. But I have got LwIP working on a NUCLEO-H743 with an older version of CubeMX recently.

After reviewing your ioc file, here are some comments.

Stack and heap size seems pretty low for the app. Try increasing it just to make sure a call to malloc() is not going to fail.

BGeor1_0-1759766108709.png

Make sure 32 KB assigned to TOTAL_HEAP_SIZE for FreeRTOS is sufficient for your application. You can enable the USE_MALLOC_FAILED_HOOK to capture any malloc failures.

Make sure there are no overlap between linker RAM regions and LwIP/FreeRTOS RAM regions.

Sometimes it is a good idea to come up with a unified memory map that tells you how RAM is allocated and used by CRT and other subsystems like LwIP, FreeRTOS etc.

Try setting a default gateway using GATEWAY_ADDRESS. I always do configure a default gateway.

I am not sure which linker file you are using. I see the following in STM32H7S3L8HX_default.ld.

__RAM_BEGIN = 0x24000000;
__RAM_SIZE = 0x71C00;

ethernetif.c has the following.

__attribute__((at(0x24060000))) ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
__attribute__((at(0x24060100))) ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */

Looks like the above address assignments is showing an overlap of allocated memory regions.

Thank you @BGeor.1 .  So, I went ahead and added the gateway, then also cleaned up the Linker script (using the one with suffix "_ROMxspi2.ld", which I have attached).  I didn't have the descriptors and memory pool setup on this project yet.  I know LWIP is using its separate heap at 0x24040000 which I also just double checked (see screenshot).  I enabled the `USE_MALLOC_FAILED_HOOK` flag for FreeRTOS.

Anyway, I got all that cleaned up, and still the same behavior. The tcpip_thread hangs when it first tries to `LOCK_TCPIP_CORE()`.  Is there some memory initialization I need to add for that mutex?

rbtmkr42_0-1759775455900.png

The memory allocations should match this screenshot from CubeMX:

rbtmkr42_1-1759775699743.png

 

tcpip_init() creates the mutex lock_tcpip_core. With the debugger, you can check whether this lock is getting created properly.

#if LWIP_TCPIP_CORE_LOCKING
if (sys_mutex_new(&lock_tcpip_core) != ERR_OK) {
LWIP_ASSERT("failed to create lock_tcpip_core", 0);
}
#endif /* LWIP_TCPIP_CORE_LOCKING */

Enable asserts in LwIP to see whether LwIP is generating any asserts. It could also give you some insight on how far LwIP is operational.

 

 

 

I usually keep USE_NEWLIB_REENTRANT disabled. I see that you have USE_NEWLIB_REENTRANT enabled in your project. May be you should try USE_NEWLIB_REENTRANT disabled.

rbtmkr42
Associate II

FYI, ST Micro made aware of this project on Github, which does work, and I plan to use as a reference going forward:

https://github.com/STMicroelectronics/STM32CubeH7RS/tree/main

Thank you all!