cancel
Showing results for 
Search instead for 
Did you mean: 

boot application - issue with SCB_DisableDCache

Anand Ram
Associate III

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

}

15 REPLIES 15
Pavel A.
Evangelist III

Was DCache enabled before you call this?

Are you trying to step thru this function in debugger?

-- pa

Piranha
Chief II

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.

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.

hi Piranha, yes tried the same still issue persists.

Anand Ram
Associate III

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 Ram
Associate III

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

upanie
Associate II

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 Ram
Associate III

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

upanie
Associate II

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