sdcard example fails running from OCRAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sdcard example fails running from OCRAM

Jump to solution
2,427 Views
jackking
Senior Contributor I

I am trying to use fatfs and usdhc module while executing from OCRAM on IMXRT1052.

This can be tested using the sdk example "sdcard_fatfs_freertos" and switching the memory config to use SRAM_OC as "RAM" region instead of the default of SRAM_DTC.

This test will fail on f_mkfs unless caching for OCRAM is turned off using something like:

    SCB_DisableICache();
    SCB_DisableDCache();

Obviously, this isn't really a useful fix, as the performance without caching is horrible.

Looking at AN12042   it specifically states that usdhc uses ADMA which takes care of cache coherency, so I'm not sure why the example doesn't run without change from OCRAM.

What configuration should be made (besides disabling cache) to allow the example to execute correctly?

Labels (1)
0 Kudos
Reply
1 Solution
2,077 Views
jeremyzhou
NXP Employee
NXP Employee

Sorry for reply late.
Please follow the steps to fix the issue.
1. Partitioning a RAM block from OCRAM for non-cacheable buffers used by sdcard driver like the Fig1 shows.

pastedImage_1.png

Fig 1


2. Modify the BOARDConfigMPU() to set the new RAM block with non-cacheable attribute.

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


3. Add an extra link section to put the noncaheable variables into the memory you created.

noncache.png

Fig 2

TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
7 Replies
2,077 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jack King,

Thank you for your interest in NXP Semiconductor products and
for the opportunity to serve you.
Does the phenomenon happen when you doing testing with the MIXMRT1050 board? if yes, please share the complete compile-able demo which can replicate the phenomenon, as I'd like to do some testing by myself.
Looking forward to your reply.

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
2,077 Views
jackking
Senior Contributor I

You can try it with the SDK example.  I am using an Embedded Artists EVK. 

I have attached the project I use for the EA EVK, but it uses a different flash chip from the NXP EVK.

All  you need to do is choose the SDK example for "sdcard_fatfs_freertos" and then switch the memory regions so that SRAM_OC is used as the "RAM" alias.

SDK_Import_Wizard.jpg

switch_ram.jpg

0 Kudos
Reply
2,076 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jack King,

Thanks for your reply.
In AN12042, the 4.3.1 Use cacheable buffers section shows the way of use cacheable buffers in the OCRAM, please give a try by using cache functions in the fsl_cache.c.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
2,076 Views
jackking
Senior Contributor I

Were you able to run the example from OCRAM?

In AN12042 it states (for uSDHC) that cacheable buffers can be passed to the driver:

AN_Using_the_i_MXRT_L1_Cache_-_AN12042_pdf.jpg

The SDK example uses a generic byte buffer:

workspace_-_evkbimxrt1050_sdcard_fatfs_freertos_test_OCRAM_source_sdcard_fatfs_freertos_c_-_MCUXpresso_IDE.jpg

I also tried changing this buffer to be non-cacheable, without success:

workspace_-_evkbimxrt1050_sdcard_fatfs_freertos_2_source_sdcard_fatfs_freertos_c_-_MCUXpresso_IDE.jpg

0 Kudos
Reply
2,077 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jack King,

I've escalated the question and the AE team will also provide the tech support. However, we need your company information, please share with us.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
2,078 Views
jeremyzhou
NXP Employee
NXP Employee

Sorry for reply late.
Please follow the steps to fix the issue.
1. Partitioning a RAM block from OCRAM for non-cacheable buffers used by sdcard driver like the Fig1 shows.

pastedImage_1.png

Fig 1


2. Modify the BOARDConfigMPU() to set the new RAM block with non-cacheable attribute.

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


3. Add an extra link section to put the noncaheable variables into the memory you created.

noncache.png

Fig 2

TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
2,077 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jack King,

Thanks for your reply.

Yes, I had already replicated the phenomenon on my site, and I'm still working on it now.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply