1. Example description

The DA14531 has an integrated ARM Cortex M0+ and can be used for programming and controlling the SoC. Due to the small form factor the ARM Cortex has its limitations. A solution for the limitations of the integrated microprocessor can be to use an external microprocessor. To control the DA14531 with this microprocessor some code is still needed on the DA14531. Fortunately, the DA14531 can execute code from RAM that can be loaded in during its boot sequence. This way a microcontroller can load a program onto the DA14531.

The goal of this example is to show how to load a program into the RAM of the DA14531 via a STM32 microcontroller. This example shows the flow of the code and how it can be configured. The program that is booted on the DA14531 in this example is called Codeless. The interface that is used for booting Codeless is UART. Codeless is a solution by Dialog to interface with the DA14531 with AT commands. More info on Codeless and its use can be found on here. In this example it will only be used to verify that the program has loaded correctly.

  • The example can be downloaded from Here

2. HW and SW configuration

2.1. Required hardware

  • A pc workstation
  • Clicker 2 for STM32 development board by Mikroe
  • A DA14531 Click board™ (BLE TINY Click) programmed with the secondary bootloader (secondary_bootloader.bin is included with the project.)
  • SEGGER J-Link
  • (optional) DA14531 Development Kit Pro Motherboard

2.2. Programming the BLE TINY Click with the secondary bootloader

The Dialog Flash Programmer can be used to program the flash of the BLE TINY Click, the flash programmer can be found here. Another option for programming the flash of the BLE TINY click using the SmartSnippets Toolbox which can be found here.

The first step to programming the flash is connecting the BLE TINY Click to the programming interface. For this either a DA14531 Development Kit Pro Motherboard or a SEGGER J-LINK can be used. In the images below the connections for both options can be viewed.

DA14531 Development Kit Pro Motherboard

DA14531_MOTHERBOARD

SEGGER J-LNK

DA14531_SEGGER

The next step is programming the BLE TINY Click. The first one to be explained is the Dialog Flash Programmer and after that the SmartSnippets Toolbox

Dialog Flash Programmer

Start the Dialog Flash Programmer. In the screen two options can be observed, the device to program with and the file to program and the file to program to the device. First click Browse and select the path to the secondary_bootloader.bin. Next select the device used for programming (the device is displayed by its serial number, which can be found on the SEGGER or the motherboard.)

After these steps the programmer should look like this:

flash_programmer

Lastly click Program and the BLE TINY Click should be programmed with the secondary bootloader.

SmartSnippets Toolbox

Open the SmartSnippets Toolbox. The first step is to setup a device, by clicking on New. Give the device settings a name, for example: BLE TINY click and optionally a description. Click on save and the settings should appear in the left panel, click on it. In the selection Please select the COM Port or JTAG Serial #: select JTAG. Next select the serial number of the SEGGER or the Motherboard. In the right panel select the DA14531 and the settings should be correct. It should look like the following:

toolbox_settings

Next click on Open and the Toolbox should open on the programming screen. First select the secondary_bootloader.bin by clicking on Load hex/bin file and following the options in the scree that opens. Next click on Connect and after the connection has been made click Burn & Verify and the secondary bootloader should be programmd. The end result should look like this:

toolbox_programming

2.3. Hardware configuration using the Clicker 2 for STM32 and the Mikroe BLE TINY Click

  • Connect the J-Link Segger to the Clicker 2 for STM32 J-TAG header using SWD configuration
  • Put the DA14531 Clickboard in the second mikroBUS™ slot of the Clicker 2 for STM32 (slot 1 can be used, but changes have to be made to the code configuration. This is explained further on in this document)

clickboard_config

2.4. Software configuration

This example requires:

  • Keil 5
  • SEGGER’s J-Link tools should be downloaded and installed.
  • BLE scanner for your smartphone (in this example BLE Scanner for Android is used)

Flow of the code

code_flow_of_boot

Running the code

Open the Keil project file located in project_environment/MDK-ARM folder and once it has opened click the Options for target… Button. In this screen go to Debug and set the debugger to J-LINK / J-TRACE Cortex After setting the debugger click on the Settings Button. Within this screen select the J-link module that is connected and set the Port: to SW. Save these settings.

CubeMX_debug CubeMX_debug_settings

After all the settings have been set the project can be built. Press the Build button or the F7 key to start building the project. When the build is done press the Start/Stop Debug Session button or the key combination Ctrl + F5 to load to program into the STM32.

Keil_compile

In the debug screen press the Run button or the F5 key to start the program and the boot process should start.

Keil_run

3. Expected Result

After about 5 seconds when the run button is pressed the DA14531 should start advertising itself as Codeless (this is the standard advertising name for Codeless). Down below a screenshot can be seen from BLE scanner for Android after the boot was successful.

BLE_result

4. Code settings

The booting process has two options 1 wire UART and 2 wire UART, in this example the booting process is done through 2 wire UART. This can be configured by either passing TWO_WIRE or ONE_WIRE to the booting function.

Another important parameter of the boot function is the CRC parameter. The CRC is to check whether the code received by the DA14531 is correct. It is calculated with the crc_calculate function and passed to the boot function.

keil_one_wire_uart

Within the boot_config.h file two settings can be found. The BOOT_ATTEMPTS and TIMEOUT_TIME define these settings. The BOOT_ATTEMPTS dictates how many attempts should be taken to start the booting process. The TIMEOUT_TIME defines the amount of time the UART should wait before a byte as received, this is a blocking process.

keil_boot_config

5. Side Notes

The project is setup using STM32CubeMX and the .ioc is provided with the project so changes can be made should they be necessary for the user. The settings used in STM32CubeMX are as follows:

CubeMX_pinout

As an example, the UART pins can be changed to pins PD5 and PD6 to use the first mikroBUS™ slot. Keep in mind that the UART handle changes in the code and that the correct one should be passed to the boot function.

6. Known Limitations

7. License


Copyright (c) 2021 Dialog Semiconductor. All rights reserved.

This software (“Software”) is owned by Dialog Semiconductor. By using this Software you agree that Dialog Semiconductor retains all intellectual property and proprietary rights in and to this Software and any use, reproduction, disclosure or distribution of the Software without express written permission or a license agreement from Dialog Semiconductor is strictly prohibited. This Software is solely for use on or in conjunction with Dialog Semiconductor products.

EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES OR AS REQUIRED BY LAW, THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES OR BY LAW, IN NO EVENT SHALL DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE SOFTWARE.