Allow memap.py to process memory bank information #345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes
This PR rewrites memap.py to enable it to process memory bank information and print percentage used of each memory bank in the MCU.
For some background, memap.py is a script called each time an application has been built to display information about how much memory of each type an application uses. It gets this information by parsing the map file generated by the linker when it builds the application. It prints a report like this:
This PR augments the script to read in the memory bank information and track which memory bank each of the symbols resides in. This enables it to print a breakdown like this:
This should be very useful as, traditionally, Mbed makes it easy to see how much space you are using, but hard to tell how close you are to running out of space. It's especially bad since a lot of devices will say they have some amount of memory, but that memory is actually split into different banks (e.g ITCM, DTCM, AXI SRAM, D2 SRAM, etc), only some of which can actually be used by Mbed. This report should give you much more detailed information about how much memory you have and how much of it is used.
memap.py is a somewhat old python script, and lacks a lot of more modern conveniences like type annotations and dataclasses. I tried to add in type info and other refactorings where possible, without completely taking the script down to the studs and rebuilding. This might be worth doing at some point but I don't realistically think I have time at present.
One thing I did add was correct a lot of incorrect usages of the term "module", and add a new glossary at the top that explains what some of the terms used in the code actually mean.
Impact of changes
Migration actions required
None
Documentation
None
Pull request type
Test results