STM32H743 Using Ethernet Without Cache Issue
GOAL
To use Ethernet + LwIP on the STM32H743 chip without cache.
Explanation
We don't want to use the cache when using Ethernet because when the cache is enabled and data is sent and received via DMA on the SPI line, the correct data doesn't propagate to the bus due to a cache miss. Disabling the cache resolves this issue, which is why we prefer not to use the cache when using Ethernet.
Cube Versions:
STMCubeIDE v1.18.1
STMCubeMX v6.14.1
STMCubeFW_H7 v1.12.0
We used the settings in the following link to configure the project by @Adam BERLINGER 's project: https://community.st.com/t5/stm32-mcus/how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308.
The CubeMX configurations are as follows:
CORTEX_M7 configurations


ETH configurations

LWIP configurations


Problems Encountered When Cache is Disabled
1. Usage Fault: The device enters a Usage Fault error when the program execution branches into the function SCB_InvalidateDCache_by_Addr() within the following call stack:
ethernetif_input() > low_level_input() > HAL_ETH_ReadData() > HAL_ETH_RXLinkCallback()
2. Bus Fault: A Bus Fault error occurs during a memory copy operation from the IP header address within the following call stack:
MX_LWIP_Init() > ethernet_input() > ip4_input() > ip_addr_copy_from_ip4()
Workaround
The issues are not observed when SCB_DisableDCache() is called immediately after HAL_Init(), even though the Data Cache is already disabled in the CubeMX configuration.
However, the problem persists under specific conditions:
-
Errors are still encountered when debugging is entered for the first time without the device's power being cycled.
-
The problem does not appear when the device's power is cut and debugging is entered immediately afterward.
-
The error is not observed when debugging is entered after the device has been powered on and off a few times.
(This behavior was tested by defining counters saved in EEPROM within the respective fault handling functions.)
I would be happy if you have an idea about this topic. Thanks in advance.
