Skip to content

Commit 8755e56

Browse files
author
Cruz Monrreal
authored
Merge pull request #7567 from theotherjimmy/managed-update-image
Tools: Generate update images with managed bl mode
2 parents 5d4f636 + 8be6a03 commit 8755e56

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

tools/build_api.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,12 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
448448
merged.tofile(destination, format=format.strip("."))
449449

450450

451+
UPDATE_WHITELIST = (
452+
"application",
453+
"header",
454+
)
455+
456+
451457
def build_project(src_paths, build_path, target, toolchain_name,
452458
libraries_paths=None, linker_script=None, clean=False,
453459
notify=None, name=None, macros=None, inc_dirs=None, jobs=1,
@@ -534,15 +540,28 @@ def build_project(src_paths, build_path, target, toolchain_name,
534540

535541
# Link Program
536542
if toolchain.config.has_regions:
537-
res, _ = toolchain.link_program(resources, build_path, name + "_application")
543+
binary, _ = toolchain.link_program(resources, build_path, name + "_application")
538544
region_list = list(toolchain.config.regions)
539-
region_list = [r._replace(filename=res) if r.active else r
545+
region_list = [r._replace(filename=binary) if r.active else r
540546
for r in region_list]
541547
res = "%s.%s" % (join(build_path, name),
542548
getattr(toolchain.target, "OUTPUT_EXT", "bin"))
543549
merge_region_list(region_list, res, notify)
550+
update_regions = [
551+
r for r in region_list if r.name in UPDATE_WHITELIST
552+
]
553+
if update_regions:
554+
update_res = "%s_update.%s" % (
555+
join(build_path, name),
556+
getattr(toolchain.target, "OUTPUT_EXT", "bin")
557+
)
558+
merge_region_list(update_regions, update_res, notify)
559+
res = (res, update_res)
560+
else:
561+
res = (res, None)
544562
else:
545563
res, _ = toolchain.link_program(resources, build_path, name)
564+
res = (res, None)
546565

547566
memap_instance = getattr(toolchain, 'memap_instance', None)
548567
memap_table = ''
@@ -570,8 +589,8 @@ def build_project(src_paths, build_path, target, toolchain_name,
570589
cur_result["result"] = "OK"
571590
cur_result["memory_usage"] = (memap_instance.mem_report
572591
if memap_instance is not None else None)
573-
cur_result["bin"] = res
574-
cur_result["elf"] = splitext(res)[0] + ".elf"
592+
cur_result["bin"] = res[0]
593+
cur_result["elf"] = splitext(res[0])[0] + ".elf"
575594
cur_result.update(toolchain.report)
576595

577596
add_result_to_report(report, cur_result)

tools/make.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,23 +273,28 @@
273273
build_dir = options.build_dir
274274

275275
try:
276-
bin_file = build_project(test.source_dir, build_dir, mcu, toolchain,
277-
set(test.dependencies),
278-
linker_script=options.linker_script,
279-
clean=options.clean,
280-
notify=notify,
281-
report=build_data_blob,
282-
macros=options.macros,
283-
jobs=options.jobs,
284-
name=options.artifact_name,
285-
app_config=options.app_config,
286-
inc_dirs=[dirname(MBED_LIBRARIES)],
287-
build_profile=extract_profile(parser,
288-
options,
289-
toolchain),
290-
stats_depth=options.stats_depth,
291-
ignore=options.ignore)
292-
print('Image: %s'% bin_file)
276+
bin_file, update_file = build_project(
277+
test.source_dir,
278+
build_dir,
279+
mcu,
280+
toolchain,
281+
set(test.dependencies),
282+
linker_script=options.linker_script,
283+
clean=options.clean,
284+
notify=notify,
285+
report=build_data_blob,
286+
macros=options.macros,
287+
jobs=options.jobs,
288+
name=options.artifact_name,
289+
app_config=options.app_config,
290+
inc_dirs=[dirname(MBED_LIBRARIES)],
291+
build_profile=extract_profile(parser, options, toolchain),
292+
stats_depth=options.stats_depth,
293+
ignore=options.ignore
294+
)
295+
if update_file:
296+
print('Update Image: %s' % update_file)
297+
print('Image: %s' % bin_file)
293298

294299
if options.disk:
295300
# Simple copy to the mbed disk

tools/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ def build_test_worker(*args, **kwargs):
21742174
del kwargs['toolchain_paths']
21752175

21762176
try:
2177-
bin_file = build_project(*args, **kwargs)
2177+
bin_file, _ = build_project(*args, **kwargs)
21782178
ret['result'] = True
21792179
ret['bin_file'] = bin_file
21802180
ret['kwargs'] = kwargs

0 commit comments

Comments
 (0)