Keil Scatter File:
-Aviral Mittal

https://www.linkedin.com/in/avimit/
A Scatter load defines 1 or more load regions, and each Load region can contain 1 or more execution regions.
A load region description specifies the region of memory where its child execution regions are to be placed.
Following is an example of Keil uVision 5 Scatter file:
It Describes 1 Load region, namely
LR_IROM1
and this load region contains 3 execution regions, namely
ER_IROM1
RW_IRAM1
RW_IRAM2
All the above 3 names are user given.

A region is defined by <user given name> e.g. LR_IROM1, followed by start address, followed by Size.
By default the region is a 'load region' i.e the LR_IROM1 region is a 'load region'
If a region is defined within this load region, that is by-default execution region.
In the example scatterload file, the 'load region' named LR_IROM1 defines 3 execution regions, namely ER_IROM1, RW_IRAM1 and RW_IRAM2
Hence in the following example there is only 1 execution region which exists within the definition braces of  the first load region.



LR_IROM1 0x00000000 0x00040000  {    ; load region size_region
  ER_IROM1 0x00000000 0x00040000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x80000000 0x00020000  {  ; RW data
   .ANY (+RW +ZI)
  }
  RW_IRAM2 0x40000000 0x00020000  {  ; RW data
   .ANY (+RW)
  }
}


Another example of Scatter-Load File:


LR_IROM1 0x00000000 0x00040000  {    ; load region size_region
  ER_IROM1 0x00000000 0x00020000  {
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x00020000  {  ; RW data
   .ANY (+RW +ZI)
  }
  NS_EXEC_BIN 0x20010000 0x00020000  {  ; NS code starts here. First value is the ns sp value.
    ns_bin.o(section_ns_bin)
  }
}



The above file can be saved as scatter.txt, and used in Keil uVision 5. The following screenshot shows how to use the above scatter file in Keil uVision5
   


This will allow 2 RW regions.

Key Words:
Example Scatter file
Example Scatterload file
Example Scatter load file
Working example of scatter load file.
How to use custom scatter file in Keil uVision
Load your own customized scatter file.