Over The Air (OTA) Bootloader Abstraction Library
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
Over The Air (OTA) Bootloader Abstraction Library Documentation

Overview

The OTA Bootloader Abstraction library implements the bootloader-specific storage interface APIs required to handle Over-the-Air (OTA) upgrade images on Infineon connectivity-enabled MCUs. It is designed to work together with the Infineon ota-update library, which downloads OTA upgrade images on PSOC™ 6, CYW20829, CYW89829, XMC7100, XMC7200, CYW955913, and PSOC™ Edge E84 (PSE84) platforms.

An application does not call the bootloader-specific storage interface APIs directly. Instead, during Infineon OTA Agent initialization, the application registers these storage interface APIs as callbacks. The ota-update library then invokes the registered callbacks to store, verify, and activate downloaded upgrade images. The library also provides the build environment (template flashmaps, linker files, and pre/post-build scripts) needed to generate BOOT and UPGRADE images for OTA applications. See the ota-update Reference Manual for more details.

Features

  • Bootloader-specific OTA storage interface (open, read, write, close, verify, set-pending, validate, get-app-info) callback implementations for MCUBootloader and the CYW955913EVK-01 in-built bootloader.
  • Template flashmaps for PSOC™ 6, CYW20829, CYW89829, XMC7100, XMC7200, and PSOC™ Edge E84 (PSE84) platforms.
  • Template OTA linker files for the GCC_ARM, ARM, and IAR toolchains (LLVM_ARM on PSOC™ Edge E84).
  • Pre-build and post-build scripts that generate and sign MCUBootloader-based BOOT and UPGRADE images.
  • OTA image encryption support, including on-the-fly encryption for CYW20829/CYW89829 and encryption for PSOC™ Edge E84 and the CY8CEVAL-062S2-CYW955513SDM2WLIPA (Secure LCS).
  • Support for SWAP, OVERWRITE, and direct execute-in-place (XIP) MCUBootloader upgrade modes.

When to Use

Use this library when building an OTA-capable application with the Infineon ota-update library and you need bootloader-specific storage handling for downloaded upgrade images. It is imported automatically by the ModusToolbox™ MCUBootloader-based and in-built-bootloader-based OTA code examples, and is required whenever an OTA application must store, verify, and activate an upgrade image through MCUBootloader or the CYW955913EVK-01 in-built bootloader.

Prerequisites

Hardware Requirements

This library supports the following Infineon device families (see ./RELEASE.md "RELEASE.md" for the exact list of validated kits):

  • PSOC™ 6 MCU with AIROC™ CYW4343W / CYW43012 / CYW43439 Wi-Fi & Bluetooth® connectivity
  • PSOC™ 6 Bluetooth® LE devices
  • AIROC™ CYW20829
  • AIROC™ CYW89829
  • XMC7100 and XMC7200
  • CYW955913
  • PSOC™ Edge E84 (PSE84)

Additional requirements:

  • Python 3.8 (used by the pre/post-build scripts to parse memory configurations).
  • cysecuretools v6.1 or greater, or edgeprotecttools v1.5 or greater, depending on the target platform (used for provisioning and OTA image signing/encryption).

Software Requirements

This version of the library was validated for compatibility with the following software and tools:

Software and Tools Version
ModusToolbox™ Software Environment 3.9
- ModusToolbox™ Device Configurator 5.90
- ModusToolbox™ Bluetooth Configurator 3.90
GCC Compiler 14.2.1
IAR Compiler 9.50.2
Arm Compiler 6 6.22
LLVM Compiler 22.1.0

Read Documentation First

  • ota-update Reference Manual - OTA Agent, storage interface definitions, and OTA image format
  • ./source/COMPONENT_MCUBOOT/MCUBOOT_APP_README.md "MCUBootApp Usage Instructions" - Cloning, configuring, and building MCUBootApp
  • ./source/COMPONENT_MCUBOOT/MCUBOOT_OTA_FLASH_LAYOUT_README.md "Flash Layout for MCUBootloader based OTA" - Flash slot layout requirements
  • ./source/COMPONENT_MCUBOOT/MCUBOOT_OTA_MAKEFILE_INFO_README.md "OTA Application Makefile settings" - Makefile defines for MCUBootloader-based OTA
  • MCUBoot design documentation: https://github.com/mcu-tools/mcuboot/blob/main/docs/design.md

Choose Starting Template

Start from an Empty ModusToolbox™ application, or from one of the OTA code examples listed under Related Code Examples (for example, mtb-example-ota-mqtt), which import this library and the ota-update library automatically.

Add Required Libraries

Add the required libraries using the ModusToolbox™ Library Manager (available in the ModusToolbox™ for VS Code extension and in the Eclipse IDE), or by creating the corresponding .mtb files in the application's deps folder and running make getlibs.

After adding the .mtb files to the deps folder, run: ``` make getlibs ```

Configure Makefile

Enable the bootloader storage component that matches your target, and configure the OTA build settings, in the application Makefile:

```

MCUBootloader-based OTA

COMPONENTS+=MCUBOOT

CYW955913EVK-01 in-built bootloader-based OTA

COMPONENTS+=CYW955913SDCM2WLIPA ```

For MCUBootloader-based OTA, also set the OTA platform, linker file, Python path, and include the library's pre/post-build makefile:

``` OTA_PLATFORM=<platform_type> OTA_LINKER_FILE=<OTA linker="" file="" path>=""> CY_PYTHON_PATH=<Path to="" python="" module>=""> include ../mtb_shared/ota-bootloader-abstraction/<version>/makefiles/mcuboot/mcuboot_support.mk ```

See ./source/COMPONENT_MCUBOOT/MCUBOOT_OTA_MAKEFILE_INFO_README.md "OTA Application Makefile settings" for the full list of Makefile defines. Detailed, platform-specific enablement steps are documented under Configuration Reference.

Add Headers

Include the OTA storage interface header for your bootloader component in the application source that registers the storage callbacks:

```c #include "cy_ota_storage_api.h" ```

Quick Start

This quick start demonstrates registering the OTA storage interface callbacks and starting the OTA Agent for an MCUBootloader-based OTA application. Follow these steps starting from an Empty application:

Step 1: Build and program MCUBootApp on your target. See ./source/COMPONENT_MCUBOOT/MCUBOOT_APP_README.md "MCUBootApp Usage Instructions".

Step 2: Add the required libraries (see Add Required Libraries) and run make getlibs.

Step 3: Configure the application Makefile (see Configure Makefile), including COMPONENTS+=MCUBOOT, OTA_PLATFORM, OTA_LINKER_FILE, CY_PYTHON_PATH, and the mcuboot_support.mk include.

Step 4: Register the storage interface callbacks and start the OTA Agent (see Sample Code).

Step 5: Build the application. The BOOT and UPGRADE images (.bin) are generated in the configured build directory. Program the BOOT image and use the UPGRADE image for OTA.

Expected Outcome: See Expected Outcome.

Sample Code

Register the bootloader storage interface callbacks in the cy_ota_storage_interface_t structure and pass it when starting the OTA Agent:

```c /* OTA storage interface callbacks */ cy_ota_storage_interface_t ota_interfaces = { .ota_file_open = cy_ota_storage_open, .ota_file_read = cy_ota_storage_read, .ota_file_write = cy_ota_storage_write, .ota_file_close = cy_ota_storage_close, .ota_file_verify = cy_ota_storage_verify, .ota_file_set_boot_pending = cy_ota_storage_set_boot_pending, .ota_file_validate = cy_ota_storage_image_validate, .ota_file_get_app_info = cy_ota_storage_get_app_info };

/* Register OTA storage interface callbacks with the OTA Agent */ cy_ota_agent_start(&ota_test_network_params, &ota_test_agent_params, &ota_interfaces, &ota_context); ```

For the CYW955913EVK-01 in-built bootloader, omit .ota_file_set_boot_pending and, after a successful download, switch to the new image by calling cy_ota_storage_switch_to_new_image().

Expected Outcome

When the Quick Start example is built and run, you should observe:

  • During the application build, the BOOT and UPGRADE images (.bin) of the OTA application are generated in the configured build directory.
  • After the BOOT image is programmed, the application runs from the primary slot under MCUBootloader (or the CYW955913EVK-01 in-built bootloader).
  • When the OTA Agent downloads the UPGRADE image, it is stored through the registered storage callbacks; on the next reset the bootloader verifies and boots the upgrade image.
  • With debug logging enabled (see Enabling Debug Output), the terminal shows the storage open/write/verify callback activity as the image is downloaded and applied.

Troubleshooting

  • No debug output: Debug logging is disabled by default. Enable it as described in Enabling Debug Output.
  • Pre/post-build script failures: Ensure Python 3.8 is installed and CY_PYTHON_PATH points to it. On Windows 10, install the pip requirements as described in Note on Using Windows 10.
  • Bootloader does not apply the update: MCUBootApp and the OTA application must use the same flash layout/flashmap. See Flash Layout Requirements and Target and Flashmap Use.
  • Update reverts after reset (SWAP mode): The updated application must call cy_ota_storage_image_validate() to confirm the update; otherwise MCUBootloader reverts on the next reset.
  • **"Unable to find CMSIS-DAP device" / "KitProg firmware is out of date":** Upgrade the board to KitProg3 using the Firmware Loader.

Related Code Examples

Configuration Reference

This section provides comprehensive documentation of the bootloader support, flash layouts, build configuration, and platform-specific enablement steps for the library. For the COMPONENT flags and Makefile defines summary, see Configure Makefile.

Bootloader Support

To add different bootloader support on Infineon connectivity-enabled MCU platforms, ota-update library offloads bootloader specific storage interface APIs using callback mechanism. To handle downloaded OTA upgrade images ota-update library calls registered bootloader-specific storage interface callbacks. The ota-bootloader-abstraction library includes an implementation of bootloader-specific storage interface APIs for various bootloaders. Additionally, it provides the necessary build environment to create BOOT and UPGRADE images for OTA applications.

OTA Storage Interface Callback APIs Structure

The OTA storage interface callback APIs structure and the callback API prototypes are defined in the ota-update library. Refer ota-update library API header file for details.

``` typedef struct cy_ota_storage_interface_s { cy_ota_file_open ota_file_open; /**< Creates and open new receive file for the data chunks as they come in. */ cy_ota_file_read ota_file_read; /**< Reads the flash data starting from the given offset. */ cy_ota_file_write ota_file_write; /**< Write a data to the flash at the given offset. */ cy_ota_file_close ota_file_close; /**< Close the underlying receive file in the specified OTA context. */ cy_ota_file_verify ota_file_verify; /**< Authenticate received OTA update file specified in the OTA context. */ cy_ota_file_set_pending ota_file_set_boot_pending; /**< To Mark the image in the inactive slot as pending. */ cy_ota_file_validate ota_file_validate; /**< The application has validated the new OTA image. */ cy_ota_file_get_app_info ota_file_get_app_info; /**< Get Application info like Application version and Application ID. */ } cy_ota_storage_interface_t; ```

OTA Storage Interface APIs Implementation

Storage operation callback Bootloader API Remarks
ota_file_open MCUBootloader cy_ota_storage_open() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
ota_file_read MCUBootloader cy_ota_storage_read() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
ota_file_write MCUBootloader cy_ota_storage_write() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
ota_file_close MCUBootloader cy_ota_storage_close() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
ota_file_verify MCUBootloader cy_ota_storage_verify() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
ota_file_set_boot_pending MCUBootloader cy_ota_storage_set_boot_pending() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
ota_file_validate MCUBootloader cy_ota_storage_image_validate() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
ota_file_get_app_info MCUBootloader cy_ota_storage_get_app_info() Available in source/COMPONENT_MCUBOOT/cy_ota_storage_api.c
Storage operation callback Bootloader API Remarks
ota_file_open CYW955913SDCM2WLIPA cy_ota_storage_open() Available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c
ota_file_read CYW955913SDCM2WLIPA cy_ota_storage_read() Available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c
ota_file_write CYW955913SDCM2WLIPA cy_ota_storage_write() Available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c
ota_file_close CYW955913SDCM2WLIPA cy_ota_storage_close() Available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c
ota_file_verify CYW955913SDCM2WLIPA cy_ota_storage_verify() Available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c
ota_file_validate CYW955913SDCM2WLIPA cy_ota_storage_image_validate() Available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c
ota_file_get_app_info CYW955913SDCM2WLIPA cy_ota_storage_get_app_info() Available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c

Note: The current version of the ota-bootloader-abstraction library implements storage interface APIs only for MCUBootloader-based OTA and the CYW955913EVK-01 in-built bootloader-based OTA.

MCUBootloader Support

The ota-bootloader-abstraction library provides MCUBootloader-based OTA support on PSOC™ 6, CYW20829, CYW89829, XMC7100, and XMC7200 platforms.

  • Template flashmaps for PSOC™ 6, CYW20829, CYW89829, XMC7100, XMC7200, and PSOC™ Edge E84 (PSE84) platforms.
  • Template linker files for GCC_ARM, ARM, and IAR toolchains. LLVM_ARM toolchain support is available on PSE84 platform.
  • For PSE84 platform,design.modus files are provided for each use-case. User needs to navigate to bsps/TARGET_APP_<Target>/config directory and remove design.modus, then copy and paste ./template_linkers/PSE84/<USE-CASE>/<EPC2/EPC4>/design.modus file to bsps/TARGET_APP_<Target>/config

Note:

  1. If the user modifies the default load addresses of the CM33 Non-Secure and CM55 projects, the updated values must override the start addresses using the CY_CM33_NS_APP_BOOT_ADDR and CY_CM55_APP_BOOT_ADDR macros.
  2. For more information on how to modify the PSE84 memory configurations for different use-cases, see the https://github.com/Infineon/mtb-example-edge-protect-bootloader/blob/master/README.md "PSOC&trade; Edge Protect Bootloader Code Example README".
  3. For more information on how to configure Encryption support on the PSE84 platform or how to configure OctalSPI mode, see the ./source/COMPONENT_IFX_MCUBOOT/IFX_MCUBOOT_APP_README.md "IFX MCUBootApp Usage Instructions".
  • Storage operation callback APIs to handle MCUBootloader based upgrade image.
  • Prebuild and Postbuild scripts for generating and signing MCUBootloader based BOOT and UPGRADE image of an OTA Application.

Supported devices:

  • PSOC™ 6 MCU with
    • AIROCâ„¢ CYW4343W
    • CYW43012 Wi-Fi & Bluetooth® combo chip
  • CYW920829M2EVK-02 evaluation board.
  • CY8CKIT-062-BLE
  • CY8CPROTO-063-BLE
  • CYBLE-416045-EVAL
  • KIT_XMC72_EVK
  • KIT_XMC72_EVK_MUR_43439M2
  • KIT_XMC71_EVK_LITE_V1
  • CYW989829M2EVB-01
  • CY8CEVAL-062S2-CYW955513SDM2WLIPA
  • KIT_PSE84_EVAL_EPC2
  • KIT_PSE84_EVAL_EPC4

The ota-update along with ota-bootloader-abstraction library works in concert with MCUBootloader to provide a no-fail solution to updating device software in the field.

MCUBootloader is a secure bootloader application for 32-bit microcontrollers and users should build it outside of the user OTA application. It is programmed separately to the device before flashing the user OTA application and is not updated for the life of the device.

User OTA application will include the ota-update library along with ota-bootloader-abstraction library, which will set the appropriate flags so that MCUBootloader knows when to perform an update of your application. The OTA library will download a new (updated) application, store it in flash, and set flags so that on the next reset, MCUBootloader will see there is an update available.

The basic device boot sequence is as follows:

  1. ROM boot will start MCUBootloader
  2. If no update is downloaded, MCUBootloader starts the current application.
  3. MCUBootloader determines if there is an update in the Secondary Slot
  4. If there is an update available:
    a. MCUBootloader verifies the update.
    b. MCUBootloader SWAPs (or OVERWRITEs) the current with the update applications.
    c. MCUBootloader starts the new (updated) application.
    d. The updated application must call cy_ota_storage_image_validate() to validate the update.
    e. For SWAP, if the new application does not call cy_ota_storage_image_validate(), MCUBootloader will REVERT on the next reset.
  5. The MCUBootloader also supports direct execute-in-place (XIP) functionality. In this process, the upgrade file is downloaded to an inactive slot. After verification, during the next reboot, instead of performing a swap or overwrite, the MCUBootloader loads the upgrade image directly from the inactive slot. Consequently, the inactive slot becomes active, while the previously active slot is designated as inactive.

Note: On secure MCUs such as PSOC™ 64, MCUBootloader is flashed as part of the provisioning step performed by the provisioning tools, and does not need to be built separately. For more information, see the ./source/COMPONENT_MCUBOOT/MCUBOOT_APP_README.md "MCUBootApp Usage Instructions".

Note: The MCUBootloader direct execute-in-place (XIP) functionality is currently supported only on the CYW920829 and CYW989829 platforms, and is compatible exclusively with the GCC-ARM toolchain.

Flash Layout Requirements

MCUBootApp and the OTA enabled application must use the same flash layout.

The flash is separated into sections also called slots. The current application occupies the Primary (BOOT) Slot. The update application (new version) will be downloaded into the Secondary (UPGRADE) Slot. Besides primary and secondary slots, MCUBootApp has a code section, a section for a "Swap Buffer" and a section for "Status Info".

Section Size Description
MCUBootApp 0x00028000 MCUBootApp code
Primary Slot Varies by flash size User Application (current)
Secondary Slot Same size as Primary Update Application (new)
Swap Buffer Varies by flash size Used by MCUBootApp for SWAP operation
Status Varies by size of Slots Used by MCUBootApp for update status

For more information, see the ./source/COMPONENT_MCUBOOT/MCUBOOT_OTA_FLASH_LAYOUT_README.md "OTA Flash Layout Information".

Target and Flashmap Use

Template flashmaps for the supported targets as of v1.X release. These flashmaps are available in MCUBootloader based OTA Flashmap folder.

Target Internal
Flash size
OTA_PLATFORM Flashmaps
CY8CPROTO-062-4343W
CY8CKIT-062S2-43012
CY8CPROTO-062-4343W
CY8CEVAL-062S2-LAI-4373M2
CY8CEVAL-062S2-MUR-43439M2
CY8CEVAL-062S2-CYW955513SDM2WLIPA
2M PSOC_062_2M Default - psoc62_2m_ext_swap_single.json
psoc62_2m_ext_overwrite_single.json
psoc62_2m_int_overwrite_single.json
psoc62_2m_int_swap_single.json
CY8CKIT-062-BLE 1M PSOC_062_1M Default - psoc62_1m_cm0_int_swap_single.json
CY8CPROTO-063-BLE
CYBLE-416045-EVAL
1M PSOC_063_1M Default - psoc63_1m_cm0_int_swap_single.json
CY8CPROTO-062S3-4343W 512K PSOC_062_512K Default - psoc62_512k_xip_swap_single.json
psoc62_512k_ext_overwrite_single.json
psoc62_512k_ext_swap_single.json
CY8CKIT-064B0S2-4343W 2M PSOC_064_2M Default - policy_single_CM0_CM4_smif_swap.json
CYW920829M2EVK-02 0K CYW20829 Default - cyw20829_xip_swap_single.json
cyw20829_xip_overwrite_single.json
cyw20829_xip_direct.json
CYW989829M2EVB-01 0K CYW89829 Default - cyw89829_xip_swap_single.json
cyw89829_xip_overwrite_single.json
cyw89829_xip_direct.json
KIT_XMC71_EVK_LITE_V1 4MB XMC7100 Default - xmc7100_int_swap_single.json
xmc7100_int_overwrite_single.json
KIT_XMC72_EVK
KIT_XMC72_EVK_MUR_43439M2
8MB XMC7200 Default - xmc7200_int_swap_single.json
xmc7200_int_overwrite_single.json
2M Internal Flash Maps Memory Usage
psoc62_2m_ext_overwrite_single.json Internal primary, external secondary
psoc62_2m_ext_swap_single.json Internal primary, external secondary
psoc62_2m_int_overwrite_single.json Internal only (primary and secondary)
psoc62_2m_int_swap_single.json Internal only (primary and secondary)
1M Internal Flash Maps Memory Usage
psoc62_1m_cm0_int_swap_single.json Internal only (primary and secondary)
psoc63_1m_cm0_int_swap_single.json Internal only (primary and secondary)
512K Internal Flash Maps Memory Usage
psoc62_512k_ext_overwrite_single.json Internal primary, external secondary
psoc62_512k_ext_swap_single.json Internal primary, external secondary
psoc62_512k_xip_swap_single.json External only (primary and secondary)
0K Internal Flash Maps Memory Usage
cyw20829_xip_overwrite_single.json External only (primary and secondary)
cyw20829_xip_swap_single.json External only (primary and secondary)
cyw20829_xip_direct.json External only (primary and secondary)
cyw89829_xip_overwrite_single.json External only (primary and secondary)
cyw89829_xip_swap_single.json External only (primary and secondary)
cyw89829_xip_direct.json External only (primary and secondary)
4M Internal Flash Maps Memory Usage
xmc7100_int_swap_single.json Internal only (primary and secondary)
xmc7100_int_overwrite_single.json Internal only (primary and secondary)
8M Internal Flash Maps Memory Usage
xmc7200_int_swap_single.json Internal only (primary and secondary)
xmc7200_int_overwrite_single.json Internal only (primary and secondary)

MCUBootApp Cloning and Building

The MCUBootloader application (MCUBootApp) is a standalone application. It is open source software that is customized in terms of flash map and is built outside of ModusToolbox™. MCUBootApp is programmed/flashed on the device one time, at manufacture (or for development).

  • MCUBootApp runs on the CM0+ CPU and starts any OTA-enabled application on the CM4 core for multi-core PSOC™ 6 devices, and on the CM7 core for XMC7100 and XMC7200 devices.
  • In case of CYW20829 and CYW89829 devices, MCUBootApp runs on CM33 CPU along with the OTA enabled applications.

MCUBoot itself is not OTA upgradable.

For cloning and building MCUBootApp refer to ./source/COMPONENT_MCUBOOT/MCUBOOT_APP_README.md "MCUBootApp README".

OTA Boot and Upgrade Image Encryption Support for CYW20829/CYW89829

  • The ota-bootloader-abstraction library supports the handling of encrypted UPGRADE images through on-the-fly encryption logic.
  • The downloaded signed image is encrypted using the provisioned encryption key, applicable to both the SECURE and NONSECURE lifecycles of the CYW20829/CYW89829.
  • For information on provisioning the CYW20829/CYW89829 in either SECURE or NONSECURE lifecycle modes, please refer to the following links: ``` https://github.com/Infineon/cysecuretools/blob/master/docs/README_CYW20829.md https://github.com/Infineon/edgeprotecttools/blob/master/docs/README_CYW20829.md ```
  • The MCUBootloader utilizes the same provisioned encryption key to decrypt the OTA image during the boot process.
  • ota-bootloader-abstraction library provides a sample flash operation implementation that supports encryption using SMIF APIs.
  • To enable support for handling OTA image encryption, add the following macro definitions to the application makefile: ``` DEFINE+=ENABLE_ON_THE_FLY_ENCRYPTION=1 DEFINE+=CY_XIP_SMIF_MODE_CHANGE=1 ```
  • The current version of the ota-bootloader-abstraction library does not include a post-build script for generating an encrypted BOOT image of the OTA application. Therefore, use the following command to encrypt the OTA application BOOT image: ``` cysecuretools -t cyw20829 encrypt –input $OTA_APP_SIGNED_BIN –output $OTA_APP_ENCRYPTED_BIN –iv 0x08020000 –enckey ./keys/encrypt_key.bin –nonce $NONCE_FILE cysecuretools -t cyw89829 encrypt –input $OTA_APP_SIGNED_BIN –output $OTA_APP_ENCRYPTED_BIN –iv 0x08020000 –enckey ./keys/encrypt_key.bin –nonce $NONCE_FILE ``` *** NOTE : *** When encrypting the OTA application BOOT image, ensure that you use the same encryption key that has been provisioned to the device, as well as the same nonce that was used for encrypting the MCUBootApp.
  • For the 'on-the-fly' encryption use case, first build the MCUBootApp with encryption support enabled. Next, create the OTA application boot image with 'on-the-fly' encryption support and subsequently encrypt the OTA application boot image using the designated encryption key.
  • Program the MCUBootApp with encryption support and the encrypted OTA application boot image. Only the signed OTA image should be sent as the upgrade image. The ota-bootloader-abstraction library receives the segments of the signed upgrade image, encrypts these segments with the provisioned encryption key using the SMIF APIs, and writes them to external flash.
  • MCUBootloader manages the encrypted OTA upgrade images utilizing the provisioned encryption key.

CYW955913EVK-01 In-Built Bootloader Support

ota-bootloader-abstraction library has below support for CYW955913EVK-01 in-built Bootloader based OTA.

  • Storage operation callback APIs to handle the in-built Bootloader based upgrade image.

Supported devices:

  • CYW955913EVK-01.

The ota-update along with ota-bootloader-abstraction library works in concert with CYW955913EVK-01 in-built Bootloader to provide a no-fail solution to updating device software in the field.

An in-built Bootloader is preprogrammed on CYW955913EVK-01 and is not updated for the life of the device.

User OTA application will include the ota-update library along with ota-bootloader-abstraction library, which will set the appropriate flags so that CYW955913EVK-01 in-built bootloader knows when to perform an update of your application. The OTA library will download a new (updated) application, store it in flash, and set flags so that on the next reset, Bootloader will see there is an update available.

The basic device boot sequence is as follows:

  1. ROM boot will start CYW955913EVK-01 in-built Bootloader.
  2. The in-built Bootloader starts the current application in Active DS.
  3. If an update is available, the OTA application uses the ota-update and ota-bootloader-abstraction library to download and store it in the Non-Active DS. Subsequently,
    a. When the switch image API (cy_ota_storage_switch_to_new_image) is called, the CYW955913EVK-01 in-built Bootloader verifies the update image headers and certificates.
    b. Upon finding a valid upgrade image, the CYW955913EVK-01 in-built Bootloader activates the Non-Active DS and designates the active DS as Non-Active DS.
    c. Following a reset, the CYW955913EVK-01 in-built Bootloader initiates the application (Upgraded Image) in the Active DS.

Enabling MCUBootloader-Based OTA in an Application

  • Before enabling MCUBootloader-based OTA in an application, build and program MCUBootApp on the chosen platform(s). Refer to the ./source/COMPONENT_MCUBOOT/MCUBOOT_APP_README.md "MCUBootApp Usage Instructions".
  • Create an ota-bootloader-abstraction.mtb file to pull ota-bootloader-abstraction library which has storage APIs to handle the MCUBootloader based OTA upgrade files. Place ota-bootloader-abstraction.mtb in the application deps folder. The contents of ota-bootloader-abstraction.mtb should be as follows: ``` https://github.com/Infineon/ota-bootloader-abstraction#latest-v1.X#$$ASSET_REPO$$/ota-bootloader-abstraction/latest-v1.X ```
  • To verify the downloaded OTA image before rebooting and enable the Direct-XIP feature, create an mcuboot.mtb file to include the mcuboot library, which contains the APIs necessary for verifying the OTA upgrade files for the MCUBootloader. Place the mcuboot.mtb file in the application's deps folder. The contents of mcuboot.mtb should be structured as follows: ``` https://github.com/mcu-tools/mcuboot#v1.9.6-cypress#$$ASSET_REPO$$/mcuboot/v1.9.6-cypress ```
  • After adding ota-bootloader-abstraction.mtb file to the deps folder of your application, Run the command 'make getlibs' to fetch ota-bootloader-abstraction library and its dependencies. ``` make getlibs ```
  • Update OTA Application makefile by referring ./source/COMPONENT_MCUBOOT/MCUBOOT_OTA_MAKEFILE_INFO_README.md "OTA Bootloader Abstraction Makefile Readme".
  • For MCUBootloader based OTA Support, add the following components to the Application makefile. ``` COMPONENTS+=MCUBOOT ```
  • Make sure that the Python module is installed on your computer, preferably Python version 3.8. Additionally, Application need to provide the path to the installed Python module by setting CY_PYTHON_PATH in the OTA Application makefile. The pre and post build scripts of the ota-bootloader-abstraction library use this Python module to parse memory configurations. ``` CY_PYTHON_PATH = <Path to="" python="" module>=""> ```
  • ota-bootloader-abstraction library has makefile mcuboot_support.mk located in makefiles folder which has necessary pre and post build scripts for generating MCUBootloader based BOOT and UPGRADE images of OTA application.
  • Include mcuboot_support.mk which is located in makefiles folder from OTA Application makefile. ``` include ../mtb_shared/ota-bootloader-abstraction/<version>/makefiles/mcuboot/mcuboot_support.mk ```
  • Configure OTA storage interface callback APIs in OTA application, And pass the same storage interface while starting OTA agent. ``` /* OTA storage interface callbacks */ cy_ota_storage_interface_t ota_interfaces = { .ota_file_open = cy_ota_storage_open, .ota_file_read = cy_ota_storage_read, .ota_file_write = cy_ota_storage_write, .ota_file_close = cy_ota_storage_close, .ota_file_verify = cy_ota_storage_verify, .ota_file_set_boot_pending = cy_ota_storage_set_boot_pending, .ota_file_validate = cy_ota_storage_image_validate, .ota_file_get_app_info = cy_ota_storage_get_app_info };

    /* Register OTA storage interface callbacks with OTA agent */ cy_ota_agent_start(&ota_test_network_params, &ota_test_agent_params, &ota_interfaces, &ota_context);

    ```

  • OTA storage interface calls Flash operations(Read, Write, erase) to store upgrade images in UPGRADE slot. ota-bootloader-abstraction implements flash operation using serial-memory library for PSE84 platform. User needs to pull this library by creating a serial-memory.mtb file and place it the application's deps folder. The contents of serial-memory.mtb should be as follows: ``` mtb:serial-memory#release-v3.0.0#$$ASSET_REPO$$/serial-memory/release-v3.0.0 ``` For all other platforms, ota-bootloader-abstraction implements flash operation using PDL APIs and implementation is available in configs folder. User can use same implementation by copying contents of configs folder to application space or Can implement flash operation APIs defined in cy_ota_flash.h.
  • For secure platforms such as PSOC™ 64, MCUBootloader is programmed during the kit provisioning process. Follow the steps in the Provisioning PSOC 64 section before building the OTA application.
  • During application build, Required BOOT and UPGRADE images(.bin) of OTA application will get generated in configured build directory.
  • Program the BOOT image and use UPGRADE image (<App name>="">.bin) for OTA.

Provisioning PSOC 64

  • For secure platforms such as PSOC™ 64, MCUBootloader is programmed during the kit provisioning process.
  • Prior to provisioning the PSOC™ 64 kit (CY8CKIT-064B0S2-4343W), User need to create policies and keys for provisioning. To do this, execute the following 'init' command from application root folder. ``` cysecuretools -t CY8CKIT-064B0S2-4343W init ```
  • The init command creates the keys, packets, policy, and prebuilt directories in application root folder. These keys and policies are utilized during the provisioning and OTA image signing process.
  • Copy policy policy_single_CM0_CM4_smif_swap.json from configs folder and replace it with the one in policy folder which is generated after executing init command.
  • Please copy the policy_single_CM0_CM4_smif_swap.json file from the configs folder and replace it with the version in the policy folder, which will be generated after running the init command.
  • The public key is programmed during the provisioning for further image verification. The private key is used to sign the image with the user application. Create a private key using below command. The public part of the key will be taken from the private during provisioning. ``` cysecuretools -t CY8CKIT-064B0S2-4343W -p policy/policy_single_CM0_CM4_swap.json create-keys ```
  • Provision the kit with policy policy_single_CM0_CM4_smif_swap.json. Refer https://github.com/Infineon/cysecuretools/blob/master/docs/README_PSOC64.md "Provisioning Steps for CY8CKIT-064B0S2-4343W" for complete provisionig steps.
  • During provisioning, the MCU bootloader is also loaded and executed from the CM0 core upon reboot.

Enabling OTA on CYW955913EVK-01 Applications

  • Create an ota-bootloader-abstraction.mtb file to pull ota-bootloader-abstraction library which has storage APIs to handle the MCUBootloader based OTA upgrade files. Place ota-bootloader-abstraction.mtb in the application deps folder. The contents of ota-bootloader-abstraction.mtb should be as follows: ``` https://github.com/Infineon/ota-bootloader-abstraction#latest-v1.X#$$ASSET_REPO$$/ota-bootloader-abstraction/latest-v1.X ```
  • After adding ota-bootloader-abstraction.mtb file to the deps folder of your application, Run the command 'make getlibs' to fetch ota-bootloader-abstraction library and its dependencies. ``` make getlibs ```
  • Update the OTA application Makefile by referring to the ./source/COMPONENT_CYW955913SDCM2WLIPA/CYW955913SDCM2WLIPA_OTA_MAKEFILE_INFO_README.md "OTA Application Makefile settings for CYW955913EVK-01".
  • For CYW955913EVK-01 in-built Bootloader based OTA Support, add the following components to the Application makefile. ``` COMPONENTS+=CYW955913SDCM2WLIPA ```
  • Configure OTA storage interface callback APIs in OTA application, And pass the same storage interface while starting OTA agent. ``` /* OTA storage interface callbacks */ cy_ota_storage_interface_t ota_interfaces = { .ota_file_open = cy_ota_storage_open, .ota_file_read = cy_ota_storage_read, .ota_file_write = cy_ota_storage_write, .ota_file_close = cy_ota_storage_close, .ota_file_verify = cy_ota_storage_verify, .ota_file_validate = cy_ota_storage_image_validate, .ota_file_get_app_info = cy_ota_storage_get_app_info };

    /* Register OTA storage interface callbacks with OTA agent */ cy_ota_agent_start(&ota_test_network_params, &ota_test_agent_params, &ota_interfaces, &ota_context);

    ```

  • OTA storage interface calls Flash operations(Read, Write, erase) to store upgrade images in Non active DS.
  • Once after succesfully downloading OTA upgrade image, switch to new image by calling cy_ota_storage_switch_to_new_image() which is available in source/COMPONENT_CYW955913SDCM2WLIPA/cy_ota_storage_api.c.
  • During application build, Required BOOT and UPGRADE images(.bin) of OTA application will get generated in configured build directory.
  • Program the BOOT image and use UPGRADE image (<App name>="">.bin) for OTA.

Enabling Debug Output

The ota-bootloader-abstraction library disables all debug log messages by default. Do the following to enable log messages:

  1. Add the ENABLE_OTA_BOOTLOADER_ABSTRACTION_LOGS macro to the DEFINES in the code example's makefile. The makefile entry should look as follows: ``` DEFINES+=ENABLE_OTA_BOOTLOADER_ABSTRACTION_LOGS ```
  2. Call the cy_log_init() function provided by the cy-log module. cy-log is part of the connectivity-utilities library. See the connectivity-utilities Reference Manual for cy-log details.

Note on Using Windows 10

When using ModusToolbox™, you need to install the pip requirements to the Python in the ModusToolbox™ installation:

``` <ModusToolbox>/tools_3.*/python/python -m pip install -r <ota-bootloader-abstraction>/scripts/mcuboot/imgtool/requirements.txt ```

Supported Toolchains

  • GCC
  • IAR
  • Arm C

For the toolchain version information, see ./RELEASE.md "RELEASE.md".

Supported Operating Systems

  • FreeRTOS
  • ThreadX

Hardware Setup

This library uses the board's default configuration. See the kit user guide to ensure the board is configured correctly.

Note: Before using an OTA code example, make sure the board is upgraded to KitProg3. The tool and instructions are available in the Firmware Loader GitHub repository. If you do not upgrade, you may see an error such as "unable to find CMSIS-DAP device" or "KitProg firmware is out of date".

Additional Information

For PSOC™ 6 MCU devices, see How to Design with PSOC 6 MCU - KBA223067 in the Infineon community.

Release Notes and Changelog

  • ./RELEASE.md "RELEASE.md" - Detailed release notes and changelog for all versions.

The following table summarizes the library versions and the ModusToolbox™ version each was validated against:

Library Version Supported ModusToolbox™ Version Remarks
ota-bootloader-abstraction v1.8 ModusToolbox™ 3.6 MCUBootloader-based direct-XIP OTA support added for CYW89829. Added encryption support for the PSOC™ Edge E84 (PSE84) platform. edgeprotecttools >= 1.5 required.
ota-bootloader-abstraction v1.7 ModusToolbox™ 3.6 Encrypted OTA image handling added for CYW955913EVK-01. Added support for the PSOC™ Edge E84 (PSE84) platform and MTB_HAL APIs.
ota-bootloader-abstraction v1.6 ModusToolbox™ 3.5 MCUBootloader-based direct-XIP OTA support added for CYW20829.
ota-bootloader-abstraction v1.5 ModusToolbox™ 3.3 XMC7100 (KIT_XMC71_EVK_LITE_V1) platform support added. Image encryption support added for the CYW20829 platform.
ota-bootloader-abstraction v1.4 ModusToolbox™ 3.2 CY8CEVAL-062S2-CYW955513SDM2WLIPA platform support added. Secure LCS and OTA image encryption added for the CYW920829 platform. cysecuretools v6.1 or greater required.
ota-bootloader-abstraction v1.2 ModusToolbox™ 3.2 CYW955913EVK-01 platform support added.
ota-bootloader-abstraction v1.1 ModusToolbox™ 3.2 CYW89829 platform support added.
ota-bootloader-abstraction v1.0 ModusToolbox™ 3.1 cysecuretools v5.0 or greater required.

License

This library is provided under the Infineon software license terms. It is intended to be used together with the Infineon ota-update library and, for MCUBootloader-based OTA, pulls in the mcuboot library (mcu-tools/mcuboot, pinned to v1.9.6-cypress) and, on the PSOC™ Edge E84 (PSE84) platform, the serial-memory library; these dependent and third-party components are governed by their respective license terms. You are responsible for reviewing and accepting all applicable license terms.

Copyright

$ Copyright 2026-YEAR Infineon Technologies AddOn $