|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| figures/ | | 22-Oct-2025 | - | | |
| interfaces/kits/ | | 22-Oct-2025 | - | 1,629 | 1,228 |
| resources/ | | 22-Oct-2025 | - | 1,092 | 1,069 |
| services/ | | 22-Oct-2025 | - | 49,944 | 39,734 |
| test/ | | 22-Oct-2025 | - | 23,657 | 18,970 |
| utils/ | | 22-Oct-2025 | - | 3,128 | 2,563 |
| .gitattributes | D | 22-Oct-2025 | 795 | 18 | 17 |
| BUILD.gn | D | 22-Oct-2025 | 3 KiB | 79 | 74 |
| LICENSE | D | 22-Oct-2025 | 12 KiB | 223 | 188 |
| OAT.xml | D | 22-Oct-2025 | 7.6 KiB | 106 | 46 |
| README.md | D | 22-Oct-2025 | 6.9 KiB | 133 | 81 |
| README_zh.md | D | 22-Oct-2025 | 6.2 KiB | 141 | 87 |
| bundle.json | D | 22-Oct-2025 | 13.8 KiB | 348 | 346 |
| updater.md | D | 22-Oct-2025 | 7.1 KiB | 127 | 103 |
| updater_default_cfg.gni | D | 22-Oct-2025 | 1.6 KiB | 57 | 50 |
| updater_ux_guide.md | D | 22-Oct-2025 | 17.5 KiB | 387 | 354 |
README.md
1# Updater<a name="EN-US_TOPIC_0000001148614629"></a>
2
3- [Introduction](#section184mcpsimp)
4- [Directory Structure](#section198mcpsimp)
5- [Usage](#section218mcpsimp)
6 - [Usage Guidelines](#section220mcpsimp)
7
8- [Repositories Involved](#section247mcpsimp)
9
10## Introduction<a name="section184mcpsimp"></a>
11
12The updater runs in the updater partition. It reads the misc partition information to obtain the update package status and verifies the update package to ensure that the update package is valid. Then, the updater parses the executable program from the update package, creates a subprocess, and starts the update program. After that, update operations will be automatically implemented by the update script.
13
14## Directory Structure<a name="section198mcpsimp"></a>
15
16```
17base/update/updater/
18├── resources # UI image resources of the update subsystem
19├── services # Service code of the updater
20│ ├── applypatch # Update package data update code
21│ ├── fs_manager # File system and partition management code
22│ ├── include # Header files for the update subsystem
23│ ├── log # Log module of the update subsystem
24│ ├── package # Update packages
25│ ├── script # Update scripts
26│ ├── diffpatch # Differential package restore code
27│ ├── sparse_image # Sparse image parsing code
28│ ├── ui # UI code
29│ └── updater_binary # Executable programs
30├── interfaces
31│ └── kits # External APIs
32└── utils # Common utilities of the update subsystem
33 └── include # Header files for general functions of the update subsystem
34```
35
36## Usage<a name="section218mcpsimp"></a>
37
38### Usage Guidelines<a name="section220mcpsimp"></a>
39
40The updater runs in the updater partition. To ensure proper functioning of the updater, perform the following operations:
41
421. Create a updater partition.
43
44The updater partition is independent of other partitions. It is recommended that the size of the updater partition be greater than or equal to 20 MB. The updater partition image is an ext4 file system. Ensure that the **config** option of the ext4 file system in the system kernel is enabled.
45
462. Create the misc partition.
47
48The misc partition stores metadata required by the update subsystem during the update process. Such data includes update commands and records of resumable data transfer upon power-off. This partition is a raw partition and its size is about 1 MB. You do not need to create a file system for the misc partition, because the update subsystem can directly access this partition.
49
503. Prepare the partition configuration table.
51
52During the update process, the updater needs to operate the partitions through the partition configuration table. The default file name of the partition configuration table is **fstab.updater**. You need to pack the **fstab.updater** file into the updater during compilation.
53
544. Start the updater.
55
56The init process in the updater partition has an independent configuration file named **init.cfg**. The startup configuration of the updater is stored in this file.
57
585. Compile the updater.
59
60a. Add the updater configurations to the **build/subsystem\_config.json** file.
61
62Example configuration:
63
64```
65"updater": {
66"project": "hmf/updater",
67"path": "base/update/updater",
68"name": "updater",
69"dir": "base/update"
70},
71```
72
73b. Add the updater for the desired product.
74
75For example, to add the updater for Hi3516D V300, add the following code to the **productdefine/common/products/Hi3516DV300.json** file.
76
77```
78 "updater:updater":{},
79```
80
816. Compile the updater partition image.
82
83Add the compilation configuration to the **build\_updater\_image.sh** script, which is stored in the **build** repository and called by the OpenHarmony compilation system.
84
85## AB Streaming Update<a name="section218mcpsimp"></a>
86
87User devices may not always have sufficient space on the data partition for downloading OTA upgrade packages. Furthermore, entering the microsystem for upgrades sometimes impacts the user experience. To resolve these issues, OpenHarmony has introduced support for AB Streaming Updates. This feature allows downloading data chunks (Chunks) to be written directly to the inactive B partition, eliminating the need to store the chunks or the full update package on the data partition. Simultaneously, users can continue operating their devices on the active A partition while the update is applied to the inactive B partition, bypassing the need to enter the updater microsystem.
88
89### Key Technologies<a name="section220mcpsimp"></a>
90
911、 Supports independent AB partition upgrades, enabling seamless updates.
92
932、 Supports resumable streaming updates, allowing updates to continue after interruptions like network disconnections or user pauses.
94
953、 Supports multiple security checks, including hash verification for each data chunk and integrity verification for each image after the update.
96
974、 Supports exception rollback, ensuring the device automatically reverts to the stable partition upon upgrade failure for a consistent user experience.
98
995、 Supports customizable streaming data chunk size, adjustable based on the device's data partition capacity.
100
101### Packaging Process<a name="section220mcpsimp"></a>
102
103The AB Streaming Update modifies the packaging of standard AB differential or full OTA packages. new and diff operations larger than the specified data size requirement in this document are split into smaller chunks. All delta dependency files are then packaged into the update.bin file using the TLV format.
104
1051、 Split diff/new content exceeding 45KB
106
107Input parameters: pkgdiff, new commands.
108
109Output: For the pkgdiff command, attempt to generate a diff file. If the diff file is larger than 45KB, split the pkgdiff operation into multiple smaller pkgdiff commands until each generated diff file is under 45KB. For the new command, directly check the block content size. Split any block not meeting the size requirement into multiple new commands.
110
1112、Calculate img blocks excluding those operated on in the action list
112
113Input parameters: All blocks operated on in the action list, Total blocks of the img.
114
115Output: The complement set of the two. Sort the required copy blocks in ascending order. Group consecutive blocks into sets. Combine them into copy commands using the standard new command format.
116
1173、Package action, diff, etc., into update.bin per TLV format
118
119Input parameters: transfer.list, new.dat, patch.dat.
120
121Output: Package each line of the transfer.list as a chunk. Locate the dependent content in new.dat and patch.dat. Generate update.bin in TLV format.
122
123## Repositories Involved<a name="section247mcpsimp"></a>
124
125Update subsystem
126
127[**update\_updater**](https://gitee.com/openharmony/update_updater)
128
129[build](https://gitee.com/openharmony/build)
130
131[productdefine\_common](https://gitee.com/openharmony/productdefine_common)
132
133