Bootloader failure bug

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

cross mob
Anonymous
Not applicable

I found a way to crash the bootloader when using the I2C interface.  In fact, this should affect any bootloader.  The CYBTLDR_COMMAND_DATA command does not restrict the user from appending data past the dataBuffer boundary.  This will cause unexpected behavior.  In the case of my I2C bootloader, I2C NAKs data from all further transfers, preventing it from performing any command.  Although this can be considered an user error, but the result is a complete failure, which is unacceptable for a bootloader.

   

 

   

   

Original code:

   

   

case CYBTLDR_COMMAND_DATA:

   

                    /* We have part of a block of data. */

   

                    ackCode = CYRET_SUCCESS;

   

                    memcpy(&dataBuffer[dataOffset], &packetBuffer[CYBTLDR_DATA_ADDR], pktSize);

   

                    dataOffset += pktSize;

   

                    break;

   

 

   

New code:

   

   

case CYBTLDR_COMMAND_DATA:

   

                    /* We have part of a block of data. */

   

                    ackCode = CYRET_SUCCESS;

   

                    if ( (dataOffset + pktSize) < SIZEOF_COMMAND_BUFFER )

   

                    {

   

                        memcpy(&dataBuffer[dataOffset], &packetBuffer[CYBTLDR_DATA_ADDR], pktSize);

   

                        dataOffset += pktSize;

   

                    }

   

                    else

   

                    {

   

                        ackCode = CYRET_ERR_LENGTH;

   

                    }

   

                    

   

                    break;

0 Likes
3 Replies
Anonymous
Not applicable

 CYBTLDR_COMMAND_PROGRAM needs to be fixed as well.

0 Likes
Anonymous
Not applicable

 Also, is there a way to redirect the CyComponentLibrary?  We have multiple PSoC 3 users and I would like to provide a fixed  copy of the library for everyone in my network.

0 Likes
Anonymous
Not applicable

Interesting.

0 Likes