Modustoolbox 2.1 DFU with BLE image write address in flash

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

cross mob
OkBa_4438736
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Hi,

I am using  two APPs for DFU functionality with BLE. App0 is just used as a launcher and App1 provides the main logic.

I am following the instructions from Cypress Device Firmware Update (DFU) Middleware Library 4.0

Host Command/Response protocol processing is as follows :

status = Cy_DFU_Continue(&state, &dfuParams);

  ++count;

   if (state == CY_DFU_STATE_FINISHED)

  {

   /* Finished loading the application image */

   /* Validate DFU application, if it is valid then switch to it */

  status = Cy_DFU_ValidateApp(1u, &dfuParams);

   if (status == CY_DFU_SUCCESS)

  {

   Cy_DFU_TransportStop();

   Cy_DFU_ExecuteApp(1u);

  }

   else if (status == CY_DFU_ERROR_VERIFY)

  {

   /*

  * Restarts loading, an alternatives are to Halt MCU here

  * or switch to the other app if it is valid.

  * Error code may be handled here, i.e. print to debug UART.

  */

  status = Cy_DFU_Init(&state, &dfuParams);

   Cy_DFU_TransportReset();

  }Cy_DFU_Continue(&state, &dfuParams);

In the code example, it looks like the packets are magically written in App1's flash address. How can I validate it ?

I tried to check API function implementations such as Cy_DFU_Continue() however I could not find which flash address is used for the incoming packets to write into flash memory. I know metadata includes the flash layout information. But I could not find the code snippets includes the relation between incoming data and flash addresses in the metadata.

What would happen if I want to use more than one 2 Apps ? How can I choose the one I want to overwrite?

Regards,

0 Likes
1 Solution
HakanJ_21
Employee
Employee
25 sign-ins First comment on KBA First solution authored

Hi OkBa_4438736

The address of the row of flash to write is specified in the "Program Data" DFU Command sent by the DFU Host Tool during a FW update. The DFU Host Tool reads the data, address as well as App ID from the .cyacd2 file. During the FW update, the DFU Host Tool also sends a "Set Application Metadata" command. When the "Set Application Metadata" command is received, the Cy_DFU_Continue API will set the appId ​​member of the cy_stc_dfu_params_t struct. You should be able to use the value of appId to confirm which of the applications that was just updated if needed.


Please refer to "AN213924 - PSoC 6 MCU Device Firmware Update Software Development Kit Guide" for details on the cyacd2 file format and DFU Commands.


/Håkan

View solution in original post

0 Likes
1 Reply
HakanJ_21
Employee
Employee
25 sign-ins First comment on KBA First solution authored

Hi OkBa_4438736

The address of the row of flash to write is specified in the "Program Data" DFU Command sent by the DFU Host Tool during a FW update. The DFU Host Tool reads the data, address as well as App ID from the .cyacd2 file. During the FW update, the DFU Host Tool also sends a "Set Application Metadata" command. When the "Set Application Metadata" command is received, the Cy_DFU_Continue API will set the appId ​​member of the cy_stc_dfu_params_t struct. You should be able to use the value of appId to confirm which of the applications that was just updated if needed.


Please refer to "AN213924 - PSoC 6 MCU Device Firmware Update Software Development Kit Guide" for details on the cyacd2 file format and DFU Commands.


/Håkan

0 Likes