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: CC2340R5 Bootloader questions

Part Number: CC2340R5
Other Parts Discussed in Thread: CC2538, CC2650, UNIFLASH

Hi,

I am trying to reprogram a CC2340R5 via UART with the ROM bootloader. I am writting the APP correctly (download with crc and send data with all the status correct), but when I try to program the CCFG part I am getting an error CMD_RET_FLASH_FAIL when I write the first block of data of CCFG. I am following the steps described in SWCU193 8.5.4 Page 469.

My firmware is 180704 bytes and CCFG 2048bytes.

I have three questions here:

1.- Which is the meaning of CMD_RET_FLASH_FAIL ?

2.- I am calculating the CRC of 180704Bytes using the following algorithm: 

// Calculate crc32 checksum the way CC2538 and CC2650 does it.
int calcCrcLikeChip(const unsigned char *pData, unsigned long ulByteCount)
{
unsigned long d, ind;
unsigned long acc = 0xFFFFFFFF;
const unsigned long ulCrcRand32Lut[] =
{
0x00000000, 0x1DB71064, 0x3B6E20C8, 0x26D930AC,
0x76DC4190, 0x6B6B51F4, 0x4DB26158, 0x5005713C,
0xEDB88320, 0xF00F9344, 0xD6D6A3E8, 0xCB61B38C,
0x9B64C2B0, 0x86D3D2D4, 0xA00AE278, 0xBDBDF21C
};

while ( ulByteCount-- )
{
d = *pData++;
ind = (acc & 0x0F) ^ (d & 0x0F);
acc = (acc >> 4) ^ ulCrcRand32Lut[ind];
ind = (acc & 0x0F) ^ (d >> 4);
acc = (acc >> 4) ^ ulCrcRand32Lut[ind];
}

return (acc ^ 0xFFFFFFFF);
}

Is there any change? Do I have to take any additional consideration? (Memory alignment etc?)

3.- When I generate the firmware, do I have to fill it with additional zeros and do some kind of alignment? Please tell me if I need to consider additional requirements.

Thanks for the support

  • Hi,

    1.- Which is the meaning of CMD_RET_FLASH_FAIL ?

    Quoting the Technical Reference Manual of the CC23xx SimpleLink Wireless MCU:

    BLDR_CMD_RET_FLASH_FAIL 0x44

    This is returned in response to a
    BLDR_CMD_GET_STATUS
    command and
    indicates that an attempt to program or erase
    the flash has failed.

    If it comes after an erase attempt, it may mean you are attempting to erase a protected sector.

    If it comes after a write attempt, it may be because some CRC are wrong, or you are writing to non-erased sectors.

    2.- I am calculating the CRC of 180704Bytes using the following algorithm: 

    I have to check the algorithm you are using in the details, but it looks ok at first sight.

    May I ask how you are computing the CRC for the CCFG part? At the moment we do not have a proper stand alone tool to compute the CRC of the CCFG. I recommend you actually flash a CC2340R5 device using CCS or Uniflash. Then, dump the content of the CCFG section, so you can have the CRC of the CCFG properly populated.

    Alternatively, you may want to use the CCFG bin file attached (with proper CRC). /cfs-file/__key/communityserver-discussions-components-files/538/ccfg_5F00_CC2340R5.bin (even if the CCFG content is not totally fitting your needs, it will at least show if the system works the way it is supposed to).

    3.- When I generate the firmware, do I have to fill it with additional zeros and do some kind of alignment? Please tell me if I need to consider additional requirements.

    It should not be required as the whole flash has to be erased prior to flash the new image (i.e. no left overs from a previous image should be left).

    I hope this will help,

    Best regards,

  • Hi,

    Thank you for your reply,

    The BLDR_CMD_RET_FLASH_FAIL error comes after write attempt, concretely after writing the CCFG bytes.

    I am calculating the CRC for the CCFG as the same way I do with APP part (using the  calcCrcLikeChip function). Can you tell me how can I extract the CRC of the CCFG file? Can I extract it from the CCFG part of hex file generated from CCS or do I have to dump the CCFG from a flashed chipset? In affirmative case, can you point me how to dump the CCFG and which part I can find the expected CRC?

    Another question, If I use the CMD_DOWNLOAD command instead DONWLOAD_CRC is the chipset expecting the CMD CRC32? Or can I finish the reprogramming procedure without the CRC check?

    Thank you for the support.

    With regards

  • Hi,

    Thank you for your patience while I was away.

    The BLDR_CMD_RET_FLASH_FAIL error comes after write attempt, concretely after writing the CCFG bytes.

    At which address do you write the CCFG bytes?

    I am calculating the CRC for the CCFG as the same way I do with APP part (using the  calcCrcLikeChip function).

    Looks correct to me.

    Can you tell me how can I extract the CRC of the CCFG file?

    The CRC is located at the end of the CCFG region (it is stored on 4 bytes).

    Can I extract it from the CCFG part of hex file generated from CCS or do I have to dump the CCFG from a flashed chipset?

    It has to be extracted from a flash chipset. Actually, CCS tool chain does not populate the aforementioned CRC (it is populated at flash time). For information we are working on a better solution, but it is not yet available.
    For the moment, the CCFG range should be [0x4E020010, 0x4E02074B], and its CRC should be at  address 0x4E02074C.

    In affirmative case, can you point me how to dump the CCFG and which part I can find the expected CRC?

    You can use Uniflash to dump the content of a device's flash. Make sure to select the CCFG region as mentioned before.

    Another question, If I use the CMD_DOWNLOAD command instead DONWLOAD_CRC is the chipset expecting the CMD CRC32? Or can I finish the reprogramming procedure without the CRC check?

    It depends to which exact step you refer to, but the answer is probably no. Please refer to the Technical Reference Manual of the CC23xx SimpleLink Wireless MCU.

    I hope this will help,

    Best regards,