Skip to content

Commit 3824083

Browse files
rgoliverpull[bot]
rgoliver
authored andcommitted
EFR32: Add hex binary to build output (#12809)
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.
1 parent eeb0354 commit 3824083

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

build/toolchain/flashable_executable.gni

+8-1
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,21 @@ template("flashable_executable") {
9696
# The executable is the final target.
9797
final_target = executable_target
9898
}
99+
100+
if (defined(invoker.flashbundle_name)) {
101+
flashbundle_name = invoker.flashbundle_name
102+
} else {
103+
flashbundle_name = "${target_name}.flashbundle.txt"
104+
}
105+
99106
group(target_name) {
100107
data_deps = [ ":$final_target" ]
101108

102109
if (defined(invoker.data_deps)) {
103110
data_deps += invoker.data_deps
104111
}
105112

106-
write_runtime_deps = "${root_out_dir}/${target_name}.flashbundle.txt"
113+
write_runtime_deps = "${root_out_dir}/${flashbundle_name}"
107114
}
108115

109116
if (defined(invoker.objcopy_image_name)) {

scripts/build/builders/efr32.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,18 @@ def GnBuildArgs(self):
118118
return args
119119

120120
def build_outputs(self):
121-
items = {
122-
'%s.out' % self.app.AppNamePrefix():
123-
os.path.join(self.output_dir, '%s.out' %
124-
self.app.AppNamePrefix()),
125-
'%s.out.map' % self.app.AppNamePrefix():
126-
os.path.join(self.output_dir,
127-
'%s.out.map' % self.app.AppNamePrefix()),
128-
}
121+
items = {}
122+
for extension in ["out", "out.map", "hex"]:
123+
name = '%s.%s' % (self.app.AppNamePrefix(), extension)
124+
items[name] = os.path.join(self.output_dir, name)
129125

130126
if self.app == Efr32App.UNIT_TEST:
131127
# Include test runner python wheels
132128
for root, dirs, files in os.walk(os.path.join(self.output_dir, 'chip_nl_test_runner_wheels')):
133129
for file in files:
134130
items["chip_nl_test_runner_wheels/" +
135131
file] = os.path.join(root, file)
132+
136133
# Figure out flash bundle files and build accordingly
137134
with open(os.path.join(self.output_dir, self.app.FlashBundleName())) as f:
138135
for line in f.readlines():

third_party/efr32_sdk/efr32_executable.gni

+21-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,28 @@ template("efr32_executable") {
4444
flashing_script_name = output_base_name + ".flash.py"
4545
flashing_options = [ "efr32" ]
4646

47-
flashable_executable(target_name) {
47+
flash_target_name = target_name + ".flash_executable"
48+
flashbundle_name = "${target_name}.flashbundle.txt"
49+
flashable_executable(flash_target_name) {
4850
forward_variables_from(invoker, "*")
4951
data_deps = [ ":${flashing_runtime_target}" ]
5052
}
53+
54+
# Add a target which generates the hex file in addition to s37.
55+
executable_target = "$flash_target_name.executable"
56+
hex_image_name = output_base_name + ".hex"
57+
hex_target_name = target_name + ".hex"
58+
objcopy_convert(hex_target_name) {
59+
conversion_input = "${root_out_dir}/${invoker.output_name}"
60+
conversion_output = "${root_out_dir}/${hex_image_name}"
61+
conversion_target_format = "ihex"
62+
deps = [ ":$executable_target" ]
63+
}
64+
65+
group(target_name) {
66+
deps = [
67+
":$flash_target_name",
68+
":$hex_target_name",
69+
]
70+
}
5171
}

0 commit comments

Comments
 (0)