You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# How to understand and use delta updates in Device Update for IoT Hub (Preview)
12
12
13
-
Delta updates allow you to generate a small update that represents only the changes between two full updates - a source image and a target image. This approach is ideal for reducing the bandwidth used to download an update to a device, particularly if there have been only a few changes between the source and target updates.
13
+
Delta updates allow you to generate a small update that represents only the changes between two full updates - a source image and a target image. This approach is ideal for reducing the bandwidth used to download an update to a device, particularly if there are only a few changes between the source and target updates.
14
14
15
15
>[!NOTE]
16
16
>The delta update feature is currently in [public preview](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
17
17
18
18
## Requirements for using delta updates in Device Update for IoT Hub
19
19
20
-
- The source and target update files must be SWU (SWUpdate) format.
20
+
- The source and target update files must be SWUpdate (SWU) format.
21
21
- Within each SWUpdate file, there must be a raw image that uses the Ext2, Ext3, or Ext4 filesystem. That image can be compressed with gzip or zstd.
22
-
- The delta generation process recompresses the target SWU update using zstd compression in order to produce an optimal delta. You'll import this recompressed target SWU update to the Device Update service along with the generated delta update file.
22
+
- The delta generation process recompresses the target SWU update using zstd compression in order to produce an optimal delta. Import this recompressed target SWU update to the Device Update service along with the generated delta update file.
23
23
- Within SWUpdate on the device, zstd decompression must also be enabled.
24
-
- This requires using [SWUpdate 2019.11](https://github.com/sbabic/swupdate/releases/tag/2019.11) or later.
24
+
- This process requires using [SWUpdate 2019.11](https://github.com/sbabic/swupdate/releases/tag/2019.11) or later.
25
25
26
26
## Configure a device with Device Update agent and delta processor component
27
27
28
28
In order for your device to download and install delta updates from the Device Update service, you need several components present and configured.
29
29
30
30
### Device Update agent
31
31
32
-
The Device Update agent _orchestrates_ the update process on the device, including download, install, and restart actions. Add the Device Update agent to a device and configure it for use. You'll need the 1.0 or later version of the agent. For instructions, see [Device Update agent provisioning](device-update-agent-provisioning.md).
32
+
The Device Update agent _orchestrates_ the update process on the device, including download, install, and restart actions. Add the Device Update agent to a device and configure it for use. Use agent version 1.0 or later. For instructions, see [Device Update agent provisioning](device-update-agent-provisioning.md).
33
33
34
34
### Update handler
35
35
36
36
An update handler integrates with the Device Update agent to perform the actual update install. For delta updates, start with the [`microsoft/swupdate:2` update handler](https://github.com/Azure/iot-hub-device-update/blob/main/src/extensions/step_handlers/swupdate_handler_v2/README.md) if you don't already have your own SWUpdate update handler that you want to modify. **If you use your own update handler, be sure to enable zstd decompression in SWUpdate**.
37
37
38
38
### Delta processor
39
39
40
-
The delta processor re-creates the original SWU image file on your device after the delta file has been downloaded, so your update handler can install the SWU file. You'll find all the delta processor code in the [Azure/iot-hub-device-update-delta](https://github.com/Azure/iot-hub-device-update-delta) GitHub repo.
40
+
The delta processor re-creates the original SWU image file on your device after the delta file is downloaded, so your update handler can install the SWU file. The delta processor code is available in the [Azure/iot-hub-device-update-delta](https://github.com/Azure/iot-hub-device-update-delta) GitHub repo.
41
41
42
42
To add the delta processor component to your device image and configure it for use, follow the README.md instructions to use CMAKE to build the delta processor from source. From there, install the shared object (libadudiffapi.so) directly by copying it to the `/usr/lib` directory:
43
43
@@ -48,9 +48,9 @@ sudo ldconfig
48
48
49
49
## Add a source SWU image file to your device
50
50
51
-
After a delta update has been downloaded to a device, it must be compared against a valid _source SWU file_ that has been previously cached on the device in order to be re-created into a full image. The simplest way to populate this cached image is to deploy a full image update to the device via the Device Update service (using the existing [import](import-update.md) and [deployment](deploy-update.md) processes). As long as the device has been configured with the Device Update agent (version 1.0 or later) and delta processor, the installed SWU file is cached automatically by the Device Update agent for later delta update use.
51
+
After a delta update is downloaded to a device, it must be compared against a valid _source SWU file_ that was previously cached on the device. This process is needed for the delta update to re-create the full target image. The simplest way to populate this cached image is to deploy a full image update to the device via the Device Update service (using the existing [import](import-update.md) and [deployment](deploy-update.md) processes). As long as the device is configured with the Device Update agent (version 1.0 or later) and delta processor, the Device Update agent caches the installed SWU file automatically for later delta update use.
52
52
53
-
If you instead want to directly pre-populate the source image on your device, the path where the image is expected is:
53
+
If you instead want to directly prepopulate the source image on your device, the path where the image is expected is:
@@ -68,14 +68,14 @@ By default, `BASE_SOURCE_DOWNLOAD_CACHE_PATH` is the path `/var/lib/adu/sdc/[pro
68
68
69
69
### Environment prerequisites
70
70
71
-
Before creating deltas with DiffGen, several things need to be downloaded and/or installed on the environment machine. We recommend a Linux environment and specifically Ubuntu 20.04 (or WSL if natively on Windows).
71
+
Before creating deltas with DiffGen, several things need to be downloaded and/or installed on the environment machine. We recommend a Linux environment and specifically Ubuntu 20.04 (or Windows Subsystem for Linux if natively on Windows).
72
72
73
73
The following table provides a list of the content needed, where to retrieve them, and the recommended installation if necessary:
74
74
75
75
| Binary Name | Where to acquire | How to install |
76
76
|--|--|--|
77
77
| DiffGen |[Azure/iot-hub-device-update-delta](https://github.com/Azure/iot-hub-device-update-delta) GitHub repo | From the root folder, select the _Microsoft.Azure.DeviceUpdate.Diffs.[version].nupkg_ file. [Learn more about NuGet packages](/nuget/).|
78
-
| .NET (Runtime)| Via Terminal / Package Managers |[Instructions for Linux](/dotnet/core/install/linux). Only the Runtime is required. |
78
+
| .NETCore Runtime, version 6.0.0| Via Terminal / Package Managers |[Instructions for Linux](/dotnet/core/install/linux). Only the Runtime is required. |
79
79
80
80
### Dependencies
81
81
@@ -98,27 +98,27 @@ The DiffGen tool is run with several arguments. All arguments are required, and
98
98
- The script recompress_tool.py runs to create the file [recompressed_target_archive], which then is used instead of [target_archive] as the target file for creating the diff.
99
99
- The image files within [recompressed_target_archive] are compressed with zstd.
100
100
101
-
If your SWU files are signed (likely), you'll need another argument as well:
101
+
If your SWU files are signed (likely), you need another argument as well:
- In addition to using [recompressed_target_archive] as the target file, providing a signing command string parameter runs recompress_and_sign_tool.py to create the file [recompressed_target_archive] and have the sw-description file within the archive signed (meaning a sw-description.sig file is present). You can use the sample `sign_file.sh` script from the [Azure/iot-hub-device-update-delta](https://github.com/Azure/iot-hub-device-update-delta/tree/main/src/scripts/signing_samples/openssl_wrapper) GitHub repo. Open the script, edit it to add the path to your private key file, then save it. See the examples section below for sample usage.
105
+
- In addition to using [recompressed_target_archive] as the target file, providing a signing command string parameter runs recompress_and_sign_tool.py to create the file [recompressed_target_archive] and have the sw-description file within the archive signed (meaning a sw-description.sig file is present). You can use the sample `sign_file.sh` script from the [Azure/iot-hub-device-update-delta](https://github.com/Azure/iot-hub-device-update-delta/tree/main/src/scripts/signing_samples/openssl_wrapper) GitHub repo. Open the script, edit it to add the path to your private key file, then save it. See the examples section for sample usage.
106
106
107
107
The following table describes the arguments in more detail:
108
108
109
109
| Argument | Description |
110
110
|--|--|
111
111
|[source_archive]| This is the image that the delta is based against when creating the delta. _Important_: this image must be identical to the image that is already present on the device (for example, cached from a previous update). |
112
112
|[target_archive]| This is the image that the delta updates the device to. |
113
-
|[output_path]| The path (including the desired name of the delta file being generated) on the host machine where the delta file is placed after creation. If the path doesn't exist, the directory is created by the tool. |
114
-
|[log_folder]| The path on the host machine where logs creates. We recommend defining this location as a sub folder of the output path. If the path doesn't exist, it is created by the tool. |
115
-
|[working_folder]| The path on the machine where collateral and other working files are placed during the delta generation. We recommend defining this location as a subfolder of the output path. If the path doesn't exist, it is created by the tool. |
113
+
|[output_path]| The path (including the desired name of the delta file being generated) on the host machine where the delta file is placed after creation. If the path doesn't exist, the tool creates it. |
114
+
|[log_folder]| The path on the host machine where logs creates. We recommend defining this location as a sub folder of the output path. If the path doesn't exist, the tool creates it. |
115
+
|[working_folder]| The path on the machine where collateral and other working files are placed during the delta generation. We recommend defining this location as a subfolder of the output path. If the path doesn't exist, the tool creates it. |
116
116
|[recompressed_target_archive]| The path on the host machine where the recompressed target file is created. This file is used instead of <target_archive> as the target file for diff generation. If this path exists before calling DiffGenTool, the path is overwritten. We recommend defining this path as a file in the subfolder of the output path. |
117
117
| "[signing_command]" _(optional)_| A customizable command used for signing the sw-description file within the recompressed archive file. The sw-description file in the recompressed archive is used as an input parameter for the signing command; DiffGenTool expects the signing command to create a new signature file, using the name of the input with `.sig` appended. Surrounding the parameter in double quotes is needed so that the whole command is passed in as a single parameter. Also, avoid putting the '~' character in a key path used for signing, and use the full home path instead (for example, use /home/USER/keys/priv.pem instead of ~/keys/priv.pem). |
118
118
119
119
### DiffGen examples
120
120
121
-
In the examples below, we're operating out of the /mnt/o/temp directory (in WSL):
121
+
In these examples, we're operating out of the /mnt/o/temp directory (in WSL):
122
122
123
123
_Creating diff between input source file and recompressed target file:_
124
124
@@ -160,7 +160,7 @@ The first step to import an update into the Device Update service is always to c
160
160
161
161
The delta update feature uses a capability called [related files](related-files.md), which requires an import manifest that is version 5 or later.
162
162
163
-
To create an import manifest for your delta update using the related files feature, you'll need to add [relatedFiles](import-schema.md#relatedfiles-object) and [downloadHandler](import-schema.md#downloadhandler-object) objects to your import manifest.
163
+
To create an import manifest for your delta update using the related files feature, you need to add [relatedFiles](import-schema.md#relatedfiles-object) and [downloadHandler](import-schema.md#downloadhandler-object) objects to your import manifest.
164
164
165
165
Use the `relatedFiles` object to specify information about the delta update file, including the file name, file size and sha256 hash. Importantly, you also need to specify two properties which are unique to the delta update feature:
166
166
@@ -171,9 +171,9 @@ Use the `relatedFiles` object to specify information about the delta update file
171
171
}
172
172
```
173
173
174
-
Both of the properties above are specific to your _source SWU image file_ that you used as an input to the DiffGen tool when creating your delta update. The information about the source SWU image is needed in your import manifest even though you don't actually import the source image. The delta components on the device use this metadata about the source image to locate the image on the device once the delta has been downloaded.
174
+
Both of these properties are specific to your _source SWU image file_ that you used as an input to the DiffGen tool when creating your delta update. The information about the source SWU image is needed in your import manifest even though you don't actually import the source image. The delta components on the device use this metadata about the source image to locate the image on the device once the delta is downloaded.
175
175
176
-
Use the `downloadHandler` object to specify how the Device Update agent orchestrates the delta update, using the related files feature. Unless you are customizing your own version of the Device Update agent for delta functionality, you should only use this downloadHandler:
176
+
Use the `downloadHandler` object to specify how the Device Update agent orchestrates the delta update, using the related files feature. Unless you're customizing your own version of the Device Update agent for delta functionality, you should only use this downloadHandler:
177
177
178
178
```json
179
179
"downloadHandler": {
@@ -192,17 +192,17 @@ Save your generated import manifest JSON to a file with the extension `.importma
192
192
193
193
### Import using the Azure portal
194
194
195
-
Once you've created your import manifest, you're ready to import the delta update. To import, follow the instructions in [Add an update to Device Update for IoT Hub](import-update.md#import-an-update). You must include these items when importing:
195
+
Once you create your import manifest, you're ready to import the delta update. To import, follow the instructions in [Add an update to Device Update for IoT Hub](import-update.md#import-an-update). You must include these items when importing:
196
196
197
197
- The import manifest .json file you created in the previous step.
198
198
- The _recompressed_ target SWU image created when you ran the DiffGen tool.
199
199
- The delta file created when you ran the DiffGen tool.
200
200
201
201
## Deploy the delta update to your devices
202
202
203
-
When you deploy a delta update, the experience in the Azure portal looks identical to deploying a regular image update. For more information on deploying updates, see [Deploy an update by using Device Update for Azure IoT Hub](deploy-update.md)
203
+
When you deploy a delta update, the experience in the Azure portal looks identical to deploying a regular image update. For more information on deploying updates, see [Deploy an update by using Device Update for Azure IoT Hub](deploy-update.md).
204
204
205
-
Once you've created the deployment for your delta update, the Device Update service and client automatically identify if there's a valid delta update for each device you're deploying to. If a valid delta is found, the delta update will be downloaded and installed on that device. If there's no valid delta update found, the full image update (the recompressed target SWU image) will be downloaded instead as a fallback. This approach ensures that all devices you're deploying the update to will get to the appropriate version.
205
+
Once you create the deployment for your delta update, the Device Update service and client automatically identify if there's a valid delta update for each device you're deploying to. If a valid delta is found, the delta update is downloaded and installed on that device. If there's no valid delta update found, the full image update (the recompressed target SWU image) is downloaded instead as a fallback. This approach ensures that all devices you're deploying the update to get to the appropriate version.
206
206
207
207
There are three possible outcomes for a delta update deployment:
208
208
@@ -219,7 +219,7 @@ If the delta update failed but did a successful fallback to the full image, it s
219
219
- resultCode: _[value greater than 0]_
220
220
- extendedResultCode: _[non-zero]_
221
221
222
-
If the update was unsuccessful, it shows an error status that can be interpreted using the instructions below:
222
+
If the update was unsuccessful, it shows an error status that can be interpreted using these instructions:
223
223
224
224
- Start with the Device Update Agent errors in [result.h](https://github.com/Azure/iot-hub-device-update/blob/main/src/inc/aduc/result.h).
225
225
@@ -234,7 +234,7 @@ If the update was unsuccessful, it shows an error status that can be interpreted
| DELTA_PROCESSOR | 10 | 0x0A | Error code for errors from delta processor API. Example: 0x90AXXXXX |
236
236
237
-
- If the error code isn't present in [result.h](https://github.com/Azure/iot-hub-device-update/blob/main/src/inc/aduc/result.h), it's likely an error in the delta processor component (separate from the Device Update agent). If so, the extendedResultCode will be a negative decimal value of the following hexadecimal format: 0x90AXXXXX
237
+
- If the error code isn't present in [result.h](https://github.com/Azure/iot-hub-device-update/blob/main/src/inc/aduc/result.h), it's likely an error in the delta processor component (separate from the Device Update agent). If so, the extendedResultCode is a negative decimal value of the following hexadecimal format: 0x90AXXXXX
238
238
239
239
- 9 is "Delta Facility"
240
240
- 0A is "Delta Processor Component" (ADUC_COMPONENT_DELTA_DOWNLOAD_HANDLER_DELTA_PROCESSOR)
0 commit comments