Skip to content

Commit c180324

Browse files
committed
Configure boot loader after scanning
1 parent 855d74a commit c180324

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

tools/build_api.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,26 +284,20 @@ def get_mbed_official_release(version):
284284

285285
return mbed_official_release
286286

287-
def add_regions_to_profile(profile, config, toolchain_class):
287+
def add_regions_to_toolchain(toolchain):
288288
"""Add regions to the build profile, if there are any.
289289
290290
Positional Arguments:
291-
profile - the profile to update
292-
config - the configuration object that owns the region
293-
toolchain_class - the class of the toolchain being used
291+
toolchain - the toolchain to add the region defines to
294292
"""
295-
if not profile:
296-
return
297-
regions = list(config.regions)
293+
regions = list(toolchain.config.regions)
298294
for region in regions:
299295
for define in [(region.name.upper() + "_ADDR", region.start),
300296
(region.name.upper() + "_SIZE", region.size)]:
301-
profile["common"].append("-D%s=0x%x" % define)
302-
active_region = [r for r in regions if r.active][0]
303-
for define in [("MBED_APP_START", active_region.start),
304-
("MBED_APP_SIZE", active_region.size)]:
305-
profile["ld"].append(toolchain_class.make_ld_define(*define))
306-
297+
toolchain.cc.append("-D%s=0x%x" % define)
298+
toolchain.cppc.append("-D%s=0x%x" % define)
299+
if region.active:
300+
toolchain.ld.append(toolchain.make_ld_define(*define))
307301
print("Using regions in this build:")
308302
for region in regions:
309303
print(" Region %s size 0x%x, offset 0x%x"
@@ -352,9 +346,6 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
352346
for key in profile:
353347
profile[key].extend(contents[toolchain_name][key])
354348

355-
if config.has_regions:
356-
add_regions_to_profile(profile, config, cur_tc)
357-
358349
toolchain = cur_tc(target, notify, macros, silent, build_dir=build_dir,
359350
extra_verbose=extra_verbose, build_profile=profile)
360351

@@ -439,6 +430,9 @@ def scan_resources(src_paths, toolchain, dependencies_paths=None,
439430
# Set the toolchain's configuration data
440431
toolchain.set_config_data(toolchain.config.get_config_data())
441432

433+
if toolchain.config.has_regions:
434+
add_regions_to_toolchain(toolchain)
435+
442436
if (hasattr(toolchain.target, "release_versions") and
443437
"5" not in toolchain.target.release_versions and
444438
"rtos" in toolchain.config.lib_config_data):

tools/config/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,17 +685,19 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
685685

686686
# Consider the others as overrides
687687
for name, val in overrides.items():
688+
if (name.startswith("target.") and
689+
(unit_kind is "application" or
690+
name in self.__unused_overrides)):
691+
_, attribute = name.split(".")
692+
setattr(self.target, attribute, val)
693+
continue
694+
688695
# Get the full name of the parameter
689696
full_name = ConfigParameter.get_full_name(name, unit_name,
690697
unit_kind, label)
691698
if full_name in params:
692699
params[full_name].set_value(val, unit_name, unit_kind,
693700
label)
694-
elif (name.startswith("target.") and
695-
unit_kind is "application" or
696-
name in self.__unused_overrides):
697-
_, attribute = name.split(".")
698-
setattr(self.target, attribute, val)
699701
else:
700702
self.config_errors.append(
701703
ConfigException(

0 commit comments

Comments
 (0)