Skip to content

Commit

Permalink
EFR32: Add hex binary to build output (#12809)
Browse files Browse the repository at this point in the history
Add a gn action which provides a hex binary in addition to the s37.
The hex binary can be flashed with jlink and doesn't require
commander to be installed, and is therefore an easier format for use
in test automation.
  • Loading branch information
rgoliver authored and pull[bot] committed Dec 16, 2021
1 parent 630e87e commit 1589500
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
9 changes: 8 additions & 1 deletion build/toolchain/flashable_executable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,21 @@ template("flashable_executable") {
# The executable is the final target.
final_target = executable_target
}

if (defined(invoker.flashbundle_name)) {
flashbundle_name = invoker.flashbundle_name
} else {
flashbundle_name = "${target_name}.flashbundle.txt"
}

group(target_name) {
data_deps = [ ":$final_target" ]

if (defined(invoker.data_deps)) {
data_deps += invoker.data_deps
}

write_runtime_deps = "${root_out_dir}/${target_name}.flashbundle.txt"
write_runtime_deps = "${root_out_dir}/${flashbundle_name}"
}

if (defined(invoker.objcopy_image_name)) {
Expand Down
13 changes: 5 additions & 8 deletions scripts/build/builders/efr32.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,18 @@ def GnBuildArgs(self):
return args

def build_outputs(self):
items = {
'%s.out' % self.app.AppNamePrefix():
os.path.join(self.output_dir, '%s.out' %
self.app.AppNamePrefix()),
'%s.out.map' % self.app.AppNamePrefix():
os.path.join(self.output_dir,
'%s.out.map' % self.app.AppNamePrefix()),
}
items = {}
for extension in ["out", "out.map", "hex"]:
name = '%s.%s' % (self.app.AppNamePrefix(), extension)
items[name] = os.path.join(self.output_dir, name)

if self.app == Efr32App.UNIT_TEST:
# Include test runner python wheels
for root, dirs, files in os.walk(os.path.join(self.output_dir, 'chip_nl_test_runner_wheels')):
for file in files:
items["chip_nl_test_runner_wheels/" +
file] = os.path.join(root, file)

# Figure out flash bundle files and build accordingly
with open(os.path.join(self.output_dir, self.app.FlashBundleName())) as f:
for line in f.readlines():
Expand Down
22 changes: 21 additions & 1 deletion third_party/efr32_sdk/efr32_executable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,28 @@ template("efr32_executable") {
flashing_script_name = output_base_name + ".flash.py"
flashing_options = [ "efr32" ]

flashable_executable(target_name) {
flash_target_name = target_name + ".flash_executable"
flashbundle_name = "${target_name}.flashbundle.txt"
flashable_executable(flash_target_name) {
forward_variables_from(invoker, "*")
data_deps = [ ":${flashing_runtime_target}" ]
}

# Add a target which generates the hex file in addition to s37.
executable_target = "$flash_target_name.executable"
hex_image_name = output_base_name + ".hex"
hex_target_name = target_name + ".hex"
objcopy_convert(hex_target_name) {
conversion_input = "${root_out_dir}/${invoker.output_name}"
conversion_output = "${root_out_dir}/${hex_image_name}"
conversion_target_format = "ihex"
deps = [ ":$executable_target" ]
}

group(target_name) {
deps = [
":$flash_target_name",
":$hex_target_name",
]
}
}

0 comments on commit 1589500

Please sign in to comment.