SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Cortex-M1 address translation when accessing PS DDR memory
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Cortex-M1 address translation when accessing PS DDR memory

Javier Massey
Last updated: September 20, 2023 2:53 am
Javier Massey 6 Min Read
Share
SHARE

The Cortex-M1 processor implements a Memory Protection Unit (MPU) to provide memory access control and address translation capabilities. When accessing DDR memory connected to the Processor Subsystem (PS), the Cortex-M1 MPU performs address translation to map virtual addresses used by the CPU to physical addresses in DDR memory.

Contents
Cortex-M1 MPU OverviewEnabling MPU for DDR AccessCortex-M1 Address TranslationTranslation ProcessSetting up the Translation TableEnabling Cache with MMUHandling Translation FaultsUsing the MPU for Software ProcessesConclusion

Cortex-M1 MPU Overview

The Cortex-M1 MPU supports configuring up to 16 memory regions with individual access permission controls. Each MPU region is defined by:

  • Start address – Base address of the memory region
  • End address – Limit address of the region
  • Access permissions – Read/Write/Execute permissions
  • XN attribute – Instruction fetch disable flag
  • Region size – Determines region matching logic
  • Enable flag – To enable/disable the region

The MPU checks every memory access from the CPU against the configured regions to validate the access and perform address translation if enabled. By default, address translation is disabled and the MPU performs only access permission checks.

Enabling MPU for DDR Access

To enable address translation for DDR accesses, the DDR memory range must be configured as an MPU region with address translation enabled. For example: MPU_Region DDR_region; DDR_region.base_addr = DDR_PHYS_BASE; // e.g. 0x80000000 DDR_region.end_addr = DDR_PHYS_END; // e.g. 0x81FFFFFF DDR_region.access_perm = FULL_ACCESS; DDR_region.xn = NOT_EXECUTE; DDR_region.enable = ENABLED; DDR_region.addr_translate = ENABLED; MPU_ConfigureRegion(&DDR_region);

This configures an MPU region covering the full DDR physical address range with read/write/execute permissions. Address translation is enabled by setting the addr_translate field.

Cortex-M1 Address Translation

With MPU address translation enabled, the processor converts the virtual addresses from the CPU core into physical addresses to access DDR memory. This translation uses a first-level table called the Translation Table Base Register (TTBR).

The TTBR points to a translation table in memory with descriptors that contain the mapping information. An area of DDR memory needs to be allocated for the translation table. The descriptor format determines the page size – 4KB or 64KB.

For a 4KB page table, the virtual address is split into:

  • Top 20 bits – Point to the descriptor entry in the translation table
  • Next 12 bits – 4KB page offset

The processor uses the top bits to look up the descriptor, which contains the 20-bit physical page number. This gets concatenated with the 12-bit offset to form the 32-bit physical address.

Translation Process

So in summary, the Cortex-M1 performs these steps for address translation:

  1. Split virtual address into PTBR index and page offset bits
  2. Read entry from translation table pointed to by TTBR
  3. Get page number from descriptor entry
  4. Concatenate page number and offset to form physical address
  5. Access memory using physical address

The MPU also checks the descriptor entry access permissions before allowing the access. Any violation causes a memory fault exception.

Setting up the Translation Table

The translation table is normally set up by the platform boot firmware. A region of DDR memory must be allocated for the table. Some key steps are:

  1. Allocate translation table memory and clear entries
  2. Create descriptors for mapping DDR memory
  3. Set TTBR to point to base of table
  4. Enable MPU and address translation

The descriptors need to map the DDR memory address range contiguously, with access permissions enabled. The PS virtual address space for DDR can be identity mapped 1:1 to the physical addresses.

Enabling Cache with MMU

The Cortex-M1 has 8KB instruction and data caches. Cacheability attributes can be set in the translation table descriptors. This controls whether memory regions are cached or bypass the cache.

The inner cache must be enabled along with the MMU translation. This ensures cache coherency and that cache invalidate operations work correctly with address translation enabled.

Handling Translation Faults

In case of any translation fault, the Cortex-M1 raises a memory management fault exception. The fault status registers indicate the fault reason, which can be:

  • Access permission violation
  • Translation fault – Invalid descriptor entry
  • Domain fault – Access to unsupported domain
  • Alignment fault e.g. unaligned access

The fault handler needs to examine the fault status and take appropriate action – fix invalid table entry, change permission, or terminate the process. The translation table contents may need to be modified dynamically at runtime in some cases.

Using the MPU for Software Processes

The Cortex-M1 MPU and MMU can be used to implement memory protection and virtual addressing for supervisor software and application processes running on the processor. Some examples:

  • Isolate processes into separate virtual address spaces
  • Limit process memory access to allowed regions
  • Map memory areas with different cache attributes
  • Dynamically expand/shrink process memory regions

The MPU provides the basic mechanisms for memory access control and address translation needed for robust software processes in embedded applications using the Cortex-M1 processor.

Conclusion

The Cortex-M1 MPU provides configurable regions with access control and address translation capabilities to remap CPU addresses when accessing DDR memory. The translation table setup is important to map the DDR address range contiguously and enable cacheability as needed. Proper fault handling and dynamically modifying table entries are required to support virtual memory management of software processes.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Mapping PS DDR Memory Region to Cortex-M1 Address Space
Next Article Using AXI interconnect between Cortex-M1 and PS on Pynq-Z1
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

Cortex M4 Interrupt Vector Table

The Cortex-M4 interrupt vector table defines the location of exception…

8 Min Read

What are Half-Precision (HP) floating-point instructions in Arm Cortex-M series?

Half-precision (HP) floating-point instructions in Arm Cortex-M series processors provide…

5 Min Read

Basepri Example

The BASEPRI register is one of the system control registers…

10 Min Read

What is ARM GCC toolchain?

The ARM GCC toolchain refers to the compiler tools used…

7 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account