MPU cache setting

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MPU cache setting

797件の閲覧回数
michaeldkfowler
Contributor IV

In reviewing the default MPU configuration in board.c, it appears caching is enabled for the ITC, DTC and NCACHE regions. Was this intentional or a bug?

 

MPU->RBAR = ARM_MPU_RBAR(0, 0x00000000U);
MPU->RASR = ARM_MPU_RASR(1, ARM_MPU_AP_NONE, 0, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_4GB);

/* Region 1 setting: Memory with Device type, not shareable, non-cacheable. */
MPU->RBAR = ARM_MPU_RBAR(1, 0x80000000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB);

/* Region 2 setting: Memory with Device type, not shareable, non-cacheable. */
MPU->RBAR = ARM_MPU_RBAR(2, 0x60000000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB);

#if defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)
/* Region 3 setting: Memory with Normal type, not shareable, outer/inner write back. */
MPU->RBAR = ARM_MPU_RBAR(3, 0x60000000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_RO, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_8MB);
#endif

/* Region 4 setting: Memory with Device type, not shareable, non-cacheable. */
MPU->RBAR = ARM_MPU_RBAR(4, 0x00000000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB);

/* Region 5 setting: Memory with Normal type, not shareable, outer/inner write back */
MPU->RBAR = ARM_MPU_RBAR(5, 0x00000000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);

/* Region 6 setting: Memory with Normal type, not shareable, outer/inner write back */
MPU->RBAR = ARM_MPU_RBAR(6, 0x20000000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);

/* Region 7 setting: Memory with Normal type, not shareable, outer/inner write back */
MPU->RBAR = ARM_MPU_RBAR(7, 0x20200000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_512KB);

/* Region 8 setting: Memory with Normal type, not shareable, outer/inner write back */
MPU->RBAR = ARM_MPU_RBAR(8, 0x20280000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB);

/* Region 9 setting: Memory with Normal type, not shareable, outer/inner write back */
MPU->RBAR = ARM_MPU_RBAR(9, 0x80000000U);
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_32MB);

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

738件の閲覧回数
diego_charles
NXP TechSupport
NXP TechSupport

Hi @michaeldkfowler 

This is the default MPU configuration for those memory areas in the SDK.  At least I saw the same  MPU settings for those areas, when creating a new project for the RT1060 EVK. There may be some special cases when one needs to customize the MPU setttings.

The NCACHE region is later on configured to have Cache disabled.  

 while ((size >> i) > 0x1U)
    {
        i++;
    }

    if (i != 0)
    {
        /* The MPU region size should be 2^N, 5<=N<=32, region base should be multiples of size. */
        assert(!(nonCacheStart % size));
        assert(size == (uint32_t)(1 << i));
        assert(i >= 5);

        /* Region 10 setting: Memory with Normal type, not shareable, non-cacheable */
        MPU->RBAR = ARM_MPU_RBAR(10, nonCacheStart);
        MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 1, 0, 0, 0, 0, i - 1);
    }

I like this application note Using the i.MXRT L1 Cache since it talks about MPU settings, NON cacheable areas, cache maintenance, cache prefetching etc. 

Let me know if this helps you!

Diego

0 件の賞賛
返信

712件の閲覧回数
michaeldkfowler
Contributor IV

Hi @diego_charles,

 Thank you for pointing out that region 10 supersedes region 8's setting. Why is it configured this way? Wouldn't it be easier to configure it correctly in region 8? 

Also, can you address my original question, of why is caching enabled on the ITC and DTC?

Thanks,

Michael

 

0 件の賞賛
返信

606件の閲覧回数
diego_charles
NXP TechSupport
NXP TechSupport

Hi @michaeldkfowler 

Many thanks for your patience. 

My current explanation is that even though the ITCM and DTCM are actually areas that physically cannot be cached, coherency is maintained for the MPU settings. Where a appplication's non-cacheable area is strictly configured in region 10, the for loop I mentioned previously.

This loop is conveniently implemented since non-cacheable area can have varied sizes and locations in the linker. This makes high level linker setup of non-cacheable area easier. See the below two pictures of two different projects. The loop will help you to setup a cacheable area of 2M or 512KB without having to modify code on BOARD_ConfigMPU()

diego_charles_0-1711157953127.png

I wish this could help!

Diego

0 件の賞賛
返信