FreeRTOS+TCP + STM32H743 + DCache - doesn't work

Hello,
I created a TCP server on the base of the NUCLEO-H743ZI2 board and STM32_Nucleo_H723ZG_FreeRTOS_TCP project. It is worked well till I found necessity to enable Cache. I can’t connect to my board any more with SCB_EnableDCache(); command in the main.c.
I have googled and found few topics in which similar problems reported. So I have implemented all recommendations from the \FreeRTOS-Plus-TCP\source\portable\NetworkInterface\STM32Hxx\readme.md file, but this doesn’t help - I still can’t connect. In the putty window I see next output:

Calling FreeRTOS_IPInit…
FreeRTOS_AddEndPoint: MAC: 78-90 IPv4: 192.168.0.200
PHY ID 7C130
xPhyReset: phyBMCR_RESET 0 ready
+TCP: advertise: 01E1 config 3100
prvEthernetUpdateConfig: LS mask 00 Force 1
Autonego ready: 00000004: full duplex 100 mbit high status
Network buffers: 56 lowest 56
Queue space: lowest 69
Link Status is high
IP-address : 192.168.0.200
End-point : up = yes method static
Net mask : 255.255.255.0
GW : 192.168.0.1
DNS-0 : 192.168.0.255
Broadcast : 192.168.0.255
MAC address: 00-12-34-56-78-90

Creating TCP IPv4 socket…
Binding socket to local address…
Listening…
Waiting for connections…
RX descriptors 7/8
RX descriptors 5/8
Network buffers: 55 lowest 55
TX descriptors 1/14
Network buffers: 54 lowest 54
TX descriptors 2/14
Network buffers: 53 lowest 53
TX descriptors 3/14
Network buffers: 52 lowest 52
TX descriptors 4/14
RX descriptors 3/8
RX descriptors 2/8
Network buffers: 51 lowest 51
TX descriptors 5/14
Network buffers: 50 lowest 50
TX descriptors 6/14
Network buffers: 49 lowest 49
TX descriptors 7/14
Network buffers: 48 lowest 48
TX descriptors 8/14
Network buffers: 47 lowest 47
TX descriptors 9/14
Network buffers: 46 lowest 46
TX descriptors 10/14
Network buffers: 45 lowest 45
TX descriptors 11/14
Network buffers: 44 lowest 44
TX descriptors 12/14
Network buffers: 43 lowest 43
TX descriptors 13/14
Network buffers: 42 lowest 42
TX descriptors 14/14
Network buffers: 41 lowest 41
emacps_send_message: Time-out waiting for TX buffer
emacps_send_message: Time-out waiting for TX buffer
emacps_send_message: Time-out waiting for TX buffer
emacps_send_message: Time-out waiting for TX buffer

Compare with working server without DCache enabled the next string is missing :

prvAcceptWaitClient: client 240261e8 parent 240220a8

and error message appeared :

emacps_send_message: Time-out waiting for TX buffer

Can you please tell me what’s wrong with my server or Cache configuration?

This may be useful for you - https://community.st.com/t5/stm32-mcus/how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308?

@aggarg
Thank you! I saw this page already. But I do not understand how to use it in my project as this page is about LWIP library and I use TCP+ library.
I have bad experience with LWIP stability and speed, so for this project I decided to use TCP+.
And since I’m not an STM32H7xx expert, I ran into a lot of problems…

Which buffer allocation scheme are you using in the project? (BufferAllocation_1.c or BufferAllocation_2.c)
Also currently there are 2 network interfaces for STM32, if you are on older version of FreeRTOS+TCP then you might be using the legacy H7 network interface, is that the case?

@tony-josi-aws
I can’t answer about buffer allocation scheme. Unfortunately I did not find how to distinguish the used scheme in my project - I use STM32_Nucleo_H723ZG_FreeRTOS_TCP project as an initial one. Please give some advise how to find answer to your question.

As for the versions of NetworkInterface.c and related files used - all of them dated by 16/07/2024. So I used FreeRTOS-plus-TCP V4.2.2
And your references are to the FreeRTOS-plus-TCP V4.3.1
So I deleted the FreeRTOS-plus-TCP folder in my project (I use STM32CubeIDE) and inserted a new one. And now I have to find a way how to build my project - compiler complains that it couldn’t find stm32h7xx_hal_eth.h. It seems that folder structure has been changed.
There are two such files:
NetworkInterface\STM32\Drivers\H7\stm32h7xx_hal_eth.h 92174 bytes
NetworkInterface\STM32\Legacy\STM32Hxx\stm32h7xx_hal_eth.h 185 bytes
Which one I have to use?

The problem has to do with caching the data segments that are passed to the network buffers and DMA.

I (still) use the Legacy STM32Hxx version and have both caches enabled:

    /* Enable I-Cache */
    SCB_EnableICache();

    /* Make the AXI memory non-cacheable */
    MPU_Config();

    /* Enable D-Cache */
    SCB_EnableDCache();

See my main.c and surrounding project.
AXI memory is used for the network and the comment says it is made “non-cacheable”.

@htibosch
Thank you Hein!
But if I follow your link and open main.c I see:

	/* Enable I-Cache */
	SCB_EnableICache();

	/* Enable D-Cache */
	/* _HT_ This project has not been tested with data cache enabled.
	Changes will be necessary in the network driver to make it work. */
//	SCB_EnableDCache();

In your piece of code in the post most interesting for me now is this part:

    /* Make the AXI memory non-cacheable */
    MPU_Config();

Can you show the MPU settings in your project?
Thank you in advance!

Oops, I copy the snipped from my private project. I will update it. One second.

I uploaded my newer project STM32H747_cube_second.

That project has a main that enabled DCache. I hope this works for you.

@htibosch
Thank you! I copied content of your MPU_Config( void ) to my project - and now I can connect to my server even with DCache enabled.
Now I have to configure my project’s ioc file according to your settings.