23. SUOTA Demonstration

A number of the example applications provided with the SDK6 implement the SUOTA service and can therefore be updated over-the-air. In this section we will use one of these examples (the proximity reporter) to demonstrate the complete SUOTA process. We will build, and then load, the SUOTA capable example application onto a DA145xx development kit board. We will then update this application firmware, over-the-air, using the Dialog SUOTA application running on an Android or iOS based SmartDevice.

Smartboot

The DA14535 module overcomes pinning constraints with a pre-programmed secondary bootloader in flash. On startup, it transitions from the default ROM booter to the secondary bootloader, enabling 2-wire UART (on pins P0_0/ P0_1) in step 4 of the booting sequence. The module also contains an image advertising SUOTA, facilitating new image downloads. Despite pin constraints, the bootloader supports 1-wire UART (on pin P0_5) and 2-wire UART interfaces. The dual image bootloader, discussed in the SmartBoot document, serves as a foundation for Software Update Over The Air (SUOTA) applications.

23.1. Preparing the Development Kit

Before getting started you need to ensure the jumper and switch settings on the development kit you are using are configured to use the external SPI flash the board contains.

23.1.1. DA14531 Development Kit - USB

_images/suota_da14531_usb.svg

Figure 70 Switch setting on the DA14531 Development Kit - USB

23.1.2. DA14531 DEVKT-P

Ensure that the switch on the daughter card is in the ‘H’ position (buck mode)

_images/da145xx-pro-spi-config.png

Figure 71 Jumper settings on the DA14531 Development Kit - Pro

23.1.3. DA1453x DEVKT-P

Ensure that the switch on the daughter card is in the ‘H’ position (buck mode)

_images/da1453x-pro-spi-config.svg

Figure 72 Jumper settings on the DA1453x DEVKT-P

23.1.4. DA14585 Development Kit - Basic

_images/suota_da14585_basic.svg

Figure 73 Jumper settings on the DA14585 Development Kit - Basic

23.1.5. DA14585/6 Development Kit - Pro

_images/suota_da14585_pro.svg

Figure 74 Jumper settings on the DA14585/6 Development Kit - Pro

23.2. Software Update Over-the-Air Application

Once the development kit has been prepared, the next step is to download and install the Dialog SUOTA application on an iOS or Android based SmartDevice via the Apple App Store or Google Play (search for ‘Dialog SUOTA’).

23.3. Preparing the Proximity Reporter Application

Using the Keil uVision IDE, open the Proximity Reporter application (prox_reporter) located within the projects/target_apps/ble_examples/prox_reporter folder of the DA145xx SDK.

We will be using the Dialog SUOTA application to perform an update over-the-air. When connected to a DA1453x or DA1458x devices, this application reads the software and firmware version numbers from the Device Information Service characteristics and displays them for the user. By default, the prox_reporter application uses the SDK version number for both the software and firmware version numbers. We will modify this behaviour so that the firmware version number represents the SDK version, and the software version represents the application version number - making it easy to tell when an update has taken place.

To do this, we will first create a file called user_version.h containing the following, and place it in the projects/target_apps/ble_examples/prox_reporter/src folder:

#define SDK_VERSION "1.0.0"

Note

This macro MUST be named SDK_VERSION, even though it refers to the application version number, otherwise it will not be found by the tool used to create the images.

Next, we will use this version number to populate the software version number characteristic in the Device Information Service. To do this we first need to add the following callback function to the user_proxr.c file:

#include "user_version.h"
void user_app_on_db_init_complete(void)
{
    /* Set application version number in DISS */
    char sw_version[] = SDK_VERSION;
    struct diss_set_value_req *req = KE_MSG_ALLOC_DYN(DISS_SET_VALUE_REQ,
                                                      prf_get_task_from_id(TASK_ID_DISS),
                                                      TASK_APP,
                                                      diss_set_value_req,
                                                      sizeof(sw_version));
    req->value = DIS_SW_REV_STR_CHAR;
    req->length = sizeof(sw_version);
    memcpy(req->data, sw_version, sizeof(sw_version));
    ke_msg_send(req);

    default_app_on_db_init_complete();
}

Next add a prototype for this function to the user_proxr.h file as follows:

void user_app_on_db_init_complete(void);

Finally, redirect the stack to call this application defined callback by changing the definition of the app_on_db_init_complete pointer in the user_callback_config.h file to the following:

- .app_on_db_init_complete            = default_app_on_db_init_complete,
+ .app_on_db_init_complete            = user_app_on_db_init_complete,

23.3.1. Description of some important files

You can find some a brief description of some important SDK files for the SUOTA procedure.

File

Description

user_profiles_config.h

Defines which BLE profiles (Bluetooth SIG adopted or custom ones) will be included in user’s application. Each header file denotes the respective BLE profile. Be sure to #define the CFG_PRF_PXPR and CFG_PRF_SUOTAR, so that the proximity reporter profile and the SUOTA custom service will be included.

user_periph_setup.h

Holds hardware related settings relative to the used development kit.

user_periph_setup.c

Source code file that handles peripheral (GPIO, UART, SPI, etc.) configuration and initialization relative to the development kit.

app_suotar.c

Source code file that is implemented as SUOTA reporter application entry point.

app_suotar_task.c

Source code file that is implemented as SUOTA receiver application Message Handlers.

app_proxr.c

Source code file that is implemented as Proximity reporter application entry point.

app_proxr_task.c

Source code file that is implemented as Proximity reporter application task implementation.

23.4. Creating Application Image Files

Now we will create two application images, each with a different version number so we can identify which image is currently being executed by the DA1453x or DA1458x device.

Note

SmartSnippets Toolbox version 5.0.14 or later is required to create a SUOTA image, if you have an earlier version installed please upgrade before proceeding.

Firstly, create a folder called suota_images in projects/target_apps/ble_examples/prox_reporter/Keil_5 for the storage of the created images.

Now build the pxp_reporter application, using the Keil IDE, and copy the resulting hex file (prox_reporter_5xx.hex) from the prox_reporter/Keil_5/out_DA145xx/Objects folder into the ‘suota_images’ folder, and rename it fw_v1.hex.

Next, create an application image file based upon this hex file using the SmartSnippets Toolbox flash programmer tool as follows:

  1. Open SmartSnippets Toolbox. Select your device family and the JTAG interface and open the profile. If you need more details on how to use the SmartSnippets Toolbox, you can consult the User Manual for the SmartSnippets Toolbox.

_images/sstoolbox_home.png

Figure 75 SmartSnippets Toolbox home screen

  1. On the ribbon, choose Flash Code.

_images/sstool_ribbon.png

Figure 76 SPI Flash/EEPROM utility

  1. Push the “improt from file” button. In the pop-up window, select the “Make single image” radio button and then browse through your files and select the fw_v1.hex file. This will create the first single image that we need for the multipart firmware. Press “Next”.

_images/select_single_image.png

Figure 77 Select the application hex file

  1. Now tell the tool where to find the file that contains the application version number that is to be embedded in the image, this is the user_version.h we created earlier. Press “Next”.

_images/select_version_file.png

Figure 78 Select the application version file

  1. If encrypted images are desired, the Create an encrypted image box should be checked.

_images/suota_encrypt.png

Figure 79 encrypted images Option

As a string of 32 hex characters, without any prefix, enter the same Key (Encryption Key) and IV (Initialization vector) as they are put in the secondary_bootloader project: SDK_Path\utilities\secondary_bootloader\src\bootloader.c. Press “Next”.

const uint8_t Key[16]= {0x06,0xa9,0x21,0x40,0x36,0xb8,0xa1,0x5b,0x51,0x2e,0x03,0xd5,0x34,0x12,0x00,0x06};
const uint8_t IV[16] = {0x3d,0xaf,0xba,0x42,0x9d,0x9e,0xb4,0x30,0xb4,0x22,0xda,0x80,0x2c,0x9f,0xac,0x41};
  1. Finally, select the folder into which the created image file is to be stored. We will use the suota_images folder created previously. Press “Finish”.

_images/single_image_summary.png

Figure 80 Select output folder of single image

  1. Now we must create a new image, with a version number greater than the previous image, that will be used when we perform a software update over-the-air. To do this simply update the version number in the user_version.h file to “2.0.0”, rebuild the prox_reporter application, and copy the resulting hex file (prox_reporter_5xx.hex) from the prox_reporter/Keil_5/out_DA145xx/Objects folder into the ‘suota_images’ folder and rename it fw_v2.hex.

  2. Now follow steps 3 to 6, above, to create an image file for version 2 of the application.

23.5. Creating a Multi-image File

Once the above steps have been completed you should have two image files present in the suota_images folder:
  • fw_v1.img

  • fw_v2.img

Now we need to create a multi-image file, that also contains the dual image bootloader, than can then be programmed into flash and executed by the DA145xx. This tool requires two application images, however only one of these is executed, the other is simply a dumy file and is not used (in fact it is overwritten when a software over-the-air update occurs). Create this dummy image file by copying the fw_v1.img``file and naming it ``fw_v2.img.

Now create a multi-image file. To do this push the “Load hex/bin file” button. In the pop-up window, select the “Make multi image” radio button, and then browse through your files and select the fw_v1.img. Press “Next”.

_images/select_multi_image.png

Figure 81 Create multi image

  • In the next screen, select the fw_v2.img. Press “Next”.

_images/multi_image_second.png

Figure 82 Select the second image file

  • For this demonstration we will use the default multi-image bootloader that is provided with the SDK. To do this ensure the “Add a secondary bootloader to the image” option is selected and leave the “”Select a custom bootloader” field blank. Press “Next”.

_images/multi_sec_bootloader.png

Figure 83 Secondary bootloader

  • In the next screen, you can choose the memory location that the firmware images will reside. For the purposes of this demonstration we will leave these as their default values. Press “Next”.

_images/multi_offsets.png

Figure 84 Memory offsets for firmware images and product header

  • Finally, select the folder into which the created multi-image file is to be stored. We will use the suota_images folder created previously. Press “Finish”.

_images/multi_summary.png

Figure 85 Summary of multi image file

  • Press “Connect” to connect to DA1453x or DA1458x device on the development kit board, then “Erase” to erase your flash contents and then “Burn & Verify”.

Reset your development kit by cycling the power (simply remove and replacing the USB cable). Version 1 of the application will be now running on your DA1453x or DA1458x device.

23.6. Performing a Software Update Over-the-Air

We will now update the firmware that is running on the DA1453x or DA1458x device from version 1 to version 2 using the Dialog SUOTA application running on a Android or iOS based SmartDevice.

Note

Ensure the Dialog SUOTA App is installed on your Smart Device before proceeding.

23.6.1. Running the SUOTA App on iOS

First we must transfer version 2 of the application image (the fw_v2.img file) to the iOS based device. This can be achieved by connecting the SmartDevice to a PC and using iTunes as follows:

  1. Open iTunes and select the SmartDevice to which the image file is to be downloaded.

_images/itunes-1.png

Figure 86 Select SmartDevice

  1. Select the SUOTA App from the File Sharing menu.

_images/itunes-2.png

Figure 87 SUOTA App File Sharing

  1. Add the application image file that is to be downloaded (fw_v2.img).

_images/itunes-3.png

Figure 88 Add Application Image File

  1. Press the “Done” button to downloaded the selected file to the SmartDevice.

_images/itunes-4.png

Figure 89 Download Application Image File

We will now use the SUOTA App to updated the firmware running on the DA1453x or DA1458x5xx over-the-air.

  1. Start the SUOTA App on the iOS based SmartDevice.

_images/ios-1.png

Figure 90 Start SUOTA App

  1. You will see the DA1453x or DA1458x device adveritsing with the name DLG-PROXR, click on this device to connect.

_images/ios-2.png

Figure 91 Connect to device

  1. Once connected the contents of the Device Information Service will be displayed, note that the device is currently running version 1.0.0 of the application.

_images/ios-3.png

Figure 92 Review version number

  1. Press the “Update” button to begin the process of downloading version 2.0.0 of the application image and select the fw_v2.img file.

_images/ios-4.png

Figure 93 Start the update

  1. Ensure that the interface to the non-voltaile memory matches that on your board. On all development kit boards the SPI interface is used to connect to external flash memory. The pins used to implement the SPI interface depend upon the board you are using:

  • DA14531 or DA14535
    • MISO GPIO - P0_3

    • MOSI GPIO - P0_0

    • CS GPIO - P0_1

    • SCK GPIO - P0_4

  • DA14585
    • MISO GPIO - P0_5

    • MOSI GPIO - P0_6

    • CS GPIO - P0_3

    • SCK GPIO - P0_0

Select the “Oldest” image bank and send press “Send to device” to start the update.

_images/ios-5.png

Figure 94 SUOTA Configuration

  1. Update progress will be displayed.

_images/ios-6.png

Figure 95 Update in progress

  1. Once complete, you have the option to reboot the device. Select “Yes, reboot”, note that the device will only reboot once the SUOTA App has disconnected.

_images/ios-7.png

Figure 96 Update complete

  1. The DA1453x or DA1458x45xx will now reboot, select it once again to confirm the update was successful.

_images/ios-2.png

Figure 97 Connect to updated device

  1. Once again the contents of the Device Information Service will be displayed. This time note that the software revision number is 2.0.0, indicating the application image was updated to version 2.0.0.

_images/ios-8.png

Figure 98 Review updated version number