Skip to content

Commit 69203d3

Browse files
committed
Create update images with managed bl mode
1 parent 4bcca89 commit 69203d3

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

tools/build_api.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,12 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
446446
merged.tofile(destination, format=format.strip("."))
447447

448448

449+
UPDATE_WHITELIST = (
450+
"application",
451+
"header",
452+
)
453+
454+
449455
def build_project(src_paths, build_path, target, toolchain_name,
450456
libraries_paths=None, linker_script=None, clean=False,
451457
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,
532538

533539
# Link Program
534540
if toolchain.config.has_regions:
535-
res, _ = toolchain.link_program(resources, build_path, name + "_application")
541+
binary, _ = toolchain.link_program(resources, build_path, name + "_application")
536542
region_list = list(toolchain.config.regions)
537-
region_list = [r._replace(filename=res) if r.active else r
543+
region_list = [r._replace(filename=binary) if r.active else r
538544
for r in region_list]
539545
res = "%s.%s" % (join(build_path, name),
540546
getattr(toolchain.target, "OUTPUT_EXT", "bin"))
541547
merge_region_list(region_list, res, notify)
548+
update_regions = [
549+
r for r in region_list if r.name in UPDATE_WHITELIST
550+
]
551+
if update_regions:
552+
update_res = "%s_update.%s" % (
553+
join(build_path, name),
554+
getattr(toolchain.target, "OUTPUT_EXT", "bin")
555+
)
556+
merge_region_list(update_regions, update_res, notify)
557+
res = (res, update_res)
558+
else:
559+
res = (res, None)
542560
else:
543561
res, _ = toolchain.link_program(resources, build_path, name)
562+
res = (res, None)
544563

545564
memap_instance = getattr(toolchain, 'memap_instance', None)
546565
memap_table = ''

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

0 commit comments

Comments
 (0)