# FOTA Partitioning

A device capable of receiving FOTA updates contains firmware composed of three parts, as illustrated in the "Memory Structure" figure:

| 1. | Bootloader

| 2. | FOTA Bluetooth Low Energy stack including DFU component (fota.bin sub-image)

| 3. | User application (app.bin sub-image)

Figure: Memory Structure

NOTE: For specific information about using FOTA in secure applications, see the readme file in the secure_fota_blinky sample application as well as its referenced documentation.

Each part depends on the previous one, except the bootloader, which is standalone. The FOTA Bluetooth Low Energy stack depends on the bootloader. The user application depends on the FOTA Bluetooth Low Energy stack, and therefore, also depends on the bootloader. In terms of size, the bootloader reserves memory. The FOTA Bluetooth Low Energy stack contains the device firmware update (DFU) component and the padding between the sub-images. The memory available in flash for the application is the amount of memory that is left once memory is reserved for the FOTA Bluetooth Low Energy Stack and bootloader. The boundary between the Bluetooth Low Energy stack and application areas can be dynamic, so it is possible to increase the Bluetooth Low Energy stack size at the expense of the application size, and vice versa.

When building a FOTA-compatible RSL sample application, you may notice that the libfota.a library is linked. This library functions as a stub object, and implements the Bluetooth Low Energy library functions as pointers to the real implementation, located in the fota.bin area. This makes the link between the application and the FOTA Bluetooth Low Energy stack particularly strong, because the application code calls functions from the Bluetooth Low Energy stack directly. Therefore, an application can only run together with the specific FOTA Bluetooth Low Energy stack revision that is used when building that application. For this reason, it is not possible to update the Bluetooth Low Energy stack without updating the application. On the other hand, it is possible to perform a FOTA update of the user application only.

Two types of FOTA updates are possible:

| • | Application only update

| • | Application + FOTA Bluetooth Low Energy stack update

The DFU component, an application embedded in the FOTA Bluetooth Low Energy stack area, implements a DFU Bluetooth Low Energy custom service for FOTA updates. It contains characteristics that allow a client device to gather information from the installed firmware (such as version numbers and IDs) and download the firmware image. As the DFU is embedded into the FOTA Bluetooth Low Energy stack area, FOTA updates are possible even when no valid user application is available in the device. More details about this component are provided in The DFU.