3.建立拟议的多粒图像¶
This section will guide you step by step on how to build a multipart binary image which can be upgraded via Dialog’s SUOTA to an upgraded firmware version. Please make sure you have installed all required dependencies listed in the “Before You Start”一节。
3.1. Getting started¶
For this tutorial we will use theProximity Reportersoftware example which is located in theprojects/target_apps/ble_examples/prox_reporter/
directory of your SDK installation. We will demonstrate how we can configure an application to run from a secondary bootloader and how we can send firmware updates over the air.
3.1.1. Hardware configuration¶
We will use the DA145xx Pro Development Kit in this example with the bootloader residing in the external SPI flash. You can see in the graphic below the configuration of the jumpers on the board to connect the SPI flash and the debugger.
3.1.2. Description of some important files¶
You can find some a brief description of some important SDK files for the SUOTA procedure.
文件 | 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 theCFG_PRF_PXPR 和CFG_PRF_SUOTAR ,因此将包括邻近记者配置文件和拟议定制服务。 |
user_periph_setup.h | Holds hardware related settings relative to the used development kit. |
user_periph_setup.c | 源代码文件处理外围设备(GPIO,UART,SPI等)配置和初始化相对于开发套件。 |
app_suotar.c | Source code file that is implemented as SUOTA reporter application entry point. |
app_suotar_task.c | 源代码文件实现为Suota Receiver应用程序消息处理程序。 |
app_proxr.c | 源代码文件实现为Proximity Reporter应用程序入口点。 |
app_proxr_task.c. | Source code file that is implemented as Proximity reporter application task implementation. |
3.1.3. Building the firmware¶
- Open the
prox_reporter.uvprojx
project file, located in/projects/target_apps/ble_examples/prox_reporter/Keil_5
under your SDK installation folder. - In the Build Toolbar, select the device you want to build the firmware for from the drop-down box.
- 更改默认蓝牙设备地址。你必须修改
CFG_NVDS_TAG_BD_ADDRESS
在里面user_config/da1458x_config_advanced.h
file, for example
#define CFG_NVDS_TAG_BD_ADDRESS {0x19, 0x00, 0x00, 0x00, 0x00, 0x19}
- 导航到文件
user_config/user_modules_config.h
和贴未定义的EXCLUDE_DLG_SUOTAR
macro. This way you will include the SUOTA module in your firmware.
#define EXCLUDE_DLG_SUOTAR (0)/ *包含* /
- Check that
CFG_PRF_SUOTAR
is defined in theuser_config/user_profiles_config.h
文件。
#define CFG_PRF_SUOTAR
- 改变advertising data. First make sure that the UUID of the SUOTA service is included in the advertising data.
#define user_advertise_data(“\ x09”\adv_type_complete_list_16bit_service_ids \ADV_UUID_LINK_LOSS_SERVICE\avd_uuid_immediate_alert_service \adv_uuid_tx_power_service \adv_uuid_suotar_service \"\x10"\ADV_TYPE_URI\"\x16\x2F\x2F\x77\x77\x77\x2E\x69\x61\x6E\x61\x2E\x6F\x72\x67")
和change the device name to a more descriptive one, for example:
#define user_device_name“suota-1”
Since we will need a few files to create the multipart image, we recommend to create a folder calledinput
和collect all these files there.
- 您现在可以继续构建固件。构建完成后,将输出十六进制文件复制到
input
夹。This is located in the proximity reporter project folder, underKeil_5 / OUT_DA145xx /对象/
, where the last part is your target device, with the nameprox_reporter_5xx.hex
. Rename the copied file tofw_1.hex
. - For the second firmware, change the device name in the
user_config/user_config.h
文件。
#define user_device_name“suota-2”
- Rebuild the firmware. Again, after the build is complete, copy the output file
prox_reporter_5xx.hex
到一个名为的文件fw_2.hex.
在里面input
夹。
At this point we have created the two single images that we will use for the SUOTA multipart image creation.
3.1.4. Create a secondary bootloader¶
The code that is run when the device boots up is called aBootloader.和its purpose is to set up the device so that the scheduler and the user code can run properly. For a software update to occur, every embedded device needs a way to assert if there is an updated firmware during boot up and apply the update.
For this purpose, we will also create asecondary bootloaderwhich will do this check.
- 导航到
/utilities/secondary_bootloader/
folder and open thesecondary_bootloader.uvprojx
项目文件。 - Open the file
includes/bootloader.h
. You will find a macro definition that reads
#define product_header_position 0x38000
This is the memory location that the product header will reside. You can leave it as it is, or you can change it to a location that suits better your application needs.
- Open the file
src/decrypt.c
. Check the encryption key and vector. Note these values, as we will use them in the following steps. By default you will see
constuint8_tKey[16]={0x06,0xa9,0x21,0x40.,0x36,0xb8,0xa1,0 x5b,0x51,0x2e,0x03,0xd5,0x34,0x12,0x00,0x06};constuint8_tIV[16]={0x3D.,0xaf,0xba,0x42,0x9d,0x9e,0xb4,0x30,0xb4,0x22,0xDA.,0x80,0x2c,0x9f,0xac,0x41};
- Select the device you want to build the firmware for from the drop-down box.
- 构建代码。根据您的目标,您应该看到输出文件夹,该输出文件夹包括输出二进制文件
OUT_DA14531 /对象/
. Locate the binary image, in our casesecodat_bootloader_531.hex.
, and copy it to theinput
夹。
At this point we have created all the binary images that we will use to program our device. In the next section we will load the multipart image to the SPI flash and upgrade it using the Dialog SUOTA mobile app.