diff --git a/tools/build_api.py b/tools/build_api.py index c769dea202c..da90efa5187 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -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") diff --git a/tools/memap.py b/tools/memap.py index c3d3eaa6962..520d4ac75df 100644 --- a/tools/memap.py +++ b/tools/memap.py @@ -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 @@ -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 [