Skip to content

Commit fcf7dbf

Browse files
committed
Use notification API in BL modes
1 parent 85e33b4 commit fcf7dbf

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

tools/build_api.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def _fill_header(region_list, current_region):
397397
start += Config.header_member_size(member)
398398
return header
399399

400-
def merge_region_list(region_list, destination, padding=b'\xFF'):
400+
def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
401401
"""Merge the region_list into a single image
402402
403403
Positional Arguments:
@@ -408,7 +408,7 @@ def merge_region_list(region_list, destination, padding=b'\xFF'):
408408
merged = IntelHex()
409409
_, format = splitext(destination)
410410

411-
print("Merging Regions:")
411+
notify.info("Merging Regions")
412412

413413
for region in region_list:
414414
if region.active and not region.filename:
@@ -419,7 +419,7 @@ def merge_region_list(region_list, destination, padding=b'\xFF'):
419419
_fill_header(region_list, region).tofile(header_filename, format='hex')
420420
region = region._replace(filename=header_filename)
421421
if region.filename:
422-
print(" Filling region %s with %s" % (region.name, region.filename))
422+
notify.info(" Filling region %s with %s" % (region.name, region.filename))
423423
part = intelhex_offset(region.filename, offset=region.start)
424424
part_size = (part.maxaddr() - part.minaddr()) + 1
425425
if part_size > region.size:
@@ -428,7 +428,8 @@ def merge_region_list(region_list, destination, padding=b'\xFF'):
428428
merged.merge(part)
429429
pad_size = region.size - part_size
430430
if pad_size > 0 and region != region_list[-1]:
431-
print(" Padding region %s with 0x%x bytes" % (region.name, pad_size))
431+
notify.info(" Padding region %s with 0x%x bytes" %
432+
(region.name, pad_size))
432433
if format is ".hex":
433434
"""The offset will be in the hex file generated when we're done,
434435
so we can skip padding here"""
@@ -437,8 +438,8 @@ def merge_region_list(region_list, destination, padding=b'\xFF'):
437438

438439
if not exists(dirname(destination)):
439440
makedirs(dirname(destination))
440-
print("Space used after regions merged: 0x%x" %
441-
(merged.maxaddr() - merged.minaddr() + 1))
441+
notify.info("Space used after regions merged: 0x%x" %
442+
(merged.maxaddr() - merged.minaddr() + 1))
442443
with open(destination, "wb+") as output:
443444
merged.tofile(output, format=format.strip("."))
444445

@@ -574,7 +575,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
574575
for r in region_list]
575576
res = "%s.%s" % (join(build_path, name),
576577
getattr(toolchain.target, "OUTPUT_EXT", "bin"))
577-
merge_region_list(region_list, res)
578+
merge_region_list(region_list, res, notify)
578579
else:
579580
res, _ = toolchain.link_program(resources, build_path, name)
580581

tools/toolchains/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,8 +1148,10 @@ def mem_stats(self, map):
11481148
def add_regions(self):
11491149
"""Add regions to the build profile, if there are any.
11501150
"""
1151-
print("Using regions in this build:")
1152-
for region in self.config.regions:
1151+
regions = list(self.config.regions)
1152+
self.notify.info("Using regions %s in this build."
1153+
% ", ".join(region.name for region in regions))
1154+
for region in regions:
11531155
for define in [(region.name.upper() + "_ADDR", region.start),
11541156
(region.name.upper() + "_SIZE", region.size)]:
11551157
define_string = "-D%s=0x%x" % define
@@ -1162,8 +1164,8 @@ def add_regions(self):
11621164
define_string = self.make_ld_define(*define)
11631165
self.ld.append(define_string)
11641166
self.flags["ld"].append(define_string)
1165-
print(" Region %s size 0x%x, offset 0x%x"
1166-
% (region.name, region.size, region.start))
1167+
self.notify.info(" Region %s: size 0x%x, offset 0x%x"
1168+
% (region.name, region.size, region.start))
11671169

11681170
# Set the configuration data
11691171
def set_config_data(self, config_data):

0 commit comments

Comments
 (0)