Create the OTA file system image

You can create a file system image outside of XCTU using any utility that can perform ECDSA signing. These instructions show how to do so using OpenSSL. To create an OTA file system image, use the following steps.

Create a staged file system

In order to create a usable file system image, first create a 'staged' copy of the file system you want to send on a local device.

Use the FS command or MicroPython to load all of the files that you want to send onto the local staging device.

Note The staging device must have the same firmware version installed as the target device or the file system will be rejected. Use the VR command to check the version number on both the staging and target devices.

Download the file system image

Run the command ATFS GET /sys/xbfs.bin to download an image of the file system from the staging device. The file is transferred using the YMODEM protocol. See File system for more information on downloading files using FS GET.

Pad the file system image

The file system image must be a multiple of 2048 bytes long before it is signed. Using hex editing software, add 0xFF bytes to the end of the downloaded image until size of the file is a multiple of 2048 (0x800 in hex).

Calculate the image signature

Once the image has been padded to a multiple of 2048 bytes, it is ready to be signed. The ECDSA signature should be calculated using SHA256 as the hash algorithm.

Assuming a public/private key pair has been generated as described in Generate a public/private key pair, that the private key is named private.pem, and that the padded image is named xbfs.bin; this can be done using OpenSSL with the following command:

openssl dgst -sha256 -sign private.pem -binary -out sig.bin xbfs.bin

sig.bin will contain the signature for the image.

Append the calculated signature to the image

The signature should be between 70 and 72 bytes, and it should be appended to the padded image.

Create the OTA file

Put the image into an OTA file that follows the format specified in ZigBee Document 095264r23. The file should consist of:

The OTA file must begin with an OTA header. See The OTA header for information on the format of the header. The image type should be 0x0100 for a file system image upgrade.

The sub-element tag should come before the image data. The sub-element tag follows the format described in section 6.3.3 of ZigBee Document 095264r23. It consists of 6 bytes: the first 2 bytes are the tag id and should be set to 0x0000. The next 4 bytes contain the length of the file system image in little-endian format.