<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic iMX6 MMU and Cache Initialization Sequence in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/iMX6-MMU-and-Cache-Initialization-Sequence/m-p/1242251#M170544</link>
    <description>&lt;P&gt;I’m trying to determine the correct order in initializing the caches and mmu at power up for the iMX6 Quad. This is for a custom OS. This is what I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _int_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Disable the mmu if it is enabled (shouldn't be enabled on powerup)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Disable the icache, dcache and L2 cache&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _L1_dcache_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _L1_icache_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if(_l2c310_cache_sts())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _l2c310_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Invalidate dcache, and L2 cache – what about the icache???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _dcache_invalidate();&amp;nbsp;&amp;nbsp; // invalidates L1_dcache and L2 cache&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Allocate the memory for the mmu Section Table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; L1_TBL_ptr = _mem_alloc_align(MMU_L1_TBL_SIZE, MMU_L1_TBL_ALIGN);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Clear the mmu table&lt;/P&gt;&lt;P&gt;_mem_zero(L1_TBL_ptr, MMU_L1_TBL_SIZE);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Initialize the mmu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Map all of memory space to 1 MB sections, strongly ordered, RW, shared&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Remap sections that are actually used – DDR, SRAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Initialize the mmu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Map all of memory space to 1 MB sections, strongly ordered, RW, shared&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Remap sections that are actually used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Enable the mmu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Save the address of the mmu table in the TTBR0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Write the DACR register – 0x55555555&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Invalidate the TLB (including DSB and ISB following)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Enable the MMU&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_enable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DSB;&lt;/P&gt;&lt;P&gt;ISB;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Enable the caches&lt;/P&gt;&lt;P&gt;_l1_dcache_enable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_int_enable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this point there is a prefetch error, and I can’t get beyond here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somewhere up above the sequence of everything is messed up. The mmu is set up flat-mapped; va = pa&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Things I don’t know how to put into the sequence:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Invalidating and enabling the branch prediction cache&lt;/LI&gt;&lt;LI&gt;Enabling the dcache prefetch&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I’ve looked at the SDK, including the patch to add L2 cache to SDK, however this crashes as well as soon as the dcache is enabled.&lt;/P&gt;&lt;P&gt;Any ideas??&lt;/P&gt;</description>
    <pubDate>Tue, 09 Mar 2021 06:09:56 GMT</pubDate>
    <dc:creator>ogj</dc:creator>
    <dc:date>2021-03-09T06:09:56Z</dc:date>
    <item>
      <title>iMX6 MMU and Cache Initialization Sequence</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMX6-MMU-and-Cache-Initialization-Sequence/m-p/1242251#M170544</link>
      <description>&lt;P&gt;I’m trying to determine the correct order in initializing the caches and mmu at power up for the iMX6 Quad. This is for a custom OS. This is what I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _int_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Disable the mmu if it is enabled (shouldn't be enabled on powerup)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Disable the icache, dcache and L2 cache&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _L1_dcache_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _L1_icache_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if(_l2c310_cache_sts())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _l2c310_disable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Invalidate dcache, and L2 cache – what about the icache???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _dcache_invalidate();&amp;nbsp;&amp;nbsp; // invalidates L1_dcache and L2 cache&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Allocate the memory for the mmu Section Table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; L1_TBL_ptr = _mem_alloc_align(MMU_L1_TBL_SIZE, MMU_L1_TBL_ALIGN);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Clear the mmu table&lt;/P&gt;&lt;P&gt;_mem_zero(L1_TBL_ptr, MMU_L1_TBL_SIZE);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Initialize the mmu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Map all of memory space to 1 MB sections, strongly ordered, RW, shared&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Remap sections that are actually used – DDR, SRAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Initialize the mmu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Map all of memory space to 1 MB sections, strongly ordered, RW, shared&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Remap sections that are actually used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Enable the mmu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Save the address of the mmu table in the TTBR0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Write the DACR register – 0x55555555&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Invalidate the TLB (including DSB and ISB following)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp; - Enable the MMU&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _mmu_enable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DSB;&lt;/P&gt;&lt;P&gt;ISB;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Enable the caches&lt;/P&gt;&lt;P&gt;_l1_dcache_enable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_int_enable();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this point there is a prefetch error, and I can’t get beyond here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somewhere up above the sequence of everything is messed up. The mmu is set up flat-mapped; va = pa&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Things I don’t know how to put into the sequence:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Invalidating and enabling the branch prediction cache&lt;/LI&gt;&lt;LI&gt;Enabling the dcache prefetch&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I’ve looked at the SDK, including the patch to add L2 cache to SDK, however this crashes as well as soon as the dcache is enabled.&lt;/P&gt;&lt;P&gt;Any ideas??&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 06:09:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMX6-MMU-and-Cache-Initialization-Sequence/m-p/1242251#M170544</guid>
      <dc:creator>ogj</dc:creator>
      <dc:date>2021-03-09T06:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: iMX6 MMU and Cache Initialization Sequence</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMX6-MMU-and-Cache-Initialization-Sequence/m-p/1242310#M170555</link>
      <description>&lt;P&gt;Hi ogj&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;one can look at sdk codes (1.1.0_iMX6_Platform_SDK.zip)&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/i-MX-Processors/SMP-Enable-in-IMX6/m-p/542111" target="_blank"&gt;https://community.nxp.com/t5/i-MX-Processors/SMP-Enable-in-IMX6/m-p/542111&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Enabling-MMU-and-Caches-on-i-MX6-Series-Platform-SDK/ta-p/1108712" target="_blank"&gt;https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Enabling-MMU-and-Caches-on-i-MX6-Series-Platform-SDK/ta-p/1108712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 07:34:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMX6-MMU-and-Cache-Initialization-Sequence/m-p/1242310#M170555</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2021-03-09T07:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: iMX6 MMU and Cache Initialization Sequence</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMX6-MMU-and-Cache-Initialization-Sequence/m-p/1246849#M170952</link>
      <description>&lt;P&gt;I couldn't get the SDK version working, but I did get everything working by experimentation.&lt;/P&gt;&lt;P&gt;I do have another question about the SDK cache patch. In the patch there is the following PL310 setup:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt;* Function: _l2c310_cache_setup&lt;BR /&gt;* Comments:&lt;BR /&gt;* This function sets up reg1_tag_ram_control &amp;amp; reg1_data_ram_control&lt;BR /&gt;* and enables double line fill in the L2 cache controller&lt;BR /&gt;*******************************************************************************/&lt;/P&gt;&lt;P&gt;void _l2c310_cache_setup(void)&lt;BR /&gt;{&lt;BR /&gt;CA5L2C_reg1_tag_ram_control = 0x00000132u;&amp;nbsp; &amp;nbsp; //offset 0x108&lt;BR /&gt;CA5L2C_reg1_data_ram_control = 0x00000132u;&amp;nbsp; &amp;nbsp;//offset 0x10C&lt;BR /&gt;CA5L2C_reg15_prefetch_ctrl = 0x40800000u;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//offset 0xF60&lt;BR /&gt;&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Going through the PL310 Cache Controller TRM (Rev r0p0), none of these registers exist. Were they added by NXP? Is there any documentation on them? Everything works fine without calling that function.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 04:52:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMX6-MMU-and-Cache-Initialization-Sequence/m-p/1246849#M170952</guid>
      <dc:creator>ogj</dc:creator>
      <dc:date>2021-03-17T04:52:05Z</dc:date>
    </item>
  </channel>
</rss>

