Skip to content

Commit

Permalink
Merge branch 'refine/ota_image_bundle' of github.com:tier4/ota-client…
Browse files Browse the repository at this point in the history
… into refine/ota_image_bundle
  • Loading branch information
obi-t4 committed Dec 26, 2023
2 parents 707857c + 9abd24f commit ced541c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 6 additions & 5 deletions tools/images_packer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ This image builder requires latest ota-client to be installed/accessable. The re
```bash
# current folder layout: venv ota-client
(venv) $ cd ota-client
(venv) $ sudo -E env PATH=$PATH python3 -m tools.image_packer build-cache-src --image-dir=./images_dir --output=t2.tar
(venv) $ sudo -E env PATH=$PATH python3 -m tools.images_packer build-cache-src --image-dir=./images_dir --output=t2.tar
```

This will build the external cache source image with images listed in `./images_dir`, and export the built image as `t2.tar` tar archive.
Expand All @@ -143,17 +143,17 @@ This will build the external cache source image with images listed in `./images_
```bash
# current folder layout: venv ota-client
(venv) $ cd ota-client
(venv) $ sudo -E env PATH=$PATH python3 -m tools.image_packer build-offline-ota-imgs-bundle --image=p1:p1_image.tgz:ver_20230808 --image=p2:p2_image.tgz:ver_20230808 --output=t2.tar
(venv) $ sudo -E env PATH=$PATH python3 -m tools.images_packer build-offline-ota-imgs-bundle --image=p1:p1_image.tgz:ver_20230808 --image=p2:p2_image.tgz:ver_20230808 --output=t2.tar
```

This will build the offline OTA image with `p1_image.tgz` and `p2_image.tgz`, which are for ECU `p1` and `p2`, and export the built image as `t2.tar` tar archive.

#### Usage 3: Build the external cache source image and create external cache source dev
#### Usage 3: Build the external cache source image and create external cache source device

```bash
# current folder layout: venv ota-client
(venv) $ cd ota-client
(venv) $ sudo -E env PATH=$PATH python3 -m tools.image_packer build-cache-src --image-dir=./images_dir --write-to=/dev/<target_dev>
(venv) $ sudo -E env PATH=$PATH python3 -m tools.images_packer build-cache-src --image-dir=./images_dir --write-to=/dev/<target_dev>
```

This will build the external cache source image OTA images listed in the `./images_dir`, and prepare the `/dev/<target_dev>` as external cache source device(ext4 filesystem labelled with `ota_cache_src`) with image rootfs exported to the filesystem on `/dev/<target_device>`.
Expand Down Expand Up @@ -183,14 +183,15 @@ optional arguments:
### `build-offline-ota-imgs-bundle` subcommand

```text
usage: images_packer build-offline-ota-imgs-bundle [-h] --image <ECU_NAME>:<IMAGE_PATH>[:<IMAGE_VERSION>] [-o <OUTPUT_FILE_PATH>]
usage: images_packer build-offline-ota-imgs-bundle [-h] --image <ECU_NAME>:<IMAGE_PATH>[:<IMAGE_VERSION>] -o <OUTPUT_FILE_PATH>
build OTA image bundle for offline OTA use.
optional arguments:
-h, --help show this help message and exit
--image <ECU_NAME>:<IMAGE_PATH>[:<IMAGE_VERSION>]
OTA image for <ECU_ID> as tar archive(compressed or uncompressed), this option can be used multiple times to include multiple images.
NOTE: if multiple OTA target image is specified for the same ECU, the later one will override the previous set one.
-o <OUTPUT_FILE_PATH>, --output <OUTPUT_FILE_PATH>
save the generated image bundle tar archive to <OUTPUT_FILE_PATH>.
```
11 changes: 10 additions & 1 deletion tools/images_packer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def main_build_offline_ota_image_bundle(args: argparse.Namespace):
image_version=_image_version,
)
)
if _ecu_id in image_files:
logger.warning(
(
f"override previously set OTA target image for ECU@{_ecu_id} "
f"from {image_files[_ecu_id]} to {_image_fpath}"
)
)
image_files[_ecu_id] = _image_fpath
else:
logger.warning(f"ignore illegal image pair: {raw_pair}")
Expand Down Expand Up @@ -233,7 +240,9 @@ def command_build_offline_ota_image_bundle(
"--image",
help=(
"OTA image for <ECU_ID> as tar archive(compressed or uncompressed), "
"this option can be used multiple times to include multiple images."
"this option can be used multiple times to include multiple images. \n"
"NOTE: if multiple OTA target image is specified for the same ECU, the later one "
"will override the previous set one."
),
required=True,
metavar="<ECU_NAME>:<IMAGE_PATH>[:<IMAGE_VERSION>]",
Expand Down

0 comments on commit ced541c

Please sign in to comment.