Problem self-validating App1 in App1.

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

cross mob
EdHa_4455331
Level 5
Level 5
25 replies posted 25 sign-ins 10 replies posted

For safety critical reasons, I need app1 to periodically check the integrity of its own image at run time. I knew the App0/bootloader was doing this, so I checked out the function it used to do this, Cy_DFU_ValidateApp. I simplified this down to:

bool ValidateApp1( void )
{
  uint32_t appVerifyStartAddress;
  uint32_t appVerifySize;


  cy_en_dfu_status_t status = Cy_DFU_GetAppMetadata(1, &appVerifyStartAddress, &appVerifySize);


  if (status == CY_DFU_SUCCESS)
  {
    uint32_t appCrc = Cy_DFU_DataChecksum((uint8_t *)appVerifyStartAddress, appVerifySize, NULL);
    uint32_t appFooterAddress = (appVerifyStartAddress + appVerifySize);
    status = (*(uint32_t*)appFooterAddress == appCrc) ? CY_DFU_SUCCESS : CY_DFU_ERROR_VERIFY;
  }

  return (status == CY_DFU_SUCCESS);

}

 

My first attempt to compile this threw the following error:

Build error_ undefined reference to '__cy_boot_metadata_addr'  in file cy_dfu.c.

After a little more tracing through how the App0/bootloader did business, I figured I could resolve this error by adding the line 

#include "dfu_mdk_common.h"

to App1's version of dfu_user.h .

Now when I try to build App1, I get the error:

Build error: expected '(' before 'void'  in file dfu_mdk_common.h at line 109, column 7.

And that line is:

__asm void cy_DFU_mdkAsmDummy(void);

And that error has me totally bewildered.  I believe dfu_mdk_common.h is provided as part of the DFU ecosystem, it seems it should build as-is without an error. And I have absolutely no idea what the compiler is complaining about.

Can anybody give me a suggestion on how to resolve this error?

 

Thanks, Ed H.

0 Likes
1 Solution
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi,

As we see you have called Cy_DFU_GetAppMetadata function from ValidateApp1. But in the Cy_DFU_GetAppMetadata function there is a reference to a section __cy_boot_metadata_addr
If you build, this will throw error until you have defined this section in the linker script.
So you should not include these header files (dfu_mdk_common.h). These are only relevant for ARM MDK.
By default, we are using GCC ARM as the toolchain.
You should use the linker scripts that come with DFU middleware.
You need to add this custom linker script in the makefile,

LINKER_SCRIPT=dfu_cm4_app1.ld

 
Regards
 
Alakananda

View solution in original post

0 Likes
2 Replies
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi,

As we see you have called Cy_DFU_GetAppMetadata function from ValidateApp1. But in the Cy_DFU_GetAppMetadata function there is a reference to a section __cy_boot_metadata_addr
If you build, this will throw error until you have defined this section in the linker script.
So you should not include these header files (dfu_mdk_common.h). These are only relevant for ARM MDK.
By default, we are using GCC ARM as the toolchain.
You should use the linker scripts that come with DFU middleware.
You need to add this custom linker script in the makefile,

LINKER_SCRIPT=dfu_cm4_app1.ld

 
Regards
 
Alakananda
0 Likes

Thank you, but that didn't help at all. 

Let me come at it from a different direction. I DON'T  want to use a boot loader. I DO want to use just a single main app. I DON'T want to do DFUs. And I DO want my image for the single main app to include the checksum that can be generated by the ELF file and I DO want my single main to self-check this checksum. 

How do I modify cy8c6xx7_cm4_dual.ld so that the elf tool will find and fill in the checksum, and how do I check that the code image for the single main app is correct from within the single main app itself?

Thanks,

Ed H.

0 Likes