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.

CC2340R5: CRC bytes in CC2340's CCFG

Part Number: CC2340R5

I'm trying to use CC2340's serial bootloader to flash the device by following the steps in the TRM:

However, the device failed to boot after I programmed the main flash and CCFG, it stayed in SBL and returned error -1274 when I tried to connect to it through a debugger.

I compared the CCFG image used for flashing with a flash dump from a running device, they have several bytes of differences. I replaced the CCFG image with the dumped file and the device can boot properly.

From the TRM, these bytes seems are CRC values and in CCS these bytes are modified after loading the program by the IDE:

But in the image file, these bytes are 0x00 initially. How can I calculate these CRC values and generate a valid CCFG to make the SBL work?

Best regards,

Shuyang

  • Hi Shuyang,

    Thank you for reaching out,

    First take a step back to your issue, does the other "running device" was flash with serial bootloader as well? It is also a CC2340 device?

    Concerning the changing bytes it seems that CCS change the right values but not at the right address, can you check if it's the case for the addresses mentioned by CCS?

    It would be interesting to know if it change right but at the wrong addresses or not at all. 

    It's not recommend to calculate the values by yourself.

    Regards,

  • Hi Guillaume,

    No, by "running device" I mean a device flashed by CCS, not SBL.

    CCS will change these CRC bytes after loading the program, but SBL will not.

    My question is how to change these CRC bytes on the SBL host side to make the device boot properly?

    Best regards,

    Shuyang

  • Hi Shuyang,

    What SBL host are you using?

    In order to calculate the CRCs by yourself  you need to, at a minimum, calculate the same three regions that CCS is calculating. On your screenshot, CCS indicates that it is calculating CRCs based on the following address ranges.

    • ccfg.bootCfg.crc32 [0x4e020000, 0x4E02000B] placing the calculated value in 0x4E02000C
    • ccfg.crc32 [0x4e020010, 0x4E02074B] placing the calculated value in 0x4E02074C
    • ccfg.debugCfg.crc32 [0x4e0207D0, 0x4E0207FB] placing the calculated value in 0x4E0207FC

    These three CRCs are always required for the application to boot. The 4th CRC (ccfg.userRecord.crc32) is completely optional. The ROM code will not refer or confirm this CRC. So you can opt to ignore it if you wish.

    Here's some python code as an example of how to do this.

    # Correct the bootcfg crc
    bootCfg_crc_address = 0x0C
    struct.pack_into("<I", ccfg_contents, bootCfg_crc_address,
        zlib.crc32(bytes(ccfg_contents[0:bootCfg_crc_address]))) 

    Hope this help a little,

    regards,

  • Hi Guillaume,

    Thanks for the detailed explanation. After modifying the CRC bytes from the host side, the device is able to boot up from SBL.

    If I remember it correct, this information is not mentioned in the bootloader chapter of TRM, would you please consider add it to the TRM?

    Thanks.

    Best regards,

    Shuyang

  • Hi Shuyang,

    Glad that it helped you! I'm taking your feedback in consideration and yes it would be nice to detail a bit more this chapter. 

    Thanks and Regards,