Bare Metal User Guide

ID 683211
Date 11/30/2015
Public
Document Table of Contents

1.6.1.2. Create New Scatter File to Locate the Bare Metal Application in the OCRAM

  1. Create a scatter file. Right click on the project, and select "New > Other...", then "Scatter File Editor > Scatter File".
    The scatter file enables you to specify the memory map of an image to the linker using a description in a text file. It is used by the ARM compiler linker to determine the placement of the program in the target memory.
    Figure 8. Creating Scatter File
  2. Select the project name, bare-metal-hello-world-01, and enter the scatter file name, like scatter_OCRAM.scat
    Figure 9. Scatter File Setting
  3. Select Finish.
    The new file automatically appears in the Project Explorer view.
  4. In the scatter_OCRAM.scat editor view, enter the following when targeting a Cyclone V or Arria V device:
    OCRAM 0xFFFF0000 0x10000
    {     
    	APP_CODE  + 0    
    	{        
    		* (+ RO , + RW , + ZI )    
    	}     
    	ARM_LIB_STACKHEAP 0xFFFF8000 EMPTY 0x8000 ; Application heap and stack    
    	{ }
    }
    The view looks similar to the following:
    Figure 10. Scatter OCRAM Code Snippet
    Note: The linker script instructs the linker on how to link the application:
    • Defines OCRAM base address (0xFFFF0000) and size (0x10000)
    • Loads all application sections in the OCRAM
    • Allocates a maximum of 32 KB (0x8000) for stack and heap starting from address 0xFFFF8000
    The parameters can easily be changed for targeting Arria 10 devices, where there are 256 KB of OCRAM located at 0xFFE00000.
  5. Select the Regions/Sections tab, located just below the scatter file to show what the memory map looks like.
    Figure 11. Scatter File Regions
  6. Select File > Save to save the modifications.
  7. After the scatter file has been created in the project, it needs to be associated with the project properties. Select the project name in the Project Explorer view and right-click to select Properties.
  8. Go to C/C++ Build > Settings > Tool Settings > ARM Linker 5 > Image Layout.
  9. In the Scatter file (--scatter) text field, browse to the newly created scatter file which should now be in the project folder.
  10. Select Apply and then OK.
    Figure 12. Scatter File Location Setting