Complete Analysis of Map Files in MDK-ARM

Friends with extensive project development experience must have encountered issues with memory overflow. How do you analyze such problems?

The previous article detailed the map files in IAR, explaining how to analyze and understand the content of map files in IAR. This article will similarly discuss the contents of map files in MDK-ARM.

Output Map Configuration

First, let’s discuss the configuration of map files in MDK-ARM. In MDK-ARM, we can output the corresponding (needed) content in the map file based on our situation (different configurations). By default, all information is output.

Project -> Options for Target -> Listing: You will see the following configuration interface:

Complete Analysis of Map Files in MDK-ARM

From the above image, you should have a general idea of the contents of the map file, right?

Complete Analysis of Map Files in MDK-ARM

The contents of the map file are roughly divided into five categories (in the order of map file classification):

1. Section Cross References: Module and segment (entry) cross-references;

2. Removing Unused Input Sections from the Image: Remove unused modules;

3. Image Symbol Table: Mapping symbol table;

4. Memory Map of the Image: Memory (mapping) distribution;

5. Image Component Sizes: Storage component sizes.

The following sections will detail several key contents of the map file in MDK-ARM (Note: some translations may not be very accurate).

Section Cross References: Module and Segment (Entry) Cross-References

Complete Analysis of Map Files in MDK-ARM

Configuration must include:Cross Reference

Section Cross References: Module and segment (entry) cross-references indicate the relationships between modules and segments (defined entries) generated by various source files.

For example:

main.o(i.System_Initializes) refers to bsp.o(i.BSP_Initializes) for BSP_Initializes

This means:

The System_Initializes function (i.System_Initializes) in the main module (main.o) calls the BSP_Initializes function in the bsp module (bsp.o).

Note:

main.o is the object file module generated from the main.c source file;

i.System_Initializes is the entry point of the System_Initializes function.

Removing Unused Input Sections from the Image: Remove Unused Modules

Complete Analysis of Map Files in MDK-ARM

Configuration must include:Unused Sections Info

This option is easy to understand; it refers to modules in our project code that have not been called.

Finally, there is a statistical summary:

52 unused section(s) (total 2356 bytes) removed from the image.

1. A total of 52 sections were not called;

2. The total size of unused sections is 2356 bytes;

Image Symbol Table: Mapping Symbol Table

Complete Analysis of Map Files in MDK-ARM

Configuration must include:Symbols

Image Symbol Table: The mapping symbol table, which is a table of addresses corresponding to each segment (this item is relatively important).

Symbols are divided into two main categories

1. Local Symbols Local

2. Global Symbols Global

Key Points

1. Symbol Name: The name of the symbol

2. Value: The corresponding address;

You will find addresses like 0x0800xxxx and 0x2000xxxx.

0x0800xxxx indicates code, variables, etc. stored in FLASH.

0x2000xxxx indicates variables Data, etc. stored in RAM.

3. Ov Type: The type corresponding to the symbol

Symbol types can generally include: Number, Section, Thumb Code, Data, etc.;

Careful readers will notice that global and static variables, etc. are located in the 0x2000xxxx memory RAM.

4. Size: Storage size

This is easy to understand; if we suspect memory overflow, we can check the code storage size for analysis.

5. Object (Section): Target section

This generally refers to the module (source file) where it is located.

Memory Map of the Image: Memory (Mapping) Distribution

Complete Analysis of Map Files in MDK-ARM

Configuration must include:Memory Map

Memory Map of the Image: The memory (mapping) distribution, which has relatively more content and is also quite important.

Image Entry Point: 0x08000131: Indicates the mapped entry address.

Load Region LR_IROM1 (Base: 0x08000000, Size: 0x000004cc, Max: 0x00080000, ABSOLUTE):

This indicates that the loading region is located at the starting address of LR_IROM1, 0x08000000, with a size of 0x000004cc, and this area has a maximum of 0x00080000.

Execution Region:

Execution Region ER_IROM1

Execution Region RW_IRAM1

This area corresponds to the regions in our target configuration, as shown below:

Complete Analysis of Map Files in MDK-ARM

Key Points

1. Base Addr: Storage address

0x0800xxxx FLASH address and 0x2000xxxx RAM address.

2. Size: Storage size

3. Type: Type

Data: Data type

Code: Code type

Zero: Uninitialized variable type

PAD: This type is placed in this position in the map file; it cannot actually be considered a type here. If translated, it can only be described as “padding type”.

The ARM processor is 32 bits; if a variable is defined as 8 bits or 16 bits, there will be some leftover space. This refers to the “padding” portion, and you will find that the other options do not have corresponding values.

4. Attr: Attributes

RO: Storage with ROM segments

RW: Storage with RAM segments

5. Section Name: Section name

This can also be referred to as the entry classification name, similar to the modules and segments referred to in the first section, “Section Cross References.”

It generally includes: RESET, .ARM, .text, i, .data, .bss, HEAP, STACK, etc.

6. Object: Target

Image Component Sizes: Storage Component Sizes

Complete Analysis of Map Files in MDK-ARM

Configuration must include:Size Info

Image Component Sizes: The storage component sizes, which mainly summarize the storage size information of the modules.

I believe everyone can understand the content of this section. After compiling the project, you will generally see a summary like the following in the compilation window:

Program Size: Code=908 RO-data=320 RW-data=0 ZI-data=1024

Code: Refers to the size of the code;

Ro-data: Refers to constant data other than inline data;

RW-data: Refers to readable and writable (RW) initialized variable data;

ZI-data: Refers to uninitialized (ZI) variable data;

Code and Ro-data: Located in FLASH;

RW-data and ZI-data: Located in RAM;

Note: RW-data initialized data will be stored in Flash and will be moved to RAM upon power-up.

The relationships are as follows:

RO Size= Code + RO Data

RW Size = RW Data + ZI Data

ROM Size = Code + RO Data + RW Data

For more specific content, refer to the article:

Keil Compilation Storage Related Explanation and Expansion

The above information is a comprehensive summary. If you don’t want to see the details of those modules and just want to see the summary statistics, you can check only “Totals Info” in the configuration. Comparison information:

Complete Analysis of Map Files in MDK-ARM

Search for “EmbeddDeveloper” on WeChat or scan the QR code below to follow and see more exciting content in my bottom menu!

Complete Analysis of Map Files in MDK-ARM

Was this content helpful to you?

Leave a Comment