Bare Metal User Guide

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

1.6.3.1. Create a New Scatter File to Locate the Bare Metal Application in the SDRAM

In the DS-5 ARM compiler projects, it is the scatter file that specifies the addresses that are used to locate the code in the required portion of the memory map.

In this step, use the same "Hello World" application, but build it located in the SDRAM memory instead of the on-chip RAM.

To use SDRAM, you must run the Preloader to configure the SDRAM memory controller. If the SDRAM is not configured before you start running the project from SDRAM, the following error messages appears:
ERROR(CMD16-TAD274-NAL22): 
! Failed to load "bare metal-hello-world-01.axf" 
! Failed to write 4,896 bytes to address S:0x02000000 while writing block of 4,096 bytes to address S:0x02000000 
! General error on memory or register access.
  1. Create a scatter file for SDRAM. Go to File > New > Others... and select Scatter File Editor > Scatter File.
  2. Click Next and enter the file name of the new scatter file as scatter_SDRAM.scat and click Finish.
  3. In the scatter_SDRAM.scat editor view, enter the following:
    SDRAM 0x02000000 0x02000000  ; 32M SDRAM
    {     
    	APP_CODE  + 0    
    	{        
    		* (+ RO , + RW , + ZI )    
    	}     
    	ARM_LIB_STACKHEAP 0x03000000 EMPTY 0x0x01000000 ; Application heap and stack    
    	{ }
    }
    Note:

    If your HWLibs project needs interrupt support, you have to add a "VECTOR" section at the beginning of the scatter file. For example:

    SDRAM 0x00100000 0x40000000 
    {
        VECTORS +0
        {
            * (VECTORS, +FIRST)
        }
        APP_CODE +0
        {
            * (+RO, +RW, +ZI)
        }
        ARM_LIB_STACKHEAP +0 EMPTY (0x40000000 - ImageLimit(APP_CODE)) ; Application heap and stack
        { }
    }
    This is the standard scatter file for a project that runs from SDRAM in most of the HWLibs examples in the "<SoC EDS installation path>\embedded\examples\software". Please note that you have to compile and link “alt_interrupt_armcc.s” in your project. This is needed because the ARMCC toolchain does not provide the vectors at the start of the program automatically.
    Note: For this section, the Vector section is not included since we are running a simple "Hello World" project only.
    Figure 42. SDRAM Scatter File Code Snippet
  4. Make sure the new scatter file appears in the Project Explorer view.
    Figure 43. SDRAM Scatter file in Project Explorer
  5. Associate the new scatter file with the project. Right-click on the project and select Properties > C/C++ Build > Settings > ARM Linker 5 > Image Layout.
  6. Browse to the new scatter file.
  7. Alternatively, instead of browsing, enter a path, like: ${workspace_loc}\bare-metal-hello-world-01\scatter_SDRAM.scat); select Apply and then OK.
    Figure 44. SDRAM Scatter File Location Setting
  8. Right-click on the project and select Build Project to rebuild with the new scatter file. Use the same debug configuration created earlier to download and run the application.
    The program stops at main and waits there. In the Commands view, notice the entry point is 0x02000000, which is the start address specified in the scatter file for the SDRAM.
    Figure 45. Program Stops at SDRAM Start Address