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

    Visitor II
    November 24, 2020

    In my case flux was guilty for sure. Believe me, I spent loooong days chasing weird problems. Cache issue was only one of many other.

    Cleaning board fixed all issues and not only on that one board.

    It's Weller flux. It has pretty low resistance and it's not "stable" it depends on temperature and time (probably the time of current flowing through it)! I know it may sound weird but it's true. Right after soldering, when the PCB and flux are warm everything works fine. After it cools down stupid crazy things start to happen.

    Graduate II
    February 3, 2022

    Hi all,

    have the same issue here: ccsidr, sets and ways are local variables of SCB_DisableDCache() that are stored on the stack. ccsidr is only read once before executing the two nested loops. However, the value changes during runtime - which may be due to some stack issue?

    0693W00000JOPyoQAH.pngEdit #1: This may be related to GCC optimization levels!

    See also: https://github.com/ARM-software/CMSIS_5/issues/620

    Edit #2: Same problem has been described here: https://community.st.com/s/feed/0D53W00000oVveoSAC - also got the same reference from Edit #1