<?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>i.MX RT Crossover MCUsのトピックRe: RT685 B0 MPU - Memory Alignment</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT685-B0-MPU-Memory-Alignment/m-p/983299#M5373</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The limit address is inclusive so you need to decrement the value you are entering for ARM_MPU_LRAR&lt;/P&gt;&lt;P&gt;The value you enter will have 0x1F postfixed and all addresses up to and including that postfixed value will be part of the region.&lt;/P&gt;&lt;P&gt;See the register description in the Arm Cortex-M33 Devices Generic User Guide:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developer.arm.com/docs/100235/0004/the-cortexm33-peripherals/security-attribution-and-memory-protection/mpu-region-limit-address-register" title="https://developer.arm.com/docs/100235/0004/the-cortexm33-peripherals/security-attribution-and-memory-protection/mpu-region-limit-address-register"&gt;https://developer.arm.com/docs/100235/0004/the-cortexm33-peripherals/security-attribution-and-memory-protection/mpu-regi…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Feb 2020 21:04:42 GMT</pubDate>
    <dc:creator>nxf58843</dc:creator>
    <dc:date>2020-02-28T21:04:42Z</dc:date>
    <item>
      <title>RT685 B0 MPU - Memory Alignment</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT685-B0-MPU-Memory-Alignment/m-p/983297#M5371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use the MPU to detect stack overflow.&amp;nbsp; The basic idea is to create two SRAM entries in the MPU: (1) from start of SRAM to base of stack minus N bytes and (2) from base of stack to the end of SRAM.&amp;nbsp; I would over allocate the stack so that the N bytes below the base of the stack would be unused normally and I can safely leave this as a hole in the memory map when programming the MPU.&amp;nbsp; If any write into this area occurs the I expect to see a mem fault. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the CM33 MPU_RBAR register, it looks like the lower 5 bits of the memory addresses are "don't cares" (they are masked out and are used as control bits.)&amp;nbsp; This implies the MPU is able to control access to memory in increments of 32-bytes.&amp;nbsp; In order to satisfy this requirement, I have ensured (a) the base of my stack is 32-byte aligned and (b) the N byte hole in the memory map is 32 bytes. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doesn't seem to work for me.&amp;nbsp; If I loop through the 32-byte region (the N bytes below the base of the stack) and write each byte one by one, I am able to write the entire 32-byte region without tripping a mem fault.&amp;nbsp; I tried to increase the alignment to 64-bytes (stack base is 64-byte aligned, N byte hole is set to 64 bytes) and I see a difference in behavior.&amp;nbsp; If I started at the base of the stack and wrote byte by byte towards low memory, I get a mem fault as soon as I write the first byte below the stack base.&amp;nbsp; If I started at the low memory (i.e. first byte of the 64 byte memory hole) and worked my way up in the same fashion, I do not get a mem fault until I am exactly 32 bytes into the N byte region (and write to a 32-byte aligned address.)&amp;nbsp; What might be happening here?&amp;nbsp; I should be running without the cache at this point (CACHE64-&amp;gt;CCR is zero). &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MPU set up in C main():&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CRITICAL_ENTER();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __DMB();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_Disable();&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetMemAttr(0, ARM_MPU_ATTR(ARM_MPU_ATTR_MEMORY_(1, 0, 1, 0), ARM_MPU_ATTR_MEMORY_(1, 0, 1, 0) ) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetMemAttr(1, ARM_MPU_ATTR(ARM_MPU_ATTR_MEMORY_(1, 0, 1, 0), ARM_MPU_ATTR_MEMORY_(1, 0, 1, 0) ) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetMemAttr(2,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_ATTR(ARM_MPU_ATTR_DEVICE_nGnRnE, ARM_MPU_ATTR_DEVICE_nGnRnE ) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetMemAttr(3,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_ATTR(ARM_MPU_ATTR_DEVICE_nGnRnE, ARM_MPU_ATTR_DEVICE_nGnRnE ) );&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetRegion(MPU_REGION_INDEX_SRAM,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_RBAR(0x00000000, ARM_MPU_SH_INNER, 0, 1, 0), ARM_MPU_RLAR(0x00001000, 0) );&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetRegion(MPU_REGION_INDEX_FLASH_MEMORY, ARM_MPU_RBAR(0x08000000, ARM_MPU_SH_NON,&amp;nbsp;&amp;nbsp; 1, 1, 0), ARM_MPU_RLAR(0x08200000, 1) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetRegion(MPU_REGION_INDEX_PERIPHERAL,&amp;nbsp;&amp;nbsp; ARM_MPU_RBAR(0x40000000, ARM_MPU_SH_OUTER, 0, 1, 1), ARM_MPU_RLAR(0x60000000, 2) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetRegion(MPU_REGION_INDEX_PERIPHERAL2,&amp;nbsp; ARM_MPU_RBAR(0xE0000000, ARM_MPU_SH_OUTER, 0, 1, 1), ARM_MPU_RLAR(0xE0100000, 3) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_SetRegion(MPU_REGION_INDEX_SRAM2,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_RBAR(0x00001040, ARM_MPU_SH_OUTER, 0, 1, 0), ARM_MPU_RLAR(0x00480000, 0) );&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARM_MPU_Enable(0);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __DSB();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __ISB();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CRITICAL_LEAVE();&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;This code should leave a 64 byte region undefined between 0x00001000 (exclusive) and 0x00001040 (inclusive).&amp;nbsp; As explained above, writing one byte at a time from 0x00001040 to 0x00001000 causes a mem fault at address 0x0000103F.&amp;nbsp; However, when going from 0x00001000 to 0x00001040, I do not get a mem fault until I write to address 0x00001020. &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Trying this more broadly on the stacks of multiple tasks, I am unable to consistently trigger a mem fault unless I corrupt 64 bytes below the base of the stack. &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2020 22:12:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT685-B0-MPU-Memory-Alignment/m-p/983297#M5371</guid>
      <dc:creator>rayip</dc:creator>
      <dc:date>2020-02-18T22:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: RT685 B0 MPU - Memory Alignment</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT685-B0-MPU-Memory-Alignment/m-p/983298#M5372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Raymond,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you may know, this device has just been launched so there is limited information available. I am going to escalate this question with our internal applications team and let you know their feedback as soon as possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2020 22:10:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT685-B0-MPU-Memory-Alignment/m-p/983298#M5372</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2020-02-20T22:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: RT685 B0 MPU - Memory Alignment</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT685-B0-MPU-Memory-Alignment/m-p/983299#M5373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The limit address is inclusive so you need to decrement the value you are entering for ARM_MPU_LRAR&lt;/P&gt;&lt;P&gt;The value you enter will have 0x1F postfixed and all addresses up to and including that postfixed value will be part of the region.&lt;/P&gt;&lt;P&gt;See the register description in the Arm Cortex-M33 Devices Generic User Guide:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developer.arm.com/docs/100235/0004/the-cortexm33-peripherals/security-attribution-and-memory-protection/mpu-region-limit-address-register" title="https://developer.arm.com/docs/100235/0004/the-cortexm33-peripherals/security-attribution-and-memory-protection/mpu-region-limit-address-register"&gt;https://developer.arm.com/docs/100235/0004/the-cortexm33-peripherals/security-attribution-and-memory-protection/mpu-regi…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2020 21:04:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT685-B0-MPU-Memory-Alignment/m-p/983299#M5373</guid>
      <dc:creator>nxf58843</dc:creator>
      <dc:date>2020-02-28T21:04:42Z</dc:date>
    </item>
  </channel>
</rss>

