Merge pull request #2030 from mlnx/memap_docs

Adding memap documentation
pull/2034/head
Sam Grove 2016-06-27 17:15:12 -05:00 committed by GitHub
commit 7bd9952583
1 changed files with 93 additions and 0 deletions

93
docs/memap.md Normal file
View File

@ -0,0 +1,93 @@
# memap - Static Memory Map Analysis
## Introduction
*memap* is a simple utility useful to display static memory information required by [mbed](https://github.com/mbedmicro/mbed) applications. This information is produced by analysing the memory map file previously generated by your toolchain.
Note: this tool is showing static RAM usage and the total size of allocated heap and stack space defined at compile time, not the actual heap and stack usage (which may be different depending on your application).
## Table of Contents
1. [Using memap](#using-memap)
1. [Information on memory sections](#info-mem-sections)
1. [Current support](#current-support)
1. [Known problems](#known-problems)
## Using memap
*memap* is automatically invoked after an mbed build finishes succesfully. But it's also possible to manually run the program with different command line options, for example:
```
$> python memap.py
usage: memap.py [-h] -t TOOLCHAIN [-o OUTPUT] [-e EXPORT] [-v] file
Memory Map File Analyser for ARM mbed version 0.3.11
positional arguments:
file memory map file
optional arguments:
-h, --help show this help message and exit
-t TOOLCHAIN, --toolchain TOOLCHAIN
select a toolchain used to build the memory map file
(ARM, GCC_ARM, IAR)
-o OUTPUT, --output OUTPUT
output file name
-e EXPORT, --export EXPORT
export format (examples: 'json', 'csv-ci', 'table':
default)
-v, --version show program's version number and exit
```
Example:
```
$> python memap.py GCC_ARM\myprog3.map -t GCC_ARM
+----------------------------+-------+-------+------+
| Module | .text | .data | .bss |
+----------------------------+-------+-------+------+
| Fill | 170 | 0 | 2294 |
| Misc | 36282 | 2220 | 2152 |
| core/hal | 15396 | 16 | 568 |
| core/rtos | 6751 | 24 | 2662 |
| features/FEATURE_IPV4 | 96 | 0 | 48 |
| frameworks/greentea-client | 912 | 28 | 44 |
| frameworks/utest | 3079 | 0 | 732 |
| Subtotals | 62686 | 2288 | 8500 |
+----------------------------+-------+-------+------+
Allocated Heap: 65540 bytes
Allocated Stack: 32768 bytes
Total Static RAM memory (data + bss): 10788 bytes
Total RAM memory (data + bss + heap + stack): 109096 bytes
Total Flash memory (text + data + misc): 66014 bytes
```
## Information on memory sections
Find here extended description on the multiple memory sections shown in the previous table.
- text: is where the code application and constants are located in Flash
- data: non-zero initialized variables; allocated in both RAM and Flash memory (variables are initialized in RAM at run time from Flash)
- bss: uninitialized data allocated in RAM, or variables initialized to zero
- heap: dynamic allocated memory defined at build time, usually used by malloc, etc, in RAM
- stack: used to store local data, temporary data when branching to a subroutine and context switch info; it's considered dynamic allocated memory region in RAM defined at build time
On the other hand, there are other entries which do not correspond to modules directly and require a bit of clarification:
- Fill: this entry represents the bytes in multiple sections (RAM and Flash) that the toolchain has filled with zeros because requires subsequent data or code to be aligment appropriately in memory
- Misc: it mainly represents helper libraries introduced by the toolchain (e.g. libc) but there might be other modules not part of mbed
## Current support
*memap* has been tested on Windows 7, Linux and Mac.
Supported map files generated by the following toolchains: GCC_ARM, ARM (ARM Compiler 5) and IAR.
## Known problems & New features
This utility is considered 'Alpha' quality at the moment.
Please note, the information generated by this utility may not be fully accurate and may vary from one toolchain to another.
If you are seeing problems or would like new features to be added then please raise a ticket on [GitHub](https://github.com/mbedmicro/mbed/issues) and use ```[memap] ``` in the title.