Skip to content

Commit cbc7cd5

Browse files
tx2rxpull[bot]
authored andcommitted
[ASR] generate OTA image automatically (#27211)
* [ASR] generate OTA image automatically and update README * rename ota image action
1 parent af97245 commit cbc7cd5

File tree

2 files changed

+57
-17
lines changed

2 files changed

+57
-17
lines changed

examples/ota-requestor-app/asr/README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,23 @@ guides to get started
3030

3131
## Testing the example
3232

33-
- Make OTA image: Taking lighting-app as an example, light project must
34-
compiled before this operation:
33+
- After building a application, `*ota.bin` will generated automatically in the
34+
output directory.
35+
36+
- Use
37+
[ota_image_tool](https://github.com/project-chip/connectedhomeip/blob/master/src/app/ota_image_tool.py)
38+
to generate the Matter OTA image. This tool can be used as follows, make
39+
sure the softwareVersion parameter must be greater than the
40+
`CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION` parameter set in the
41+
application's CHIPProjectConfig.h file.
3542

3643
```
37-
third_party/asr/asr582x/asr_sdk/tools/otaImage/image_gen_header out/asr-asr582x-lighting/chip-asr-lighting-example.bin flash_remapping
44+
./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
3845
```
3946
40-
After that, `chip-asr-lighting-example.ota.bin` will generated in the
41-
directory `./out/asr-asr582x-lighting/`.
42-
4347
- Run the Linux OTA Provider with OTA image.
4448
```
45-
./chip-ota-provider-app -f chip-asr-lighting-example.ota.bin
49+
./chip-ota-provider-app -f matter_firmware_ota.bin
4650
```
4751
- OTA Provider commissioning in another Linux terminal.
4852
```
@@ -57,5 +61,5 @@ guides to get started
5761
- After OTA Requestor commissioning is successful, use `chip-tool` to inform
5862
OTA Provider to send OTA image to OTA Requestor.
5963
```
60-
./chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 <OTA REQUESTOR APP NODE ID> 0
64+
./chip-tool otasoftwareupdaterequestor announce-otaprovider 1 0 0 0 <OTA REQUESTOR APP NODE ID> 0
6165
```

third_party/asr/asr_executable.gni

+45-9
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,54 @@ template("asr_executable") {
2525

2626
if (asr_ic_family == "asr595x") {
2727
objcopy = "${asr_toolchain_root}riscv-asr-elf-objcopy"
28-
} else if (asr_ic_family == "asr582x") {
29-
objcopy = "${asr_toolchain_root}arm-none-eabi-objcopy"
3028
} else {
31-
objcopy = "objcopy"
29+
objcopy = "${asr_toolchain_root}arm-none-eabi-objcopy"
3230
}
3331

34-
#Copy flashing dependencies to the output directory so that the output
35-
#is collectively self-contained; this allows flashing to work reliably
36-
#even if the build and flashing steps take place on different machines
37-
#or in different containers.
38-
39-
flashable_executable(target_name) {
32+
flash_target_name = target_name + ".flash_executable"
33+
flashbundle_name = "${target_name}.flashbundle.txt"
34+
flashable_executable(flash_target_name) {
4035
forward_variables_from(invoker, "*")
4136
}
37+
38+
action("generate_ota_image") {
39+
script = "${build_root}/gn_run_binary.py"
40+
41+
outputs = [ "${root_out_dir}/${output_base_name}_ota.bin" ]
42+
43+
if (asr_ic_family == "asr595x") {
44+
gen_ota_tool = "${asr_sdk_build_root}/asr_sdk/tools/image_gen_header/image_gen_header"
45+
} else {
46+
gen_ota_tool =
47+
"${asr_sdk_build_root}/asr_sdk/tools/otaImage/image_gen_header"
48+
}
49+
50+
_ota_tool_path = rebase_path(gen_ota_tool, root_build_dir)
51+
52+
if (asr_ic_family == "asr595x") {
53+
args = [
54+
_ota_tool_path,
55+
"${root_out_dir}/${objcopy_image_name}",
56+
"-d",
57+
"LEGA_A0V2",
58+
"-b",
59+
"REMAPPING",
60+
]
61+
} else {
62+
args = [
63+
_ota_tool_path,
64+
"${root_out_dir}/${objcopy_image_name}",
65+
"flash_remapping",
66+
]
67+
}
68+
69+
deps = [ ":$flash_target_name" ]
70+
}
71+
72+
group(target_name) {
73+
deps = [
74+
":$flash_target_name",
75+
":generate_ota_image",
76+
]
77+
}
4278
}

0 commit comments

Comments
 (0)