scripts: fix ram_reports and generate bin file if missing
Some boards do not generate .bin files by default, this file is however needed when generating ram/rom reports, so in case it is not present, create it. Fixes #5784 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
aee2ff526d
commit
de311407bd
2 changed files with 14 additions and 7 deletions
|
@ -8,6 +8,7 @@ foreach(report ram_report rom_report)
|
||||||
${ZEPHYR_BASE}/scripts/footprint/size_report
|
${ZEPHYR_BASE}/scripts/footprint/size_report
|
||||||
${flag_for_${report}}
|
${flag_for_${report}}
|
||||||
--objdump ${CMAKE_OBJDUMP}
|
--objdump ${CMAKE_OBJDUMP}
|
||||||
|
--objcopy ${CMAKE_OBJCOPY}
|
||||||
--nm ${CMAKE_NM}
|
--nm ${CMAKE_NM}
|
||||||
-o ${PROJECT_BINARY_DIR}
|
-o ${PROJECT_BINARY_DIR}
|
||||||
DEPENDS ${logical_target_for_zephyr_elf}
|
DEPENDS ${logical_target_for_zephyr_elf}
|
||||||
|
|
|
@ -31,6 +31,8 @@ parser.add_option("-F", "--rom",
|
||||||
help="print ROM statistics")
|
help="print ROM statistics")
|
||||||
parser.add_option("-s", "--objdump", type="string", dest="bin_objdump",
|
parser.add_option("-s", "--objdump", type="string", dest="bin_objdump",
|
||||||
help="Path to the GNU binary utility objdump")
|
help="Path to the GNU binary utility objdump")
|
||||||
|
parser.add_option("-c", "--objcopy", type="string", dest="bin_objcopy",
|
||||||
|
help="Path to the GNU binary utility objcopy")
|
||||||
parser.add_option("-n", "--nm", type="string", dest="bin_nm",
|
parser.add_option("-n", "--nm", type="string", dest="bin_nm",
|
||||||
help="Path to the GNU binary utility nm")
|
help="Path to the GNU binary utility nm")
|
||||||
|
|
||||||
|
@ -406,14 +408,18 @@ def print_tree(data, total, depth):
|
||||||
print('{:92d}'.format(total))
|
print('{:92d}'.format(total))
|
||||||
return totp
|
return totp
|
||||||
|
|
||||||
|
bin_file = os.path.join(options.outdir, options.binary + ".bin")
|
||||||
|
stat_file = os.path.join(options.outdir, options.binary + ".stat")
|
||||||
|
elf_file = os.path.join(options.outdir, options.binary + ".elf")
|
||||||
|
|
||||||
binary = os.path.join(options.outdir, options.binary + ".elf")
|
if not os.path.exists(bin_file):
|
||||||
|
FNULL = open(os.devnull, 'w')
|
||||||
|
subprocess.call([options.bin_objcopy,"-S", "-Obinary", "-R", ".comment", "-R",
|
||||||
|
"COMMON", "-R", ".eh_frame", elf_file, bin_file],
|
||||||
|
stdout=FNULL, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
if options.outdir and os.path.exists(binary):
|
if options.outdir and os.path.exists(elf_file):
|
||||||
fp = get_footprint_from_bin_and_statfile(
|
fp = get_footprint_from_bin_and_statfile(bin_file, stat_file, 0, 0)
|
||||||
"%s/%s.bin" % (options.outdir, options.binary),
|
|
||||||
"%s/%s.stat" % (options.outdir, options.binary),
|
|
||||||
0, 0)
|
|
||||||
base = os.environ['ZEPHYR_BASE']
|
base = os.environ['ZEPHYR_BASE']
|
||||||
ram, data = generate_target_memory_section(
|
ram, data = generate_target_memory_section(
|
||||||
options.bin_objdump, options.bin_nm, options.outdir, options.binary,
|
options.bin_objdump, options.bin_nm, options.outdir, options.binary,
|
||||||
|
@ -424,4 +430,4 @@ if options.outdir and os.path.exists(binary):
|
||||||
print_tree(ram, fp['total_ram'], options.depth)
|
print_tree(ram, fp['total_ram'], options.depth)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("%s does not exist." % (binary))
|
print("%s does not exist." % (elf_file))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue