# Sub-Image Format

A sub-image contains the 1-to-1 flash content for RSL devices. We use positions 8 and 9 of the vector table to store pointers for the version info and the image descriptor, as shown in the "Vector Table Positions" figure:

Figure: Vector Table Positions

Every vector is a 32-bit value. With the Reset handler vector, the image start address can be calculated as:

To find the version info and image descriptor, we calculate the corresponding image offsets by subtracting the image start address from the vector value:

All multi-byte values in the description are in little-endian format.

The version info has the following format:

typedef struct

{

char id[6]; /* ID string */

uint16_t num; /* <major[15:12]>.<minor[11:8]>.<revision[7:0]> */

} version;

typedef struct

{

version img_ver /* image version */

uint8_t dev_id[16]; /* device UUID set by mkfotaimg (default all 0s) */

} version_info;

In the FOTA stack sub-image, the version info is directly followed by a configuration structure:

typedef struct

{

uint32_t length; /* length of this structure in bytes */

uint8_t pub_key[64]; /* public signing key set by mkfotaimg */

/* (default all 0s)

uint8_t srv_id[16]; /* service UUID used when advertising */

/* set by mkfotaimg (defaults to the */

/* DFU service ID)

uint16_t dev_name_len; /* device name length set by mkfotaimg */

/* (defaults to 13)

uint8_t dev_name[29]; /* device name used when advertising */

/* set by mkfotaimg (defaults to */

/* “RSL FOTA ”) */

} config_info;

The image descriptor has the following format:

typedef struct

{

uint32_t image_size; /* image size in bytes excluding the signature */

uint32_t build_id[8]; /* FOTA stack build ID */

} image_descriptor;

The FOTA stack build IDs from the two sub-images must match; otherwise it means that the application image has been linked against another version of the FOTA stack image as included in the FOTA image, in which case an IMAGE_DNL_BAD_BUILDID error is generated. The public key derived from the signing key is stored in the configuration structure of the FOTA stack sub-image (see above struct config_info field pub_key). The image size found in the image descriptor excludes the signature, so you must add 64 to the size to get the total sub-image size.