Skip to main content
Visitor II
July 10, 2020
Question

boot application - issue with SCB_DisableDCache

  • July 10, 2020
  • 12 replies
  • 5346 views

does anybody have a idea why the code is stuck at below do while loop (bold marked)?.

use case: for the boot application , SCB_DisableDCache () is getting called before jumping into use aplication.

__STATIC_INLINE void SCB_DisableDCache (void)

{

 #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)

  uint32_t ccsidr;

  uint32_t sets;

  uint32_t ways;

  SCB->CSSELR = 0U; /*(0U << 1U) | 0U;*/ /* Level 1 data cache */

  __DSB();

  SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */

  __DSB();

  ccsidr = SCB->CCSIDR;

                      /* clean & invalidate D-Cache */

  sets = (uint32_t)(CCSIDR_SETS(ccsidr));

  do {

   ways = (uint32_t)(CCSIDR_WAYS(ccsidr));

   do {

    SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) |

            ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) );

    #if defined ( __CC_ARM )

     __schedule_barrier();

    #endif

   } while (ways-- != 0U);

  } while(sets-- != 0U);

  __DSB();

  __ISB();

 #endif

}

    This topic has been closed for replies.

    12 replies

    Super User
    July 10, 2020

    Was DCache enabled before you call this?

    Are you trying to step thru this function in debugger?

    -- pa

    Anand RamAuthor
    Visitor II
    July 12, 2020

    hi , yes i have enabled DCache during init and disabled again in deinit process before jumping into application software.

    no, i just let it running and tried without debugger after flashing too, while debugging its observed code is breaking at i mentioned before.

    Graduate II
    July 10, 2020

    Haven't sorted out the exact reason behind it, but cache management functions tend to stuck if you try to debug them by stepping in or even stepping over with a single step. Just let them run normally and use breakpoints to stop at specific code.

    Anand RamAuthor
    Visitor II
    July 12, 2020

    hi Piranha, yes tried the same still issue persists.

    Anand RamAuthor
    Visitor II
    July 12, 2020

    additional info, i use the RAM location to fill the data using linker commands in c file after the necessary configurations in .id file.

    do i need to do any sort of memory configurations as below

     HAL_MPU_ConfigRegion(&MPU_InitStruct); ??

    Anand RamAuthor
    Visitor II
    July 15, 2020

    still this issue is not solved?please share your valuable inputs to find the root cause and fix

    Visitor II
    November 2, 2020

    Hi,

    Did you solve the problem?

    I have exactly the same behavior in this project:

    https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32F7508-DISCO/Templates/Template_Project

    It works fine on STM32F7508-DISCO board but stuck in SCB_DisableDCache (void) on my custom board.

    The difference is the microcontroller used. On STM32F7508-DISCO there is STM32F750N8 and on my board I have STM32F750V8.

    But I can't find any difference between those chips that could affect DCache invalidating.

    Anand RamAuthor
    Visitor II
    November 3, 2020

    hi,

    please include below part of code during deinit.

    SCB_DisableICache();

     SCB_DisableDCache();

     SCB_CleanDCache();

     SCB_InvalidateICache();

     SCB_InvalidateDCache();

    alternative workaround :

    if you have big size array or accessing variables, please use volatile keyword. which don't use cache memory.

    Reason for the problem: cache is not cleared properly during de-init procedure.

    hope this information helps you.

    -Anandh Ram

    Visitor II
    November 3, 2020

    Thanks so much. I'll check this out today and let you know if it worked.

    Visitor II
    November 3, 2020

    Hmm, I have no idea what's going on but today it works fine :\

    I didn't have to do any change, just powered up and works like a charm.

    Super strange.

    Visitor II
    November 24, 2020

    Just for the record, I know what was the reason of the super strange behavior.

    It was flux. The PCB wasn't super cleaned after soldering and it caused super strange behavior.

    The microcontroller was behaving really odd and not only the microcontroller.

    External USB phy also was behaving wacky and even DC/DC converter was giving some strange symptoms and sometimes it even stopped working.

    After a few sessions in ultrasonic cleaner everything started to work as expected.

    Super User
    November 24, 2020

    > It was flux.

    No, not likely. Seen this behavior on several ST eval boards.

    When running thru SCB_DisableDCache at full speed, debugger will not hang. Only when single stepping it hangs.

    So this is caused either by single-stepping thru an inline function or some specific handling of stuff related to the cache.

    Just do not single step thru these functions.

    -- pa