Skip to content

tools: Bring back memap output by default #6155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions tools/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,11 @@ def build_project(src_paths, build_path, target, toolchain_name,
real_stats_depth = stats_depth if stats_depth is not None else 2
memap_table = memap_instance.generate_output('table', real_stats_depth)
if not silent:
if not stats_depth:
memap_bars = memap_instance.generate_output('bars',
real_stats_depth, None,
getattr(toolchain.target, 'device_name', None))
print(memap_bars)
else:
print(memap_table)
memap_bars = memap_instance.generate_output('bars',
real_stats_depth, None,
getattr(toolchain.target, 'device_name', None))
print(memap_table)
print(memap_bars)

# Write output to file in JSON format
map_out = join(build_path, name + "_map.json")
Expand Down
14 changes: 8 additions & 6 deletions tools/memap.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,9 @@ def generate_table(self, file_desc):
output += "Total Flash memory (text + data): %s bytes\n" % \
str(self.mem_summary['total_flash'])

return output
return output.strip()

def generate_bars(self, file_desc, device_name=None):
def generate_bars(self, file_desc, device_name=None, show_totals=False):
""" Generates nice looking bars that represent the memory consumption

Returns: string containing nice looking bars
Expand Down Expand Up @@ -663,10 +663,12 @@ def unit(n, u='B', p=3):
scale = math.floor(math.log(n, 1024))
return '{1:.{0}g}{2}{3}'.format(p, n/(1024**scale), PREFIXES[int(scale)], u)

usage = "Text {} Data {} BSS {}".format(unit(text), unit(data), unit(bss))
avail = "ROM {} RAM {}".format(unit(rom_used), unit(ram_used))
output = ["{0} {1:>{2}}".format(usage, avail,
abs(WIDTH-len(usage)-1) if device_name is not None else 0)]
output =[]
if show_totals:
usage = "Text {} Data {} BSS {}".format(unit(text), unit(data), unit(bss))
avail = "ROM {} RAM {}".format(unit(rom_used), unit(ram_used))
output.append("{0} {1:>{2}}".format(usage, avail,
abs(WIDTH-len(usage)-1) if device_name is not None else 0))

if device_name is not None:
for region, avail, uses in [
Expand Down