OTA structure(App0 and App1) firmware. App0 Cy_DFU_ValidateApp failed, If Cy_Flash_WriteRow() is called in App1 and then reset the system by pushing reset button

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Jiabin
Level 4
Level 4
100 sign-ins 25 replies posted First solution authored

Hi, 

  I am developing a low-power application using CY8CKIT-062-BLE board.

  I followed the application note "PSoC 6 MCU Device Firmware Update Software Development Kit Guide" and configured a "map A"  BLE DFU Memory Maps.

 

Jiabin_0-1653113777854.png

 

 On the basis of above configuration, I am trying to use the non-volatile memory of PSoC by following the example code : CE220120

 So, In the App1, I declare a const value before the "main()" function:

CY_ALIGN(CY_FLASH_SIZEOF_ROW)
const uint8_t flashData[CY_FLASH_SIZEOF_ROW] = {0}; /* The array will be placed in Flash */

Then in the the "main()" function, I write the following code:

uint8_t ramData[CY_FLASH_SIZEOF_ROW];
Initial_finished=false;
/* Initialize the data in RAM that will be written into flash */
for(uint16_t index = 0; index < CY_FLASH_SIZEOF_ROW; index++)
{
ramData[index] = (uint8_t)index;
}
cy_en_flashdrv_status_t flashWriteStatus;
flashWriteStatus = Cy_Flash_WriteRow((uint32_t)(flashData), (const uint32_t *)ramData);

The App1 properly works after updating the App0 to App1.

However, after I powered off the board and powered on again (or put RESET button ), the system cannot execute App1 properly; it keeps in App0 and waiting for updating image.
I called printf to check what is wrong, and found after resetting, in App0 "status = Cy_DFU_ValidateApp(1u, &dfuParams)", the status is not "CY_DFU_SUCCESS".

If I remove the "Cy_Flash_WriteRow()" function in App1, the App1 can be normally executed after resetting the system.

So my question is:

1. What makes "Cy_DFU_ValidateApp(1u, &dfuParams)" failed after calling "Cy_Flash_WriteRow()" in App1?

2. How to make sure "Cy_DFU_ValidateApp(1u, &dfuParams)" not failed after calling "Cy_Flash_WriteRow()" in App1?

 

Thank you very much for your kind help!!

Best regards,

Jiabin

0 Likes
1 Solution
RavikiranH_01
Employee
Employee
10 sign-ins 25 replies posted 10 replies posted

App0 verifies App1 (uses CRC if you are using the Infineon released Code Example as it is) before jummpig to it. 
From the above explanation, it looks like App0 FAILED to VERIFY App1. 

During the build process (on host PC) a CRC generated and attached to the App1 firmware. It is placed in ".cy_app_signature" section. Please see your App1 main.c & Linker files for details.

Cy_Flash_WriteRow() called from App1 seems to be modifying the "flash" content that is used for CRC calculation; and hence CRC is doesn't match after calling Cy_Flash_WriteRow().

 When you do Cy_Flash_WriteRow(); you could modify the App1 to write to a region outside the  application flash area. For example, you can write to emEeprom region or any other flash region outside the App1's scope. 

See https://github.com/Infineon/mtb-example-psoc6-dfu-basic/blob/master/bootloader_cm4/source/dfu_user.c for emeeprom address range and its usage on P6

View solution in original post

2 Replies
RavikiranH_01
Employee
Employee
10 sign-ins 25 replies posted 10 replies posted

App0 verifies App1 (uses CRC if you are using the Infineon released Code Example as it is) before jummpig to it. 
From the above explanation, it looks like App0 FAILED to VERIFY App1. 

During the build process (on host PC) a CRC generated and attached to the App1 firmware. It is placed in ".cy_app_signature" section. Please see your App1 main.c & Linker files for details.

Cy_Flash_WriteRow() called from App1 seems to be modifying the "flash" content that is used for CRC calculation; and hence CRC is doesn't match after calling Cy_Flash_WriteRow().

 When you do Cy_Flash_WriteRow(); you could modify the App1 to write to a region outside the  application flash area. For example, you can write to emEeprom region or any other flash region outside the App1's scope. 

See https://github.com/Infineon/mtb-example-psoc6-dfu-basic/blob/master/bootloader_cm4/source/dfu_user.c for emeeprom address range and its usage on P6