2017/01/17

Complex scattering example

What code/data must be placed in a root region of a scatter file?

The initialization code/data from within the C library that does the copying from load to execution addresses must be placed in a root region (i.e. one which executes at its load address). This is because this code/data cannot itself be copied. This means that the scatter description file must have at least one root region that must contain:
  • The copying code from the library member called __main.o.
  • Sections named Region$$Table and ZISection$$Table which contain the addresses of the code/data to be copied. These sections are generated by the linker so they do not have a corresponding object file (so * must be used when placing these in a scatter file).
If these sections named Region$$Table and ZISection$$Table are not placed in a root region then the linker will report:
Error: L6202E: Section Region$$Table cannot be assigned to a non-root region.
Error: L6202E: Section ZISection$$Table cannot be assigned to a non-root region. 
In many cases this code/data may be placed in a root region by use of a wildcard *(+RO) that gathers all non-explicitly placed code/data. However in some circumstances, this wildcard may need to be placed in a non-root region, in which case a scatter file similar to the one below may be used.
Example scatter file for ADS and RVCT 2.0:
LOAD_FLASH 0x04000000 0x80000   ;start address and length
{
    EXEC_FLASH 0x04000000 0x80000
    {
        init.o (Init,+FIRST)    ; remap & init code
        __main.o (+RO)          ; copy code
        * (Region$$Table)       ; RO/RW addresses to copy
        * (ZISection$$Table)    ; ZI addresses to zero
    }
    EXEC_32bitRAM 0x0000 0x2000
    {
        vectors.o (Vect,+FIRST) ; vector table
        int_handler.o (+RO)     ; interrupt handler
    }
    EXEC_16bitRAM 0x2000 0x80000
    {
        * (+RO)                 ; ## all other RO areas ##
        * (+RW,+ZI)             ; program variables
    }
} 
For RVCT 2.1 and later, an alternative way is to specify these sections using InRoot$$Sections:
LOAD_FLASH 0x04000000 0x80000   ;start address and length
{
    EXEC_FLASH 0x04000000 0x80000
    {
        init.o (Init,+FIRST)    ; remap & init code
        * (InRoot$$Sections)    ; using InRoot$$Sections
    }
    ...
} 
An application's initial entry point must also be rooted. If the initial entry point is not in a root region, the link will fail with an error such as:
Error: L6203E: Entry point (0x08000000) lies within non-root region EXE_FLASH. 


Reference:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0474g/BABEJHII.html

http://www.keil.com/support/man/docs/armlink/armlink_pge1362065974588.htm

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3552.html

2017/01/16

ARM Scatter File Explain

Bookmark below simple straight forward explaining
http://www.keil.com/support/man/docs/armlink/armlink_pge1362065973150.htm
Simple scatter-loaded memory map
7.1.6 Scatter-loading images with a simple memory map
For images with a simple memory map, you can specify the memory map using only linker command-line options, or with a scatter file.
The following figure shows a simple memory map:
Figure 7-1 Simple scatter-loaded memory map

Simple scatter-loaded memory map

Simple scatter-loaded memory map






The following example shows the corresponding scatter-loading description that loads the segments from the object file into memory:

LOAD_ROM 0x0000 0x8000       ; Name of load region (LOAD_ROM),
                             ; Start address for load region (0x0000),
                             ; Maximum size of load region (0x8000)
{
    EXEC_ROM 0x0000 0x8000   ; Name of first exec region (EXEC_ROM),
                             ; Start address for exec region (0x0000),
                             ; Maximum size of first exec region (0x8000)
    {
        * (+RO)              ; Place all code and RO data into
                             ; this exec region
    }
    SRAM 0x10000 0x6000      ; Name of second exec region (SRAM),
                             ; Start address of second exec region (0x10000),
                             ; Maximum size of second exec region (0x6000)
    {
        * (+RW, +ZI)         ; Place all RW and ZI data into
                             ; this exec region
    }
}

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...