From 4d365512d701292ad314bc07b9317c05734994e4 Mon Sep 17 00:00:00 2001 From: lucicop Date: Mon, 7 Feb 2022 17:28:22 +0200 Subject: [PATCH] Add OTA header generation when compiling (#14745) * Add OTA header generation when compiling * Correct path to qpg script * Restyled by gn * Fix gni to work even when OTA requestor is not defined Co-authored-by: Restyled.io --- third_party/qpg_sdk/qpg_executable.gni | 42 +++++++++++++++++++++++++- third_party/qpg_sdk/repo | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/third_party/qpg_sdk/qpg_executable.gni b/third_party/qpg_sdk/qpg_executable.gni index 068c857a6f9f16..21398b9d44075b 100644 --- a/third_party/qpg_sdk/qpg_executable.gni +++ b/third_party/qpg_sdk/qpg_executable.gni @@ -14,12 +14,26 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") import("${build_root}/toolchain/flashable_executable.gni") +import("${chip_root}/src/platform/device.gni") +import("${dir_pw_build}/python.gni") template("qpg_executable") { output_base_name = get_path_info(invoker.output_name, "name") + qpg_target_name = target_name + executable_target_name = "${target_name}.out" + if (chip_enable_ota_requestor) { + # Generate OTA image after executable + ota_target_name = "${target_name}_ota" + final_target = ota_target_name + } else { + # The executable is the final target. + final_target = executable_target_name + } + objcopy_image_name = invoker.output_name + ".hex" objcopy_image_format = "ihex" objcopy = "arm-none-eabi-objcopy" @@ -45,8 +59,34 @@ template("qpg_executable") { flashing_script_name = output_base_name + ".flash.py" flashing_options = [ "qpg" ] - flashable_executable(target_name) { + flashable_executable(executable_target_name) { forward_variables_from(invoker, "*") data_deps = [ ":${flashing_runtime_target}" ] } + + # If OTA requestor is enabled, generate OTA image from HEX + if (chip_enable_ota_requestor) { + pw_python_action(ota_target_name) { + public_deps = [ ":${qpg_target_name}.out.image" ] + sources = [ "${root_out_dir}/${objcopy_image_name}" ] + outputs = [ "${root_out_dir}/${objcopy_image_name}.ota" ] + script = + "${chip_root}/third_party/qpg_sdk/repo/Tools/ota/generate_ota_img.py" + out_dir = rebase_path(root_out_dir, root_build_dir) + + args = [ + rebase_path(chip_root, root_build_dir), + "${out_dir}/${invoker.output_name}.hex", + "${out_dir}/${invoker.output_name}.ota", + ] + } + } + + group(qpg_target_name) { + data_deps = [ ":$final_target" ] + + if (defined(invoker.data_deps)) { + data_deps += invoker.data_deps + } + } } diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index 2b463adb2a9323..e8b208b64acd70 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit 2b463adb2a9323fc54d435f359cd0f167845dfb1 +Subproject commit e8b208b64acd70da01780215164a270ca21935d2