Some engineers may not pay much attention to map files (memory mapped files) in daily project development, but once you understand the map file, you will get twice the result with half the effort in the development and debugging process . In order to make the problem more specific, here we take IAR EWARM and STM32F107 as examples to deeply analyze a map file.
First, you need to check the option to generate a map file in the project settings. The default setting is not to generate a map file, so we need to set it manually. As shown below:
After each compilation, you will find a .map file named after the project in the "Project Directory\Debug\Lis" folder. Open it in the IAR editor (you can also open it directly with a file editor such as Notepad or Notepad++ ).
In addition, you can also double-click the displayed map file in the Output virtual directory of the workspace , and the map file will be automatically opened in the IAR editor .
The map file mainly consists of the following parts:
- The file header shows the linker version, output file name, MAP file name, and linker command line, etc.
- RUNTIME MODEL ATTRIBUTES displaysEndianand other attributes;
- PLACEMENT SUMMARY showssectionsin memory;
- INIT TABLE displays section tablesrelated to initialization;
- MODULE SUMMARY displays all linked file information, including target files and library files;
- ENTRY LIST gives the entry addresses of all functions and the target files where they are located.
- The total number of code and data bytes is shown at the end of the file (if you want to see how much Flash and RAM the final target code occupies , you can check here).
The following are several parts that are often used during debugging.
- PLACEMENT SUMMARY , this part mainly shows the memory mapping address of code and data in the chip. Some people may wonder why these addresses are allocated. In fact, these address allocations aredefinedLinkerfile (*.icfIARlinks according to the defined address based on the selected target chip, and then burns it intoFlash. The specific definition of the address space can be found inicffile description for details.
- ENTRY LIST , the entry address of all functions in the development project. This part is very useful. Through this address mapping and combined with observing the memory space during debugging, you can understand the execution status of the entire program.
3. MODULE SUMMARY , mainly summarizes the ro code size and rw data size occupied by the linked file .
- This is the end of the map file. It gives the resources occupied by the entire project file, that is, the usage of the internal Flash and RAM of the chip , which helps you grasp the scale of project development. Finally, it gives the project compilation and linking output information .
This content is originally created by MamoYU , a user on the EEWORLD forum. If you want to reprint or use it for commercial purposes, you must obtain the author’s consent and indicate the source.