This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541: OAD: CRC mismatch between linker (IAR) and BIM

Part Number: CC2541

Hello,

I am trying to implement OAD with the default images sizes and linker files provided in stack "BLE-CC254x-1.4.2.2".  I write the BIM to flash using debug option in IAR then I write the ImageA into flash using debug option in IAR. cc2541 goes into sleep mode because the CRC calculated by BIM (crc[1]) doesn't match with CRC calculated by IAR (crc[0]). 

Can you please help in debugging this?

The details of the setup is as below

bim_main.c constants

/* ------------------------------------------------------------------------------------------------
 *                                          Constants
 * ------------------------------------------------------------------------------------------------
 */

#define BIM_IMG_A_PAGE        1
#define BIM_IMG_A_AREA        62

#define BIM_IMG_B_PAGE        8
#define BIM_IMG_B_AREA       (124 - BIM_IMG_A_AREA)

#define BIM_CRC_OSET          0x00
#define BIM_HDR_OSET          0x00

oad_target.h constants

/*********************************************************************
 * CONSTANTS
 */

#if !defined OAD_IMG_A_PAGE
#define OAD_IMG_A_PAGE        1
#define OAD_IMG_A_AREA        62
#endif

#if !defined OAD_IMG_B_PAGE
// Image-A/B can be very differently sized areas when implementing BIM vice OAD boot loader.
#if defined FEATURE_OAD_BIM
#define OAD_IMG_B_PAGE        8
#else
#define OAD_IMG_B_PAGE        63
#endif
#define OAD_IMG_B_AREA       (124 - OAD_IMG_A_AREA)
#endif

Please let me know if any other info is required.

  • Hi Niraj,

    Can you add the changes suggested by this post: e2e.ti.com/.../1939005

    Best wishes
  • Thanks JKS for the response.

    I tried that without any success.

    On further debug, I found that the image header is not present in the flash. This seems to be a linker issue. 

    The following is the extract from oad_target.c

    #pragma location="IMAGE_HEADER"
    const __code img_hdr_t _imgHdr = {
    #if defined FEATURE_OAD_SECURE
      2012,                       // CRC must not be 0x0000 or 0xFFFF.
    #endif
    #if defined (BOOTP_E_IMAGE_A)
    #warning "Forcing a CRC-shadow match with the BOOTP_E_IMAGE_A flag - is this bootstrap code?"
      2012,                       // CRC-shadow forced to match CRC for a bootstrap Encrypted Image-A
    #else
      0xFFFF,                     // CRC-shadow must be 0xFFFF for everything else
    #endif
      OAD_IMG_VER( OAD_IMAGE_VERSION ), // 15-bit Version #, left-shifted 1; OR with Image-B/Not-A bit.
      OAD_IMG_R_AREA * OAD_FLASH_PAGE_MULT,
    #if defined HAL_IMAGE_A
      OAD_IMAGE_A_USER_ID,        // User-Id
    #else
      OAD_IMAGE_B_USER_ID,        // User-Id
    #endif
      { OAD_MAJOR_VER, OAD_MINOR_VER, OAD_REVISION, 0xFF }  // Reserved
    };
    #pragma required=_imgHdr
    
    #pragma location="AES_HEADER"
    static const __code aes_hdr_t _aesHdr = {
     { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
     { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B },  // Dummy Nonce
     { 0xFF, 0xFF, 0xFF, 0xFF }   // Spare
    };
    #pragma required=_aesHdr
    
    

    The following is the flash read while CRC calculation.

    The first two byte are the CRC calculated by IAR and placed at the beginning of page-1 of flash. But the next bytes where the IMAGE_HEADER and AES_HEADER should be present are all 0xFF. 

    I can observe the rest of the code is present at from 48th byte. (0x0830). Can you help me figure out why the Image header is missing in the flash.