Skip to content. | Skip to navigation

Sections
You are here: Home Resources Documentation PetaLinux 0.40 final User Guide Advanced Topics Enabling Uncached Shadow Option

Enabling Uncached Shadow Option

Overview

When accessing memory region that are shared between the device driver and the hardware IP core the driver will need to do a cache flush on the memory region prior to any read operation. This is to prevent stale data from being read due to processor caching. Cache flushes will incur performance penalties due to the process of invalidating the cache.

The CONFIG_XILINX_UNCACHED_SHADOW support prevents the memory region from being cached by the processor. This option eliminates the need to flush the cache. Hence, significantly improving performance of the driver.

How to allocate UNCACHED SHADOW memory

Prior to using this memory region the driver will need to explicitly allocate them using the following function call.

In 2.6 kernel use the dma_alloc_coherent function call to allocate memory that will not be cached by the processor.

static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, int flag)

For 2.4 kernel use the consistent_alloc function call to allocate memory that will not be cached by the processor.

void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle);

How to configure for Uncached Shadow Memory Support

The mechanism that implements the Uncahced Shadow RAM functionality requires the following changes in the hardware project:

  • The DDR memory controller address map needs to be double that of the physical memory size.
  • The "main_memory_start" parameter in the OS section of the system.mss file needs to be set to the physical memory address map.
  • The "main_memory_size" parameter in the OS section of the system.mss file needs to reflect the actual size of the physical memory.

DDR Memory Controller Address Map

How the main memory is connected to the Microblaze core is platform dependent. However, it is only required to change the HIGHADDR parameter of the memory controller for the DDR RAM memory in the system.mhs file.

The HIGHADDR needs to be double the size of the physical memory.

The below example shows the modifications required for a system with 32MB of DDR SDRAM memory.

BEGIN mch_opb_ddr
PARAMETER INSTANCE = DDR_SDRAM_32Mx16
PARAMETER HW_VER = 1.00.c

...

PARAMETER C_MEM0_BASEADDR = 0x28000000
PARAMETER C_MEM0_HIGHADDR = 0x2BFFFFFF

...

This example assumes that the system SDRAM memory is connected to the processor via the mch_opb_ddr interface. The C_MEM0_HIGHADDR parameter is set to 0x2BFFFFFF (64MB) double the physical memory size of 32MB.

It is normally also required to ensure that the BASEADDR parameter is aligned with the new memory size.

For example, in the above system. The new memory size is 64MB or 0x04000000. Hence, the user needs to ensure that the BASEADDR value is multiple of 0x04000000. E.g. 0x24000000 or 0x28000000.

MAIN_MEMORY Parameter Overrides

On top of doubling the memory map range in the system.mhs file, it is also required to specify the actual physical memory range in the system.mss file.

The physical memory range is specified via the "main_memory_start" and "main_memory_size" parameter in the OS section of the system.mss file.

Set the main_memory_start parameter in the OS section of the system.mss file to the BASEADDR value as per specified previously. This parameter tells the PetaLinux BSP the start of the physical memory map address.

Set the main_memory_size parameter in the OS section of the system.mss file to be the actual physical size of the memory.

BEGIN OS
PARAMETER OS_NAME = petalinux
PARAMETER OS_VER = 1.00.b
PARAMETER PROC_INSTANCE = microblaze_0
PARAMETER lmb_memory = dlmb_cntlr
PARAMETER flash_memory = FLASH_16Mx8
PARAMETER flash_memory_bank = 0
PARAMETER main_memory_start = 0x28000000
PARAMETER main_memory_size = 0x02000000
PARAMETER stdin = RS232_DTE
PARAMETER stdout = RS232_DTE
PARAMETER periph_type_overrides = {Reset_GPIO soft_reset} {Character_LCD_2x16 LCD_2x16}
END

The above example shows the physical memory is mapped to address 0x28000000 and the size is 0x02000000 (32MB).

Generate BSP and Bitstreams

Once the above modification is done, it is required to generate the BSP for the kernel build. This can be done via the following commands.

$ make -f system.make libs

Remember to run petalinux-copy-autoconfig to propagate the configuration files to the kernel build framework.

Generate the hardware bitstream as per usual.

Kernel Configurations

To enable the UNCACHED Shadow RAM support in the kernel, run the kernel configuration tools and enable the "Are you using uncached shadow for RAM ?" option.

  ┌────────────────────── Linux Kernel Configuration ───────────────────────
│ Arrow keys navigate the menu. <Enter> selects submenus --->. │
│ Highlighted letters are hotkeys. Pressing <Y> includes, <N> excludes, │
│ <M> modularizes features. Press <Esc><Esc> to exit, <?> for Help, </> │
│ for Search. Legend: [*] built-in [ ] excluded <M> module < > │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Code maturity level options ---> │ │
│ │ General setup ---> │ │
│ │ Loadable module support ---> │ │
│ │ Block layer ---> │ │
│ │ Platform options ---> │ │
│ │ Processor type and features ---> │ │
│ │ Exectuable file formats ---> │ │
│ │ Networking ---> │ │
│ │ Device Drivers ---> │ │
│ │ File systems ---> │ │
│ │ Kernel hacking ---> │ │
│ │ Security options ---> │ │
│ │ Cryptographic options ---> │ │
│ │ Library routines ---> │ │
│ │ --- │ │
│ │ Load an Alternate Configuration File │ │
│ └────┴(+)─────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > │
└─────────────────────────────────────────────────────────────────────────┘
  ┌────────────────────── Processor type and features ──────────────────────
│ Arrow keys navigate the menu. <Enter> selects submenus --->. │
│ Highlighted letters are hotkeys. Pressing <Y> includes, <N> excludes, │
│ <M> modularizes features. Press <Esc><Esc> to exit, <?> for Help, </> │
│ for Search. Legend: [*] built-in [ ] excluded <M> module < > │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ [ ] Preemptible Kernel │ │
│ │ [*] Are you using uncached shadow for RAM ? │ │
│ │ [ ] Allow allocating large blocks (> 1MB) of memory │ │
│ │ --- Boot options │ │
│ │ () Default kernel command string │ │
│ │ [ ] Force default kernel command string │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > │
└─────────────────────────────────────────────────────────────────────────┘

Save and exit the configurations.

Build and download the kernel images as per usual.

Now the Uncached Shadow RAM support is enabled on your platform.

Document Actions
Quick Contact
Customer stories

Petalogix helped us stay on our target schedule and provided valuable insight.

Read more PetaLogix customer stories

 
Site by:
Personal tools