cancel
Showing results for 
Search instead for 
Did you mean: 

Calling SCB_DisableDCache()/SCB_EnableDCache oftenly

Dat Tran
Senior II

Hi,

Is there any issue if in STM32H743ZI, ethernet driver I call:

….

SCB_CleanDCache();

SCB_DisableDCache();

   HAL_ETH_Transmit(&EthHandle, &TxConfig, ETH_DMA_TRANSMIT_TIMEOUT);

   SCB_EnableDCache();

...

so far, it works perfectly until now instead of only SCB_CleanDCache();

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions

It should be unnecessary.

Consider using the By Addr version so you just flush the buffer, not cripple the MCU entirely.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5

It should be unnecessary.

Consider using the By Addr version so you just flush the buffer, not cripple the MCU entirely.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
berendi
Principal

Or you can permanently disable caching just for the memory region where the dma buffers are located

https://community.st.com/s/question/0D70X000007Q6AwSAK/stm32f7-using-spi-slave-with-dma-to-set-a-flag-ie-no-interrupts (scroll down to the last answer)

Dat Tran
Senior II

 @ Piranha: I already did what you suggested, added "By_Addr" in the loop. The thing is I got ethernet working, but Ping is roughly, and 50% is timeout.

My solution is, before transmit I add SCB_DisableDCache();

After transmitted, we enable SCB_EnableDCache();

Everything work smooth and fast. Ping is 100% response and <1ms all the time, which is very good.

SCB_DisableDCache();

   HAL_ETH_Transmit(&EthHandle, &TxConfig, ETH_DMA_TRANSMIT_TIMEOUT);

   SCB_EnableDCache();

Not sure if that way is safe or not.

Piranha
Chief II

Disabling cache implies cleaning and invalidating all of it. The effect of that is described in my comment in that other topic.

With "by_Addr" functions the code runs faster and therefore other flaws are more likely to show off. As can be read in a link related to "lwIP driver Rx buffers released while still in use" flaw, unfortunately in ST's implementation for H7 the Rx part of code is so broken, that it can't work at all.

Read my post with a phrase "false premise" and look for Harrold's workaround here:

https://community.st.com/s/question/0D50X0000BozSc5SQE/ethernet-security-issues