From 3a294cf331b6da3646813d344c631bdeaab21531 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 19:54:24 +0000 Subject: [PATCH 1/3] Initial plan From 43054649bbf16e1ca8f3f728d06ed01071a79fc5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:00:51 +0000 Subject: [PATCH 2/3] Add modules.dmp size to ROM memory usage summary Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- scripts/memory_report.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/scripts/memory_report.py b/scripts/memory_report.py index 4f463dc..c330f26 100755 --- a/scripts/memory_report.py +++ b/scripts/memory_report.py @@ -156,8 +156,12 @@ def aggregate_by_library(self) -> Dict[str, Dict[str, int]]: return dict(library_usage) - def get_rom_usage(self) -> Dict[str, int]: - """Calculate ROM (Flash) usage""" + def get_rom_usage(self, modules_dmp_size: int = 0) -> Dict[str, int]: + """Calculate ROM (Flash) usage + + Args: + modules_dmp_size: Size of modules.dmp file if it exists + """ rom_usage = {} # Get library contributions to text and rodata @@ -166,6 +170,10 @@ def get_rom_usage(self) -> Dict[str, int]: for lib_name, sections in library_usage.items(): rom_usage[lib_name] = sections['text'] + sections['rodata'] + # Add modules.dmp size if provided + if modules_dmp_size > 0: + rom_usage['modules.dmp'] = modules_dmp_size + return rom_usage def get_ram_usage(self) -> Dict[str, int]: @@ -192,8 +200,12 @@ def get_ram_usage(self) -> Dict[str, int]: return ram_usage - def get_total_rom(self) -> int: - """Get total ROM usage""" + def get_total_rom(self, modules_dmp_size: int = 0) -> int: + """Get total ROM usage + + Args: + modules_dmp_size: Size of modules.dmp file if it exists + """ total = 0 if 'text' in self.sections: total += self.sections['text']['size'] @@ -202,6 +214,8 @@ def get_total_rom(self) -> int: if 'data' in self.sections: # .data is stored in ROM but copied to RAM total += self.sections['data']['size'] + # Add modules.dmp size if provided + total += modules_dmp_size return total def get_total_ram(self) -> int: @@ -380,10 +394,17 @@ def main(): parser = MemoryMapParser(map_file, library_config if library_config else None) parser.parse() + # Check for modules.dmp file in the output directory (build directory) + modules_dmp_path = Path(output_dir) / "modules.dmp" + modules_dmp_size = 0 + if modules_dmp_path.exists(): + modules_dmp_size = modules_dmp_path.stat().st_size + print(f"Found modules.dmp: {format_size(modules_dmp_size)}") + # Get memory usage - rom_usage = parser.get_rom_usage() + rom_usage = parser.get_rom_usage(modules_dmp_size) ram_usage = parser.get_ram_usage() - total_rom_used = parser.get_total_rom() + total_rom_used = parser.get_total_rom(modules_dmp_size) total_ram_used = parser.get_total_ram() # Get memory capacities From 6faeaa80e70921d1dd7bd98cab0e495f29208902 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:02:26 +0000 Subject: [PATCH 3/3] Add error handling and improve comments for modules.dmp size check Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- scripts/memory_report.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/memory_report.py b/scripts/memory_report.py index c330f26..ffb198f 100755 --- a/scripts/memory_report.py +++ b/scripts/memory_report.py @@ -160,7 +160,7 @@ def get_rom_usage(self, modules_dmp_size: int = 0) -> Dict[str, int]: """Calculate ROM (Flash) usage Args: - modules_dmp_size: Size of modules.dmp file if it exists + modules_dmp_size: Size of modules.dmp file if it exists (0 if not present) """ rom_usage = {} @@ -170,7 +170,7 @@ def get_rom_usage(self, modules_dmp_size: int = 0) -> Dict[str, int]: for lib_name, sections in library_usage.items(): rom_usage[lib_name] = sections['text'] + sections['rodata'] - # Add modules.dmp size if provided + # Add modules.dmp size if file exists (size > 0) if modules_dmp_size > 0: rom_usage['modules.dmp'] = modules_dmp_size @@ -204,7 +204,7 @@ def get_total_rom(self, modules_dmp_size: int = 0) -> int: """Get total ROM usage Args: - modules_dmp_size: Size of modules.dmp file if it exists + modules_dmp_size: Size of modules.dmp file if it exists (0 if not present) """ total = 0 if 'text' in self.sections: @@ -214,7 +214,7 @@ def get_total_rom(self, modules_dmp_size: int = 0) -> int: if 'data' in self.sections: # .data is stored in ROM but copied to RAM total += self.sections['data']['size'] - # Add modules.dmp size if provided + # Add modules.dmp size if provided (0 is safe to add) total += modules_dmp_size return total @@ -398,8 +398,11 @@ def main(): modules_dmp_path = Path(output_dir) / "modules.dmp" modules_dmp_size = 0 if modules_dmp_path.exists(): - modules_dmp_size = modules_dmp_path.stat().st_size - print(f"Found modules.dmp: {format_size(modules_dmp_size)}") + try: + modules_dmp_size = modules_dmp_path.stat().st_size + print(f"Found modules.dmp: {format_size(modules_dmp_size)}") + except (OSError, PermissionError) as e: + print(f"Warning: Could not read modules.dmp size: {e}") # Get memory usage rom_usage = parser.get_rom_usage(modules_dmp_size)