From 3cda3144c3dddd27467802bc7f8f8e259a2a1549 Mon Sep 17 00:00:00 2001 From: weicheng Date: Thu, 15 Jun 2023 21:05:19 +0800 Subject: [PATCH] [ASR] generate OTA image automatically (#27211) * [ASR] generate OTA image automatically and update README * rename ota image action --- examples/ota-requestor-app/asr/README.md | 20 +++++---- third_party/asr/asr_executable.gni | 54 ++++++++++++++++++++---- 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/examples/ota-requestor-app/asr/README.md b/examples/ota-requestor-app/asr/README.md index d0dcc9f7146554..d8d5b7f9de2d03 100755 --- a/examples/ota-requestor-app/asr/README.md +++ b/examples/ota-requestor-app/asr/README.md @@ -30,19 +30,23 @@ guides to get started ## Testing the example -- Make OTA image: Taking lighting-app as an example, light project must - compiled before this operation: +- After building a application, `*ota.bin` will generated automatically in the + output directory. + +- Use + [ota_image_tool](https://github.com/project-chip/connectedhomeip/blob/master/src/app/ota_image_tool.py) + to generate the Matter OTA image. This tool can be used as follows, make + sure the softwareVersion parameter must be greater than the + `CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION` parameter set in the + application's CHIPProjectConfig.h file. ``` - third_party/asr/asr582x/asr_sdk/tools/otaImage/image_gen_header out/asr-asr582x-lighting/chip-asr-lighting-example.bin flash_remapping + ./src/app/ota_image_tool.py create -v -p -vn 2 -vs "2.0" -da sha256 application_ota.bin matter_firmware_ota.bin ``` - After that, `chip-asr-lighting-example.ota.bin` will generated in the - directory `./out/asr-asr582x-lighting/`. - - Run the Linux OTA Provider with OTA image. ``` - ./chip-ota-provider-app -f chip-asr-lighting-example.ota.bin + ./chip-ota-provider-app -f matter_firmware_ota.bin ``` - OTA Provider commissioning in another Linux terminal. ``` @@ -57,5 +61,5 @@ guides to get started - After OTA Requestor commissioning is successful, use `chip-tool` to inform OTA Provider to send OTA image to OTA Requestor. ``` - ./chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 0 + ./chip-tool otasoftwareupdaterequestor announce-otaprovider 1 0 0 0 0 ``` diff --git a/third_party/asr/asr_executable.gni b/third_party/asr/asr_executable.gni index 8347b02ef77265..0be41a4b120e8d 100644 --- a/third_party/asr/asr_executable.gni +++ b/third_party/asr/asr_executable.gni @@ -25,18 +25,54 @@ template("asr_executable") { if (asr_ic_family == "asr595x") { objcopy = "${asr_toolchain_root}riscv-asr-elf-objcopy" - } else if (asr_ic_family == "asr582x") { - objcopy = "${asr_toolchain_root}arm-none-eabi-objcopy" } else { - objcopy = "objcopy" + objcopy = "${asr_toolchain_root}arm-none-eabi-objcopy" } - #Copy flashing dependencies to the output directory so that the output - #is collectively self-contained; this allows flashing to work reliably - #even if the build and flashing steps take place on different machines - #or in different containers. - - 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, "*") } + + action("generate_ota_image") { + script = "${build_root}/gn_run_binary.py" + + outputs = [ "${root_out_dir}/${output_base_name}_ota.bin" ] + + if (asr_ic_family == "asr595x") { + gen_ota_tool = "${asr_sdk_build_root}/asr_sdk/tools/image_gen_header/image_gen_header" + } else { + gen_ota_tool = + "${asr_sdk_build_root}/asr_sdk/tools/otaImage/image_gen_header" + } + + _ota_tool_path = rebase_path(gen_ota_tool, root_build_dir) + + if (asr_ic_family == "asr595x") { + args = [ + _ota_tool_path, + "${root_out_dir}/${objcopy_image_name}", + "-d", + "LEGA_A0V2", + "-b", + "REMAPPING", + ] + } else { + args = [ + _ota_tool_path, + "${root_out_dir}/${objcopy_image_name}", + "flash_remapping", + ] + } + + deps = [ ":$flash_target_name" ] + } + + group(target_name) { + deps = [ + ":$flash_target_name", + ":generate_ota_image", + ] + } }