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.

LAUNCHXL-CC26X2R1: regarding function oadImgBlockWrite

Guru 18625 points

Part Number: LAUNCHXL-CC26X2R1

Tool/software:

Dear all,

Let's consider this piece of code from vanilla oad.c file, SDK v7.40

        else if (blkNum == (numBlksInImgHdr - 1))
        {
            ...

            ...
            status = oadValidateCandidateHdr((imgHdr_t * )&candidateImageHeader);
            if(status == OAD_SUCCESS)
            {
            ...
                status = oadEraseExtFlashPages(imagePage, candidateImageHeader.fixedHdr.len, pageSize);
                // Cancel OAD due to flash erase error
                if(FLASH_SUCCESS != status)
                {
                    return (OAD_FLASH_ERR);
                }

            ...


                // Write a OAD_BLOCK to Flash.
                status = writeFlashPg(imagePage, 0,
                                        (uint8_t * ) &candidateImageHeader,
                                        sizeof(imgHdr_t));

                // Cancel OAD due to flash program error
                if(FLASH_SUCCESS != status)
                {
                    return (OAD_FLASH_ERR);
                }


                // If there are non header (image data) bytes in this packet
                // write them to flash as well
                if(nonHeaderBytes)
                {
                    // Write a OAD_BLOCK to Flash.
                    status = writeFlashPg(imagePage,
                                            sizeof(imgHdr_t),
                                            (pValue+OAD_BLK_NUM_HDR_SZ+remainder),
                                            nonHeaderBytes);

                    // Cancel OAD due to flash program error
                    if(FLASH_SUCCESS != status)
                    {
                        return (OAD_FLASH_ERR);
                    }
                }
            }

My concern is about the 2 consecutive calls to writeFlashPg(). 

In them, the offset is properly done. The length in the first call is 141. The length in the second call is 99.

But they both point to the same imagePage counter variable.

In the memory I am using, typical 256 block-size and 4096 sector-size, you cannot do that.

You have to write all at once the content of a 256 block-size. Well, not exactly, but you cannot do a write that extends more than 256.

Thus, I guess I need to add some boundary-check logic to my memory driver code? 

Thanks for your time in advance.