Skip to content
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

Take OUTPUT_EXT into account in managed bl #6007

Merged
merged 2 commits into from Feb 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions tools/build_api.py
Expand Up @@ -346,6 +346,7 @@ def merge_region_list(region_list, destination, padding=b'\xFF'):
padding - bytes to fill gapps with
"""
merged = IntelHex()
_, format = splitext(destination)

print("Merging Regions:")

Expand All @@ -363,14 +364,18 @@ def merge_region_list(region_list, destination, padding=b'\xFF'):
pad_size = region.size - part_size
if pad_size > 0 and region != region_list[-1]:
print(" Padding region %s with 0x%x bytes" % (region.name, pad_size))
merged.puts(merged.maxaddr() + 1, padding * pad_size)
if format is ".hex":
"""The offset will be in the hex file generated when we're done,
so we can skip padding here"""
else:
merged.puts(merged.maxaddr() + 1, padding * pad_size)

if not exists(dirname(destination)):
makedirs(dirname(destination))
print("Space used after regions merged: 0x%x" %
(merged.maxaddr() - merged.minaddr() + 1))
with open(destination, "wb+") as output:
merged.tofile(output, format='bin')
merged.tofile(output, format=format.strip("."))

def scan_resources(src_paths, toolchain, dependencies_paths=None,
inc_dirs=None, base_path=None, collect_ignores=False):
Expand Down Expand Up @@ -512,7 +517,8 @@ def build_project(src_paths, build_path, target, toolchain_name,
region_list = list(toolchain.config.regions)
region_list = [r._replace(filename=res) if r.active else r
for r in region_list]
res = join(build_path, name) + ".bin"
res = "%s.%s" % (join(build_path, name),
getattr(toolchain.target, "OUTPUT_EXT", "bin"))
merge_region_list(region_list, res)
else:
res, _ = toolchain.link_program(resources, build_path, name)
Expand Down