RT1060 - use of OCRAM breaks fatfs example

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

RT1060 - use of OCRAM breaks fatfs example

跳至解决方案
1,421 次查看
tmeyer1
Contributor III

I'm working on a FreeRTOS project and plan to use all 1MB of the internal RAM on the RT1060. I've noticed that there is a change in the code behavior based off the location I store the global data.

For example, currently I'm working with the RT1060EVK board with a uSD card and FatFS. I import the example project: evkmimxrt1060_sdcard_fatfs_freertos and change only one setting, which breaks the example. Out of the box, it run as expected. After moving the global data into the OCRAM (from DTCM), the application no longer writes to the SD card.

pastedImage_1.png

Can anyone explain to me what I'm missing, and why changing this from SRAM_OC to SRAM_DTC fixes some issues in the SD initialization. 

FYI: the output from the example when it fails is as follows:

SDCARD fatfs freertos example.

Card inserted.

Make file system......The time may be long if the card capacity is big.
Make file system failed.

The example I am running is from SDK version 2.6.2.

Thanks,

Tim

标签 (2)
1 解答
1,162 次查看
Takashi_Kashiwagi
Senior Contributor I

Hi Tim-san

Did you change MPU setting?

In Default Setting, OCRAM area is set to not shareable by BOARD_ConfigMPU. 

So transfer using DMA does not work.

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

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

Best Regards,

T.Kashiwagi

在原帖中查看解决方案

0 项奖励
3 回复数
1,162 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi Tim,

This is because OCRAM default is cacheable. Since some SD control block in RAM is shared by SD peripheral and MCU, cache function cause data missing. When MCU write something to the block, it only write to cache actually. Peripheral can get it. When peripheral write something to the block, MCU also don't know. Because it only read from cache actually.

TCM is not cacheable. So, it hasn't this problem. For i.MXRT, shareable means non-cacheable by default. T.Kashiwagi's method can resolve the problem.

Regards,

Jing

1,162 次查看
tmeyer1
Contributor III

Perfect, thanks so much for pointing that out. It all makes sense to me know. 

Thanks,

Tim

0 项奖励
1,163 次查看
Takashi_Kashiwagi
Senior Contributor I

Hi Tim-san

Did you change MPU setting?

In Default Setting, OCRAM area is set to not shareable by BOARD_ConfigMPU. 

So transfer using DMA does not work.

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

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

Best Regards,

T.Kashiwagi

0 项奖励