4.7.17. ota_tool
ota_tool is a command-line utility designed for OTA (Over-The-Air) update management on embedded devices. It supports features such as version checking, partition management, package signature verification, automatic updates, and forced updates, primarily used for firmware updates.
For detailed information about
ota_tool, please refer to the OTA Features and Introduction section.
4.7.17.1. Syntax Description
Below is the help information displayed when executing ota_tool:
ota_tool Usage:
-v, --version get this library's version, system version, antirollback version
-b, --boot check ota update status when boot.
-s, --setpartition [partition] set A/B slot partition, 0--A; 1--B.
-g, --getpartition get A/B slot partition, 0--A; 1--B.
-p, --package [package_path] specify the path of package, the package paths can be relative or absolute, it's length must be smaller than 64 bytes.
-n, --noreboot request ota without reboot.
-c, --checksign signature check.
-i, --signature signature information file.
-h, --help Display this help screen.
4.7.17.2. Parameter Options Description
-v, –version: Get the OTA library version, system version, and anti-rollback version.
-b, –boot: Check OTA update status during boot.
-s, –setpartition [partition]: Set the active partition (A/B partitions).
Parameters:
0: Indicates partition A.
1: Indicates partition B.
-g, –getpartition: Get the currently active partition (A/B partitions). Returns 0 or 1.
-p, –package [package_path]: Specify the path of the update package, which can be a relative or absolute path. The path length must be less than 64 bytes.
-n, –noreboot: Perform OTA update without automatically rebooting the device.
-c, –checksign: Perform signature verification to ensure the integrity and authenticity of the update package.
-i, –signature [signature_file]: Specify the path of the signature file for signature verification.
-h, –help: Display help information.
4.7.17.3. Command Options and Their Functional Descriptions
Query Version Information
Command:
root@buildroot:~# ota_tool -v
Function:
Output the OTA library version, system version, and anti-rollback version.
Output:
root@buildroot:/userdata/gmsl# ota_tool -v
OTA Library version is 1.0.1
system version is V1.0.16_20250311-1228
Field Explanation:
OTA Library version: Indicates the current version number of the OTA library.
system version is V1.0.16_20250311-1228: Indicates the current system version number.
OTA Partition Management
Command:
root@buildroot:~# ota_tool -s 1
root@buildroot:~# ota_tool -s 0
Function:
Set the A/B slot for the next boot. 0 represents partition A, and 1 represents partition B.
Output when setting partition A:
root@buildroot:~# ota_tool -s 0
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[fe2954d5], newcrc[fe2954d5], offset[1352]
[OTA_INFO][veeprom_flag.c:396] update part num: [0]
[OTA_INFO][ota_boot_control.c:142] curslot read from misc is: 1
[OTA_INFO][ota_boot_control.c:650] next expected slot is:1
[OTA_INFO][ota_boot_control.c:688] set slot:0 to next expected success!
[OTA_INFO][veeprom_flag.c:632] next slot veeprom 0
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[fe2954d5], newcrc[fe2954d5], offset[1352]
[OTA_INFO][veeprom_flag.c:310] veeprom: flag [7], value [0]
Output when setting partition B:
root@buildroot:~# ota_tool -s 1
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[637d5378], newcrc[637d5378], offset[1352]
[OTA_INFO][veeprom_flag.c:396] update part num: [0]
[OTA_INFO][ota_boot_control.c:142] curslot read from misc is: 0
[OTA_INFO][ota_boot_control.c:650] next expected slot is:0
[OTA_INFO][ota_boot_control.c:688] set slot:1 to next expected success!
[OTA_INFO][veeprom_flag.c:632] next slot veeprom 1
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[637d5378], newcrc[637d5378], offset[1352]
[OTA_INFO][veeprom_flag.c:310] veeprom: flag [7], value [1]
Command:
root@buildroot:~# ota_tool -g
Function:
Retrieve the currently active partition.
Output:
root@buildroot:~# ota_tool -g
[OTA_INFO][hobot_ota_hl.c:462] current slot is:A
OTA Firmware Update
Before using ota_tool for an update, the OTA update package must be uploaded to the device. The command to compile the OTA update package is as follows:
./bd.sh otapackage
For a detailed introduction to the OTA packaging process, please refer to the X5 Introduction to the OTA Packaging Module section.
Command:
root@buildroot:~# ota_tool -p all_in_one.zip
Function:
Initiate OTA firmware update without verifying package integrity.
Command:
ota_tool -c -p all_in_one.zip -i all_in_one.signature
Function:
Initiate OTA firmware update and verify package integrity.
OTA Status Check
Command:
root@buildroot:~# ota_tool -b
Function:
Check OTA update status at boot time and mark the boot status of the current partition. This command option is automatically invoked by the system after an OTA firmware update.
Manual output:
root@buildroot:~# ota_tool -b
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[637d5378], newcrc[637d5378], offset[1352]
[OTA_INFO][veeprom_flag.c:396] update part num: [0]
Normal boot
[OTA_INFO][ota_boot_control.c:304] This slot has been marked success before, no need to mark it repeatedly
[OTA_INFO][ota_boot_control.c:797] set slot:0 boot success
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[637d5378], newcrc[637d5378], offset[1352]
[OTA_INFO][veeprom_flag.c:310] veeprom: flag [0], value [3]
System auto-start output:
[OTA_INFO][veeprom_flag.c:396] update part num: [1]
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[4db4cddd], newcrc[4db4cddd], offset[1352]
[OTA_INFO][veeprom_flag.c:396] update part num: [1]
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[4db4cddd], newcrc[4db4cddd], offset[1352]
[OTA_INFO][veeprom_flag.c:396] update part num: [1]
[OTA_INFO][ota_utils.c:876] normal mode
[OTA_INFO][hobot_ota_hl.c:755] OTA update status check success
[OTA_INFO][ota_boot_control.c:797] set slot:0 boot success
[OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[4db4cddd], newcrc[4db4cddd], offset[1352]
[ 4.355944] printk: S99ota_update_c: 16 output lines suppressed due to ratelimiting