From 69203d30f180438e8bec3b27f40b9160098830bb Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Fri, 20 Jul 2018 10:53:00 -0500 Subject: [PATCH] Create update images with managed bl mode --- tools/build_api.py | 23 +++++++++++++++++++++-- tools/make.py | 39 ++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/tools/build_api.py b/tools/build_api.py index 0b127700ac..898339ceb7 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -446,6 +446,12 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'): merged.tofile(destination, format=format.strip(".")) +UPDATE_WHITELIST = ( + "application", + "header", +) + + def build_project(src_paths, build_path, target, toolchain_name, libraries_paths=None, linker_script=None, clean=False, notify=None, name=None, macros=None, inc_dirs=None, jobs=1, @@ -532,15 +538,28 @@ def build_project(src_paths, build_path, target, toolchain_name, # Link Program if toolchain.config.has_regions: - res, _ = toolchain.link_program(resources, build_path, name + "_application") + binary, _ = toolchain.link_program(resources, build_path, name + "_application") region_list = list(toolchain.config.regions) - region_list = [r._replace(filename=res) if r.active else r + region_list = [r._replace(filename=binary) if r.active else r for r in region_list] res = "%s.%s" % (join(build_path, name), getattr(toolchain.target, "OUTPUT_EXT", "bin")) merge_region_list(region_list, res, notify) + update_regions = [ + r for r in region_list if r.name in UPDATE_WHITELIST + ] + if update_regions: + update_res = "%s_update.%s" % ( + join(build_path, name), + getattr(toolchain.target, "OUTPUT_EXT", "bin") + ) + merge_region_list(update_regions, update_res, notify) + res = (res, update_res) + else: + res = (res, None) else: res, _ = toolchain.link_program(resources, build_path, name) + res = (res, None) memap_instance = getattr(toolchain, 'memap_instance', None) memap_table = '' diff --git a/tools/make.py b/tools/make.py index 94f910d360..d59c5badf8 100644 --- a/tools/make.py +++ b/tools/make.py @@ -273,23 +273,28 @@ if __name__ == '__main__': build_dir = options.build_dir try: - bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, - set(test.dependencies), - linker_script=options.linker_script, - clean=options.clean, - notify=notify, - report=build_data_blob, - macros=options.macros, - jobs=options.jobs, - name=options.artifact_name, - app_config=options.app_config, - inc_dirs=[dirname(MBED_LIBRARIES)], - build_profile=extract_profile(parser, - options, - toolchain), - stats_depth=options.stats_depth, - ignore=options.ignore) - print('Image: %s'% bin_file) + bin_file, update_file = build_project( + test.source_dir, + build_dir, + mcu, + toolchain, + set(test.dependencies), + linker_script=options.linker_script, + clean=options.clean, + notify=notify, + report=build_data_blob, + macros=options.macros, + jobs=options.jobs, + name=options.artifact_name, + app_config=options.app_config, + inc_dirs=[dirname(MBED_LIBRARIES)], + build_profile=extract_profile(parser, options, toolchain), + stats_depth=options.stats_depth, + ignore=options.ignore + ) + if update_file: + print('Update Image: %s' % update_file) + print('Image: %s' % bin_file) if options.disk: # Simple copy to the mbed disk