In this article, we will delve into the world of scatter loading and explore its significance in creating a customized memory map for embedded systems. We will also discuss the importance of understanding the role of brackets in scatter loading files.

What is Scatter Loading?

Scatter loading is a technique used to create a customized memory map for embedded systems. It allows developers to specify the location of code segments, data, and other resources in the system's memory space. This technique is particularly useful when developing software for embedded systems that require specific memory arrangements.

The Role of Brackets

In scatter loading files, brackets [] are used to enclose specific information about each region. These brackets play a crucial role in defining the attributes of each region, such as its type (ROM, RAM, or ZI), size, and alignment.

Let's take an example:

EXEC_ROM 0x0 { spaghetti.o (+RO) }
EXEC_RAM 0x8000 { spaghetti.o (+RW) }
EXEC_RAM2 0xA000 { spaghetti.o (+ZI) }

In this example, the brackets [] are used to enclose information about each region. The +RO, +RW, and +ZI attributes specify the type of data that will be stored in each region.

Understanding Scatter Loading Files

Scatter loading files typically contain a list of regions, each with its own set of attributes. These regions are used to load different parts of the program into memory. The file also specifies the location and size of each region.

For example:

LOAD_ROM 0x0 : Load Region : Loading image's appearance
{
 EXEC_ROM 0x0 : Execution Region : Excution image's appearance
 {
 spaghetti.o (+RO) : 실행될때 spaghetti.o의 RO는 여기에, input section
 }
 EXEC_RAM 0x8000 : Execution Region
 {
 spaghetti.o (+RW) : 실행될 때 spaghetti.o의 RW는 여기에, input sectoin
 }
 EXEC_RAM2 0xA000 : Execution Region
 {
 spaghetti.o (+ZI) : 실행 될 때 spaghetti.o의 ZI는 여기에~, input section
 }
}

This file defines three regions: EXEC_ROM, EXEC_RAM, and EXEC_RAM2. Each region has its own set of attributes, including the type of data that will be stored in each region.

Loading Scatter Files into Linker

To load a scatter file into the linker, you can use the -scatter option. For example:

armlink -scatter filename.scl outfile1.o outfile2.o outfile3.o ...

This command tells the linker to load the filename.scl scatter file and create output files based on the regions specified in the file.

Root Region

One important consideration when creating a scatter loading file is the presence of a Root Region. The Root Region is the starting point for all memory accesses, and it must be defined in the scatter file.

If you don't define a Root Region, the linker will default to using the FIXED attribute to create a fixed memory map. This can lead to unexpected behavior or errors during execution.

Default Memory Map

When you don't use a scatter loading file, the linker will automatically generate a default memory map based on the type of data stored in each region. The default memory map is as follows:

  • RO (Read-Only) regions are placed at address 0x8000
  • RW (Read/Write) regions are placed after the RO regions
  • ZI (Zero-Init) regions are placed at the end of the memory space

This default memory map is suitable for most embedded systems, but it may not be optimal for all applications.


In this article, we have explored the role of brackets in scatter loading files and the importance of understanding the attributes of each region. We have also discussed the significance of creating a customized memory map using scatter loading techniques. By mastering these techniques, you can create optimized memory maps for your embedded systems and improve their performance and reliability.

References

  • ARM documentation: Scatter Loading
  • ARM documentation: Linker Reference Guide