Skip to content

Commit

Permalink
[ASR] generate OTA image automatically (#27211)
Browse files Browse the repository at this point in the history
* [ASR] generate OTA image automatically and update README

* rename ota image action
  • Loading branch information
tx2rx authored and pull[bot] committed Jul 10, 2023
1 parent 32cce94 commit 3cda314
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
20 changes: 12 additions & 8 deletions examples/ota-requestor-app/asr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Vendor ID> -p <Product ID> -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.
```
Expand All @@ -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 <OTA REQUESTOR APP NODE ID> 0
./chip-tool otasoftwareupdaterequestor announce-otaprovider 1 0 0 0 <OTA REQUESTOR APP NODE ID> 0
```
54 changes: 45 additions & 9 deletions third_party/asr/asr_executable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
}

0 comments on commit 3cda314

Please sign in to comment.