diff --git a/cmake/reports/CMakeLists.txt b/cmake/reports/CMakeLists.txt old mode 100644 new mode 100755 index 41c1b708732..2afa4446803 --- a/cmake/reports/CMakeLists.txt +++ b/cmake/reports/CMakeLists.txt @@ -5,6 +5,16 @@ set(flag_for_rom_report rom) set(flag_for_footprint all) set(report_depth 99) +if(CONFIG_REPORT_LOWEST_LIMIT) + set(REPORT_LOWEST_LIMIT ${CONFIG_REPORT_LOWEST_LIMIT}) +else() + set(REPORT_LOWEST_LIMIT 0) +endif() +if(CONFIG_REPORT_MAX_ITEMS) + set(REPORT_MAX_ITEMS ${CONFIG_REPORT_MAX_ITEMS}) +else() + set(REPORT_MAX_ITEMS 0) +endif() if(DEFINED ZEPHYR_WORKSPACE) set(workspace_arg "--workspace=${ZEPHYR_WORKSPACE}") elseif(DEFINED WEST_TOPDIR) @@ -21,6 +31,8 @@ foreach(report ram_report rom_report) -o ${CMAKE_BINARY_DIR} ${workspace_arg} -d ${report_depth} + -l ${REPORT_LOWEST_LIMIT} + -m ${REPORT_MAX_ITEMS} ${flag_for_${report}} DEPENDS ${logical_target_for_zephyr_elf} $ diff --git a/scripts/footprint/size_report b/scripts/footprint/size_report index 256b516cc38..e333bcbb0a7 100755 --- a/scripts/footprint/size_report +++ b/scripts/footprint/size_report @@ -752,6 +752,12 @@ def print_any_tree(root, total_size, depth): """ Print the symbol tree. """ + global args + maxItems = None + + if args.maxItems and args.maxItems != 0: + maxItems = args.maxItems + print('{:98s} {:>7s} {:>7s} {:11s} {:16s}'.format( Fore.YELLOW + "Path", "Size", "%", " Address", "Section" + Fore.RESET)) print('=' * 138) @@ -760,6 +766,19 @@ def print_any_tree(root, total_size, depth): s = str(row.node._size).rjust(100-f) percent = 100 * float(row.node._size) / float(total_size) + if args.lowestLimit and args.lowestLimit != 0: + # If the current symbol's footprint percentage is below the threshold -> skip it + if percent < args.lowestLimit: + continue + + # Only print as many items as the user configured + if args.maxItems and args.maxItems != 0: + maxItems -= 1 + + if maxItems < 0: + break + + hex_addr = "-" section_name = "" cc = cr = "" @@ -805,6 +824,10 @@ def parse_args(): parser.add_argument("-v", "--verbose", action="store_true", help="Print extra debugging information") parser.add_argument("--json", help="store results in a JSON file.") + parser.add_argument("-l", "--lowestLimit", dest="lowestLimit", + type=int, default=0, help="set what percentage is the lowest limit for printing a symbol.") + parser.add_argument("-m", "--maxItems", dest="maxItems", + type=int, default=0, help="how many items in total should the script print.") args = parser.parse_args()