16. OTP Programming

In earlier stages, we developed and executed our application by loading it directly into the device’s RAM using the debugger—an approach suitable for development. However, for production, our application will be stored in OTP, external SPI flash, or loaded via I2C/UART interfaces by the ROM-based bootloader present in all DA1453x, DA14585/DA14586 devices. This ensures a more reliable and efficient deployment.

Refer to the following documents for more details about the boot options available on DA1453x,DA14585/DA14586 devices:

This section covers preparing and programming your application into the OTP memory of DA1453x, DA14585/DA14586 devices. After programming, upon a hardware or power-on reset, the ROM-based bootloader loads the application from OTP into RAM and executes it.

SWD access after OTP programming

The ROM-based bootloader on the DA1453x does not activate the SWD ( Serial Wire Debug Probe) interface during the OTP-to-RAM loading process. Consequently, once you program your application into OTP on the DA14531, SWD interface access to the device is no longer possible. Additionally, it’s crucial to exercise caution when programming OTP on the DA14585/86, as incorrect programming can render the device unusable. Follow these instructions meticulously to ensure proper execution.

16.1. Preparing the Application

Some minor modifications are required to optimize an application before it is programmed into OTP.

First, change the code location macro found in the ..._config_advanced.h files (considering the target) as follows:
- #define CFG_CODE_LOCATION_EXT
+ #undef CFG_CODE_LOCATION_EXT

- #undef CFG_CODE_LOCATION_OTP
+ #define CFG_CODE_LOCATION_OTP

This enables the linker to check that the application will fit in the available OTP memory.

Next, in the ..._config_basic.h files (considering the target), disable development mode by changing the CFG_DEVELOPMENT_DEBUG macro as follows:
- #define CFG_DEVELOPMENT_DEBUG
+ #undef CFG_DEVELOPMENT_DEBUG

This prevents the DA1453x , DA14585/DA14586 from emulating an OTP copy (as it is now doing it for real) and also turns off a number of development debug features.

Finally, rebuild the application and you then have a binary file that is ready to be programmed into OTP memory.

16.2. Programming OTP Memory

Once you have prepared your application firmware you can the use the OTP Programmer tool contained within the SmartSnippets™ Toolbox to program your application into the DA145xx OTP memory. If you’re not already familiar with the SmartSnippets™ Toolbox then it is strongly recommended that you review the Getting Started section of the User Manual.

Start the SmartSnippets Toolbox, connect to the development kit board using the JTAG option and select the OTP Programmer from the tools menu. The programming process involves two steps: programming the image and programming the header.

16.2.1. Programming OTP Image

Select the OTP Image tab and choose the application you want to program using the Browse button.

_images/otp_prog_file.png

Figure 29 Select a file to program into OTP memory

Programming OTP: Hex and Binary File Options

To program the OTP, you have the flexibility to use either a hex file or a binary file with the provided tool. For the empty_peripheral_template project, these files can be located in the following directory: empty_peripheral_template\Keil_5\out_DA145xx\Objects.

Once the application image has been selected, make a note of its size as this will be required when programming the OTP header. This information will be displayed in the log window, in this example the application image size is 19480 bytes.

_images/otp_img_size.png

Figure 30 Application Image Size

Program this image into OTP by pressing the Connect button and then the Burn button. When prompted, press Yes to complete the programming process. When complete you’ll see a message saying “Memory burning completed successfully” in the Log window.

_images/prog_otp.png

Figure 31 Program a file into OTP memory

16.2.2. Programming OTP Header

Once the image has been programmed, the OTP header has to be updated to tell the ROM based bootloader to load and execute this image following a power-on or hardware reset. To do this, select the System Parameters tab and then press the Connect button. Set both of the Application Flag fields to Yes and set the OTP DMA Length field to the size of the application image divided by four (in hexadecimal format). In this example the OTP image size (noted in the previous step) was 19480 and so the field is set to 0x1306.

_images/otp_hdr.png

Figure 32 OTP Header Configuration

Program these changes into OTP by pressing the Burn button.

Finally, press the reset button on the development kit board (or cycle the power) and the application will be loaded from OTP into RAM by the ROM based bootloader and will start executing.

16.2.2.1. Programming OTP BD Address (DA1453x)

If you are using a public BD address and want to program it into OTP then it should be written to the Bluetooth Device Address field in the OTP Header. This field is 8-bytes long and the BD address should be stored in the byte order shown below (in this example an address of 80:EA:CA:A0:02:A2 is written to the OTP):

_images/otp_bd_addr.png

Figure 33 Program a BD Address into into OTP memory

16.3. Production Programming OTP

The method discussed above is ideal for programming a small number of devices, such as when building prototypes. When it comes to production it is strongly recommended that the Dialog Production Line Tool (PLT) is used for programming OTP. This tool can also be used to test the radio and trim the crystal etc. Further details about the PLT can be found here: