Skip to main content
Visitor II
January 31, 2020
Solved

Calling SCB_DisableDCache()/SCB_EnableDCache oftenly

  • January 31, 2020
  • 5 replies
  • 1803 views

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

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    It should be unnecessary.

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

    5 replies

    Graduate II
    January 31, 2020

    It should be unnecessary.

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

    Visitor II
    January 31, 2020

    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 TranAuthor
    Visitor II
    February 1, 2020

     @ 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.

    Graduate II
    February 1, 2020

    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