Skip to content

Commit

Permalink
Upload ota-bootloader-abstraction 1.4.0.341 [2641]
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlab-runner committed Aug 2, 2024
1 parent a022e31 commit 57dff04
Show file tree
Hide file tree
Showing 16 changed files with 777 additions and 134 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ See the [ota-update](https://github.com/Infineon/ota-update/) library documentat

| Library Version | Supported MTB version | Remarks |
|---------------------------------| -------------------------|-------------------------------------------|
| ota-bootloader-abstraction v1.2.0 | ModusToolbox 3.2 | CYW955913EVK-01 platform support added |
| ota-bootloader-abstraction v1.1.0 | ModusToolbox 3.2 | CYW89829 platform support added |
| ota-bootloader-abstraction v1.0.0 | ModusToolbox 3.1 | cysecuretools v5.0 or greater is required |
| ota-bootloader-abstraction v1.4.0 | ModusToolbox 3.2 | CY8CEVAL-062S2-CYW955513SDM2WLIPA kit support added.<br>Support for secure LCS and OTA image encryption has been added to the CYW920829 platform.<br>cysecuretools v6.1 or greater is required. |
| ota-bootloader-abstraction v1.2.0 | ModusToolbox 3.2 | CYW955913EVK-01 platform support added |
| ota-bootloader-abstraction v1.1.0 | ModusToolbox 3.2 | CYW89829 platform support added |
| ota-bootloader-abstraction v1.0.0 | ModusToolbox 3.1 | cysecuretools v5.0 or greater is required |

## 1. Bootloader Support
To add different bootloader support on Infineon connectivity-enabled MCU platforms, [ota-update](https://github.com/Infineon/ota-update/) library offloads bootloader specific storage interface APIs using callback mechanism.
Expand Down Expand Up @@ -73,15 +74,16 @@ typedef struct cy_ota_storage_interface_s
- Prebuild and Postbuild scripts for generating and signing MCUBootloader based BOOT and UPGRADE image of an OTA Application.

<b> Supported devices: </b><br>
- PSoC™ 6 MCU with
- AIROC™ CYW4343W
- CYW43012 Wi-Fi & Bluetooth® combo chip
- 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
- CYW989829M2EVB-01
- CY8CEVAL-062S2-CYW955513SDM2WLIPA

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.

Expand All @@ -100,7 +102,7 @@ User OTA application will include the *ota-update* library along with *ota-bootl
d. The updated application must call cy_ota_storage_image_validate() to validate the update.<br>
e. For SWAP, if the new application does not call cy_ota_storage_image_validate(), MCUBootloader will REVERT on the next reset.<br>

<b> NOTE:</b> 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 [MCUBootloader App Information](./source/COMPONENT_MCUBOOT/MCUBOOT_APP_README.md#5-cysecuretools-for-psoc-64-and-cyw20829-devices).<br><br>
<b> NOTE:</b> 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 [MCUBootloader App Information](./source/COMPONENT_MCUBOOT/MCUBOOT_APP_README.md#5-cysecuretools-for-psoc-64-and-cyw20829-devices).<br><br>

<b> 2.1 Flash layout requirements</b><br>

Expand All @@ -125,7 +127,7 @@ Template flashmaps for the supported targets as of v1.0.0 release. These flashma

| Target | Internal<br>Flash size | OTA_PLATFORM | Flashmaps |
|-------------------|---------------------|----|------|
| CY8CPROTO-062-4343W<br>CY8CKIT-062S2-43012<br>CY8CPROTO-062-4343W<br>CY8CEVAL-062S2-LAI-4373M2<br>CY8CEVAL-062S2-MUR-43439M2| 2M | PSOC_062_2M | Default - psoc62_2m_ext_swap_single.json<br>psoc62_2m_ext_overwrite_single.json<br>psoc62_2m_int_overwrite_single.json<br>psoc62_2m_int_swap_single.json|
| CY8CPROTO-062-4343W<br>CY8CKIT-062S2-43012<br>CY8CPROTO-062-4343W<br>CY8CEVAL-062S2-LAI-4373M2<br>CY8CEVAL-062S2-MUR-43439M2<br>CY8CEVAL-062S2-CYW955513SDM2WLIPA| 2M | PSOC_062_2M | Default - psoc62_2m_ext_swap_single.json<br>psoc62_2m_ext_overwrite_single.json<br>psoc62_2m_int_overwrite_single.json<br>psoc62_2m_int_swap_single.json|
| CY8CKIT-062-BLE | 1M | PSOC_062_1M |Default - psoc62_1m_cm0_int_swap_single.json |
| CY8CPROTO-063-BLE<br>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<br> psoc62_512k_ext_overwrite_single.json<br>psoc62_512k_ext_swap_single.json |
Expand Down Expand Up @@ -358,17 +360,17 @@ For the toolchain version information, please refer to [ota-bootloader-abstracti

## 10. Supported Kits

- [PSoC™ 6 Wi-Fi BT Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062-4343w/) (CY8CPROTO-062-4343W)
- [PSoC™ 62S2 Wi-Fi BT Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-062s2-43012/) (CY8CKIT-062S2-43012)
- [PSoC™ 62S3 Wi-Fi BT Prototyping Kit ](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062s3-4343w/)(CY8CPROTO-062S3-4343W)
- [PSoC™ 64 Secure Boot Wi-Fi BT Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-064b0s2-4343w/) (CY8CKIT-064B0S2-4343W)
- [CY8CEVAL-062S2 Evaluation Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ceval-062s2/)(CY8CEVAL-062S2-LAI-4373M2 and CY8CEVAL-062S2-MUR-43439M2)
- [PSoC™ 6-BLE Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-062-ble/) (CY8CKIT-062-BLE)
- [PSoC™ 6 BLE Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-063-ble/) (CY8CPROTO-063-BLE)
- [PSoC™ 6 Wi-Fi BT Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062-4343w/) (CY8CPROTO-062-4343W)
- [PSoC™ 62S2 Wi-Fi BT Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-062s2-43012/) (CY8CKIT-062S2-43012)
- [PSoC™ 62S3 Wi-Fi BT Prototyping Kit ](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062s3-4343w/)(CY8CPROTO-062S3-4343W)
- [PSoC™ 64 Secure Boot Wi-Fi BT Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-064b0s2-4343w/) (CY8CKIT-064B0S2-4343W)
- [CY8CEVAL-062S2 Evaluation Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ceval-062s2/)(CY8CEVAL-062S2-LAI-4373M2, CY8CEVAL-062S2-MUR-43439M2 and CY8CEVAL-062S2-CYW955513SDM2WLIPA)
- [PSoC™ 6-BLE Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-062-ble/) (CY8CKIT-062-BLE)
- [PSoC™ 6 BLE Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-063-ble/) (CY8CPROTO-063-BLE)
- [EZ-BLE Arduino Evaluation Board](https://www.infineon.com/cms/en/product/evaluation-boards/cyble-416045-eval/) (CYBLE-416045-EVAL)
- [AIROC™ CYW20829 Bluetooth® LE SoC](https://www.infineon.com/cms/en/product/promopages/airoc20829/) (CYW920829M2EVK-02)
- [AIROC™ CYW20829 Bluetooth® LE SoC](https://www.infineon.com/cms/en/product/promopages/airoc20829/) (CYW920829M2EVK-02)
- [XMC7200 Evaluation Kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc72_evk/) (KIT_XMC72_EVK)
- [AIROC™ CYW989820M2EVB-01 Evaluation kit](https://www.infineon.com/cms/en/product/wireless-connectivity/airoc-bluetooth-le-bluetooth-multiprotocol/airoc-bluetooth-le/cyw20829/)(CYW989820M2EVB-01)
- [AIROC™ CYW989820M2EVB-01 Evaluation kit](https://www.infineon.com/cms/en/product/wireless-connectivity/airoc-bluetooth-le-bluetooth-multiprotocol/airoc-bluetooth-le/cyw20829/)(CYW989820M2EVB-01)
- [CYW955913EVK-01 Wi-Fi Bluetooth&reg; Prototyping Kit (CYW955913EVK-01)](https://www.infineon.com/CYW955913EVK-01)

## 9. Hardware Setup
Expand All @@ -393,4 +395,4 @@ This example uses the board's default configuration. See the kit user guide to e

Infineon also provides a wealth of data at www.infineon.com to help you select the right device, and quickly and effectively integrate it into your design.

For PSoC™ 6 MCU devices, see [How to Design with PSoC 6 MCU - KBA223067](https://community.infineon.com/t5/Knowledge-Base-Articles/How-to-Design-with-PSoC-6-MCU-KBA223067/ta-p/248857) in the Infineon community.
For PSoC™ 6 MCU devices, see [How to Design with PSoC 6 MCU - KBA223067](https://community.infineon.com/t5/Knowledge-Base-Articles/How-to-Design-with-PSoC-6-MCU-KBA223067/ta-p/248857) in the Infineon community.
5 changes: 5 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ See the [README.md](./README.md) for a complete description of the OTA bootloade

## Changelog

### v1.4.0

- Added support for CY8CEVAL-062S2-CYW955513SDM2WLIPA kit.
- Support for secure LCS and OTA image encryption has been added to the CYW920829 platform.

### v1.2.1

- Minor Documentation update.
Expand Down
173 changes: 162 additions & 11 deletions configs/COMPONENT_MCUBOOT/flash/cy_ota_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/

/*
* Flash operation callback implementation for OTA update.
* Flash operation callback implementation for OTA libraries.
*/

/* Header file includes */
Expand Down Expand Up @@ -117,6 +117,8 @@
#define POST_SMIF_ACCESS_TURN_ON_XIP
#endif

#define CY_BOOT_TRAILER_MAX_UPDATE_SIZE (16)

/**********************************************************************************************************************************
* local variables & data
**********************************************************************************************************************************/
Expand All @@ -125,7 +127,7 @@ static cy_stc_smif_context_t ota_QSPI_context;
static volatile uint32_t status_flags;

/* Default QSPI configuration */
const cy_stc_smif_config_t ota_SMIF_config =
cy_stc_smif_config_t ota_SMIF_config =
{
.mode = (uint32_t)CY_SMIF_NORMAL,
.deselectDelay = _CYHAL_QSPI_DESELECT_DELAY,
Expand All @@ -146,10 +148,53 @@ static uint8_t read_back_test[1024];
#endif
#endif /* CY_IP_MXSMIF & !XMC7200 */

#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
/**
* @brief Local buffer for data flash write
*/
uint8_t *write_buffer = NULL;
#endif

/**********************************************************************************************************************************
* Internal Functions
**********************************************************************************************************************************/
#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
static bool ota_allocate_write_buffer(uint64_t size)
{
if(write_buffer != NULL)
{
free(write_buffer);
write_buffer = NULL;
}

write_buffer = (uint8_t *)malloc(size);
if(write_buffer == NULL)
{
return false;
}
else
{
return true;
}
}

static void ota_free_write_buffer(void)
{
if(write_buffer != NULL)
{
free(write_buffer);
write_buffer = NULL;
}
}

static uint32_t cy_flash_addr_to_cbus_addr(uint32_t secondary_addr)
{
uint32_t cbus_addr = 0;
cbus_addr = CY_XIP_CBUS_BASE + secondary_addr;
return cbus_addr;
}
#endif

#if defined(CY_IP_MXSMIF) && !defined(PSOC_062_1M) && !defined(XMC7200)
#if defined(OTA_USE_EXTERNAL_FLASH)
/*******************************************************************************
Expand Down Expand Up @@ -597,8 +642,10 @@ cy_rslt_t cy_ota_mem_init( void )
cy_rslt_t smif_status = CY_SMIF_BAD_PARAM; /* Does not return error if SMIF Quad fails */
bool QE_status = false;

#ifndef ENABLE_ON_THE_FLY_ENCRYPTION
/* pre-access to SMIF */
PRE_SMIF_ACCESS_TURN_OFF_XIP;
#endif

#if (defined (CYW20829B0LKML) || defined (CYW89829B01MKSBG))
/* SMIF is already initialized for 20829 and 89829 so we are only initializing the
Expand Down Expand Up @@ -685,9 +732,11 @@ cy_rslt_t cy_ota_mem_init( void )
SET_FLAG(FLAG_HAL_INIT_DONE);

_bail:
#ifndef ENABLE_ON_THE_FLY_ENCRYPTION
/* post-access to SMIF */
POST_SMIF_ACCESS_TURN_ON_XIP;
#endif
#endif
#endif /* CY_IP_MXSMIF & !XMC7200 */
return result;
}
Expand Down Expand Up @@ -793,6 +842,9 @@ static cy_rslt_t cy_ota_mem_write_row_size( cy_ota_mem_type_t mem_type, uint32_t
{
#if (defined (CY_IP_MXSMIF) && !defined (XMC7200))
cy_en_smif_status_t cy_smif_result = CY_SMIF_SUCCESS;
#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
uint32_t cbus_addr = 0;
#endif

if (addr >= CY_SMIF_BASE_MEM_OFFSET)
{
Expand All @@ -801,37 +853,98 @@ static cy_rslt_t cy_ota_mem_write_row_size( cy_ota_mem_type_t mem_type, uint32_t

if (IS_FLAG_SET(FLAG_HAL_INIT_DONE))
{
#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
cbus_addr = cy_flash_addr_to_cbus_addr(addr);
if(ota_allocate_write_buffer(len) != true)
{
printf("\n%s() - Memory allocation failed at %d\n", __func__, __LINE__);
return CY_RSLT_TYPE_ERROR;
}

memcpy(write_buffer, data, len);

/* pre-access to SMIF */
PRE_SMIF_ACCESS_TURN_OFF_XIP;

cy_smif_result = Cy_SMIF_MemWrite(SMIF0, smifBlockConfig.memConfig[MEM_SLOT],
addr, data, len, &ota_QSPI_context);
/* Encrypt ota_Buffer */
cy_smif_result = Cy_SMIF_Encrypt(SMIF0, cbus_addr, write_buffer, len, &ota_QSPI_context);

/* post-access to SMIF */
POST_SMIF_ACCESS_TURN_ON_XIP;

if(cy_smif_result == CY_SMIF_SUCCESS)
{
cy_smif_result = Cy_SMIF_MemWrite(SMIF0, smifBlockConfig.memConfig[MEM_SLOT], addr, write_buffer, len, &ota_QSPI_context);
}

ota_free_write_buffer();
#else
if(cy_smif_result == CY_SMIF_SUCCESS)
{
/* pre-access to SMIF */
PRE_SMIF_ACCESS_TURN_OFF_XIP;
cy_smif_result = Cy_SMIF_MemWrite(SMIF0, smifBlockConfig.memConfig[MEM_SLOT], addr, data, len, &ota_QSPI_context);
/* post-access to SMIF */
POST_SMIF_ACCESS_TURN_ON_XIP;
}
#endif
}
else
{
cy_smif_result = (cy_en_smif_status_t)CY_RSLT_SERIAL_FLASH_ERR_NOT_INITED;
}

#ifdef READBACK_SMIF_WRITE_TEST
#ifdef READBACK_SMIF_WRITE_TEST
if (cy_smif_result == CY_SMIF_SUCCESS)
{
if (ota_mem_read(CY_OTA_MEM_TYPE_EXTERNAL_FLASH, addr, read_back_test, ((16 < length) ? 16 : len)) == CY_RSLT_SUCCESS)
uint32_t i = 0;
cy_smif_result = cy_ota_mem_read(CY_OTA_MEM_TYPE_EXTERNAL_FLASH, addr, &read_back_test[0], ((16 < len) ? 16 : len));
if(cy_smif_result == CY_RSLT_SUCCESS)
{
int i;
for (i=0; (i<16 && i<len); i++)
#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
printf("\n\rEncrypted Data : ");
for(i = 0; (i < 16 && i < len); i++)
{
printf("0x%02x ", read_back_test[i]);
}
printf("\n\n\r");

cbus_addr = cy_flash_addr_to_cbus_addr(addr);

/* pre-access to SMIF */
PRE_SMIF_ACCESS_TURN_OFF_XIP;

/* Encrypt again read_back_test buffer to get plain txBuffer */
cy_smif_result = Cy_SMIF_Encrypt(SMIF0, cbus_addr, read_back_test, len, &ota_QSPI_context);

/* post-access to SMIF */
POST_SMIF_ACCESS_TURN_ON_XIP;

if(cy_smif_result != CY_SMIF_SUCCESS)
{
printf("[Error] Data encryption failed with error %d\r\n\r\n", cy_smif_result);
}
else
{
printf("\n\rDecrypted Data : ");
for(i = 0; (i < 16 && i < len); i++)
{
printf("0x%02x ", read_back_test[i]);
}
printf("\n\n\r");
}
#endif
for(i = 0; (i < 16 && i < len); i++)
{
if(data[i] != read_back_test[i])
if((((uint8_t *)data)[i]) != read_back_test[i])
{
result = -1;
printf("[Error] Data mismatch at index %d expected : %d got : %d \r\n", i, (((uint8_t *)data)[i]), read_back_test[i]);
}
}
}
}
#endif

#endif
return (cy_smif_result == CY_SMIF_SUCCESS) ? CY_RSLT_SUCCESS : CY_RSLT_TYPE_ERROR;
#else
return CY_RSLT_TYPE_ERROR;
Expand Down Expand Up @@ -870,6 +983,11 @@ cy_rslt_t cy_ota_mem_write( cy_ota_mem_type_t mem_type, uint32_t addr, void *dat
uint32_t curr_addr = addr;
uint8_t *curr_src = data;

#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
cy_en_smif_status_t cy_smif_result = CY_SMIF_SUCCESS;
uint32_t cbus_addr = 0;
#endif

while(bytes_to_write > 0x0U)
{
chunk_size = bytes_to_write;
Expand Down Expand Up @@ -898,8 +1016,41 @@ cy_rslt_t cy_ota_mem_write( cy_ota_mem_type_t mem_type, uint32_t addr, void *dat
{
return CY_RSLT_TYPE_ERROR;
}

#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
cbus_addr = cy_flash_addr_to_cbus_addr(row_base);

/* pre-access to SMIF */
PRE_SMIF_ACCESS_TURN_OFF_XIP;

/* Encrypt again block_buffer to get plain txBuffer */
cy_smif_result = Cy_SMIF_Encrypt(SMIF0, cbus_addr, &(block_buffer[0]), sizeof(block_buffer), &ota_QSPI_context);

/* post-access to SMIF */
POST_SMIF_ACCESS_TURN_ON_XIP;

if(cy_smif_result != CY_SMIF_SUCCESS)
{
printf("[Error] Data encryption failed with error %d\r\n\r\n", cy_smif_result);
}
#endif
memcpy (&block_buffer[row_offset], curr_src, chunk_size);

#ifdef ENABLE_ON_THE_FLY_ENCRYPTION
if(mem_type == CY_OTA_MEM_TYPE_EXTERNAL_FLASH)
{
/* Erase while updating Image trailers */
if(len <= CY_BOOT_TRAILER_MAX_UPDATE_SIZE)
{
result = cy_ota_mem_erase(mem_type, curr_addr, bytes_to_write);
if(result != CY_RSLT_SUCCESS)
{
printf("%s() Erase failed for memory type %d\n", __func__, (int)mem_type);
return CY_RSLT_TYPE_ERROR;
}
}
}
#endif
result = cy_ota_mem_write_row_size(mem_type, row_base, (void *)(&block_buffer[0]), sizeof(block_buffer));
if(result != CY_RSLT_SUCCESS)
{
Expand Down
Loading

0 comments on commit 57dff04

Please sign in to comment.