* Add editorconfig and pre-commit config Editorconfig is widly used and supported file. It says basic things how files should be formatted. pre-commit is tool which can automatically check some basic checks like code formatting everytime someone makes commit. This can also be used in CI to run these things. Then it is very easy to do same things locally as in CI. This also makes easy to select clang-format version so everyone is using same one. * clang-format: Ignore folders where are external code We should not format external code. Add clang-format files to exclude those. We should move external code always to example external/ folder so we can exclude those more easily. * clang-format: Remove custom zephyr/.clang-gormat This clang-format file where introduces before our root clang-format. It does not make sense anymore as we have root clang-format. Removing this will unifie formatting in whole repo. * clang-format: Add couple new rules Add couple new formatting rules. Always align const to left side. We did have only one place where it was right side so this make sense as it is already rule for us. I choose also insertbraces becuase when I run this I notice that we have lot of multiline code without braces. So very error prone places. This will take error possibility away. Repo also always use braces even with single line statments so this does not matter much. * ci: Add pre-commit validation Validate pre-commit in CI. * format: Convert spaces to tabs in Makefiles Makefile normally use tabs. We enforce that with editorconfig. Fix couple places where spaces where still in use. --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
memap - Static Memory Map Analysis
Introduction
memap is a simple utility that displays static memory information required by mbed applications. This information is produced by analysing the memory map file previously generated by your toolchain.
Note: this tool shows 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
Using memap
memap is automatically invoked after an mbed build finishes successfully. 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
Result 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
The table above showed multiple memory sections.
.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 copied from Flash to RAM at run time).bss: uninitialized data allocated in RAM, or variables initialized to zero.Heap: dynamic allocations in the Heap area in RAM (for example, used bymalloc). The maximum size value may be defined at build time.Stack: dynamic allocations in the Stack area in RAM (for example, used to store local data, temporary data when branching to a subroutine or context switch information). The maximum size value may be defined at build time.
There are other entries that require a bit of clarification:
- Fill: represents the bytes in multiple sections (RAM and Flash) that the toolchain has filled with zeros because it requires subsequent data or code to be aligned appropriately in memory.
- Misc: usually represents helper libraries introduced by the toolchain (like
libc), but can also represent modules that are not part of mbed.
Current support
memap has been tested on Windows 7, Linux and Mac OS X and works with memory map files are generated by the GCC_ARM, ARM (ARM Compiler 5) and IAR toochains.
Known issues and new features
This utility is considered ‘alpha’ quality at the moment. The information generated by this utility may not be fully accurate and may vary from one toolchain to another.
If you are experiencing problems, or would like additional features, please raise a ticket on GitHub and use [memap] in the title.